11import type { OnModuleDestroy , OnModuleInit } from '@nestjs/common'
22import { forwardRef , Inject , Injectable , Logger } from '@nestjs/common'
3+ import { omit , pick , uniqBy } from 'es-toolkit/compat'
4+ import { ObjectId } from 'mongodb'
5+ import type { Document } from 'mongoose'
6+ import type { Socket } from 'socket.io'
7+
38import { RequestContext } from '~/common/contexts/request.context'
49import { BizException } from '~/common/exceptions/biz.exception'
510import { ArticleTypeEnum } from '~/constants/article.constant'
@@ -21,10 +26,7 @@ import { transformDataToPaginate } from '~/transformers/paginate.transformer'
2126import { checkRefModelCollectionType } from '~/utils/biz.util'
2227import { dbTransforms } from '~/utils/db-transform.util'
2328import { camelcaseKeys } from '~/utils/tool.util'
24- import { omit , pick , uniqBy } from 'es-toolkit/compat'
25- import { ObjectId } from 'mongodb'
26- import type { Document } from 'mongoose'
27- import type { Socket } from 'socket.io'
29+
2830import { CommentState } from '../comment/comment.model'
2931import { CommentService } from '../comment/comment.service'
3032import { ConfigsService } from '../configs/configs.service'
@@ -540,7 +542,11 @@ export class ActivityService implements OnModuleInit, OnModuleDestroy {
540542 $in : [ CommentState . Read , CommentState . Unread ] ,
541543 } ,
542544 } )
543- . populate ( 'ref' , 'title nid slug subtitle content categoryId' )
545+ . populate ( {
546+ path : 'ref' ,
547+ select : 'title nid slug subtitle content categoryId category' ,
548+ populate : { path : 'category' , select : 'slug name' } ,
549+ } )
544550 . lean ( { getters : true } )
545551 . sort ( {
546552 created : - 1 ,
@@ -551,6 +557,7 @@ export class ActivityService implements OnModuleInit, OnModuleDestroy {
551557 return docs . map ( ( doc ) => ( {
552558 ...pick ( doc , 'created' , 'author' , 'text' , 'avatar' ) ,
553559 ...pick ( doc . ref , 'title' , 'nid' , 'slug' , 'id' ) ,
560+ category : ( doc . ref as any ) ?. category ?? undefined ,
554561 type : checkRefModelCollectionType ( doc . ref ) ,
555562 } ) )
556563 }
0 commit comments