Skip to content

Commit

Permalink
fix: handle deleted content in get like data
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed May 3, 2024
1 parent 0ab422b commit 911640b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 11 additions & 6 deletions apps/core/src/modules/activity/activity.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 3 additions & 1 deletion apps/core/src/modules/activity/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
Expand Down

0 comments on commit 911640b

Please sign in to comment.