fix: handle deleted content in get like data
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
@@ -180,15 +180,20 @@ export class ActivityController {
|
||||
|
||||
for (const item of like.data) {
|
||||
const likeData = pick(item, 'created', 'id') as any
|
||||
if ('nid' in item.ref) {
|
||||
likeData.type = CollectionRefTypes.Note
|
||||
likeData.nid = item.ref.nid
|
||||
|
||||
if (!item.ref) {
|
||||
likeData.title = '已删除的内容'
|
||||
} else {
|
||||
likeData.type = CollectionRefTypes.Post
|
||||
likeData.slug = item.ref.slug
|
||||
if ('nid' in item.ref) {
|
||||
likeData.type = CollectionRefTypes.Note
|
||||
likeData.nid = item.ref.nid
|
||||
} else {
|
||||
likeData.type = CollectionRefTypes.Post
|
||||
likeData.slug = item.ref.slug
|
||||
}
|
||||
likeData.title = item.ref.title
|
||||
}
|
||||
|
||||
likeData.title = item.ref.title
|
||||
transformedLike.push(likeData)
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,9 @@ export class ActivityService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
const docsWithRefModel = activities.docs.map((ac) => {
|
||||
const nextAc = ac.toJSON()
|
||||
Reflect.set(nextAc, 'ref', refModelData.get(ac.payload.id))
|
||||
const refModel = refModelData.get(ac.payload.id)
|
||||
|
||||
refModel && Reflect.set(nextAc, 'ref', refModel)
|
||||
|
||||
return nextAc
|
||||
}) as any as (ActivityModel & {
|
||||
|
||||
Reference in New Issue
Block a user