Skip to content

Commit f6ed0c8

Browse files
committed
fix(activity): filter null refs in getRecentComment
Populated comment refs can be null when the referenced document is deleted. Skip those entries to prevent 'Cannot use in operator' error.
1 parent faa7273 commit f6ed0c8

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

apps/core/src/modules/activity/activity.service.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -569,17 +569,19 @@ export class ActivityService implements OnModuleInit, OnModuleDestroy {
569569
)
570570

571571
await this.commentService.fillAndReplaceAvatarUrl(docs)
572-
return docs.map((doc) => {
573-
const categoryId = (doc.ref as any)?.categoryId
574-
return {
575-
...pick(doc, 'created', 'author', 'text', 'avatar'),
576-
...pick(doc.ref, 'title', 'nid', 'slug', 'id'),
577-
category: categoryId
578-
? (categoryMap[categoryId.toString()] ?? undefined)
579-
: undefined,
580-
type: checkRefModelCollectionType(doc.ref),
581-
}
582-
})
572+
return docs
573+
.filter((doc) => doc.ref)
574+
.map((doc) => {
575+
const categoryId = (doc.ref as any)?.categoryId
576+
return {
577+
...pick(doc, 'created', 'author', 'text', 'avatar'),
578+
...pick(doc.ref, 'title', 'nid', 'slug', 'id'),
579+
category: categoryId
580+
? (categoryMap[categoryId.toString()] ?? undefined)
581+
: undefined,
582+
type: checkRefModelCollectionType(doc.ref),
583+
}
584+
})
583585
}
584586

585587
async getRecentPublish() {

0 commit comments

Comments
 (0)