fix: add some field

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-04-13 19:37:28 +08:00
parent 8d170ed13e
commit 903aa30122
3 changed files with 10 additions and 4 deletions

View File

@@ -186,6 +186,8 @@ export class ActivityController {
likeData.type = CollectionRefTypes.Post
likeData.slug = item.ref.slug
}
likeData.title = item.ref.title
transformedLike.push(likeData)
}

View File

@@ -31,6 +31,7 @@ import { CountingService } from '~/processors/helper/helper.counting.service'
import { EventManagerService } from '~/processors/helper/helper.event.service'
import { InjectModel } from '~/transformers/model.transformer'
import { transformDataToPaginate } from '~/transformers/paginate.transformer'
import { getAvatar } from '~/utils'
import { CommentService } from '../comment/comment.service'
import { Activity } from './activity.constant'
@@ -502,7 +503,7 @@ export class ActivityService implements OnModuleInit, OnModuleDestroy {
})
.populate('ref', 'title nid slug category')
.lean()
.lean({ getters: true })
.sort({
created: -1,
})
@@ -510,9 +511,9 @@ export class ActivityService implements OnModuleInit, OnModuleDestroy {
return docs.map((doc) => {
return Object.assign(
{},
pick(doc, 'created', 'author', 'text'),
pick(doc, 'created', 'author', 'text', 'avatar'),
doc.ref,
!doc.avatar ? { avatar: getAvatar(doc.mail) } : {},
{
type:
'nid' in doc.ref

View File

@@ -61,8 +61,10 @@ export interface RecentComment {
text: string
id: string
title: string
slug: string
slug?: string
type: string
avatar: string
nid?: string
}
export interface RecentLike {
@@ -71,6 +73,7 @@ export interface RecentLike {
type: CollectionRefTypes.Post | CollectionRefTypes.Note
nid?: number
slug?: string
title: string
}
export interface RecentNote {