feat: 增加收件箱已读标识

pull/64/head
moonrailgun 2 years ago
parent 692e66d334
commit badfaa07d3

@ -57,6 +57,14 @@ export class Inbox extends TimeStamps implements Base {
type: () => InboxMessage,
})
message?: InboxMessage;
/**
*
*/
@prop({
default: false,
})
readed: boolean;
}
export type InboxDocument = DocumentType<Inbox>;

@ -78,6 +78,11 @@ class InboxService extends TcService {
},
});
this.registerAction('all', this.all);
this.registerAction('ack', this.ack, {
params: {
inboxItemId: 'string',
},
});
}
async appendMessage(
@ -152,6 +157,26 @@ class InboxService extends TcService {
return await this.transformDocuments(ctx, {}, list);
}
/**
*
*/
async ack(ctx: TcContext<{ inboxItemId: string }>) {
const inboxItemId = ctx.params.inboxItemId;
const userId = ctx.meta.userId;
await this.adapter.model.updateOne(
{
_id: inboxItemId,
userId,
},
{
readed: true,
}
);
return true;
}
/**
*
*

Loading…
Cancel
Save