|
|
@ -4,6 +4,7 @@ import {
|
|
|
|
TcContext,
|
|
|
|
TcContext,
|
|
|
|
TcDbService,
|
|
|
|
TcDbService,
|
|
|
|
TcPureContext,
|
|
|
|
TcPureContext,
|
|
|
|
|
|
|
|
InboxStruct,
|
|
|
|
} from 'tailchat-server-sdk';
|
|
|
|
} from 'tailchat-server-sdk';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -114,6 +115,7 @@ class InboxService extends TcService {
|
|
|
|
const inboxItem = await this.transformDocuments(ctx, {}, doc);
|
|
|
|
const inboxItem = await this.transformDocuments(ctx, {}, doc);
|
|
|
|
|
|
|
|
|
|
|
|
await this.notifyUsersInboxAppend(ctx, [userId], inboxItem);
|
|
|
|
await this.notifyUsersInboxAppend(ctx, [userId], inboxItem);
|
|
|
|
|
|
|
|
await this.emitInboxAppendEvent(ctx, inboxItem);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -152,6 +154,7 @@ class InboxService extends TcService {
|
|
|
|
const inboxItem = await this.transformDocuments(ctx, {}, doc);
|
|
|
|
const inboxItem = await this.transformDocuments(ctx, {}, doc);
|
|
|
|
|
|
|
|
|
|
|
|
await this.notifyUsersInboxAppend(ctx, [userId], inboxItem);
|
|
|
|
await this.notifyUsersInboxAppend(ctx, [userId], inboxItem);
|
|
|
|
|
|
|
|
await this.emitInboxAppendEvent(ctx, inboxItem);
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -237,9 +240,7 @@ class InboxService extends TcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 发送通知群组信息有新的内容
|
|
|
|
* 通知用户收件箱追加了新的内容
|
|
|
|
*
|
|
|
|
|
|
|
|
* 发送通知时会同时清空群组信息缓存
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private async notifyUsersInboxAppend(
|
|
|
|
private async notifyUsersInboxAppend(
|
|
|
|
ctx: TcPureContext,
|
|
|
|
ctx: TcPureContext,
|
|
|
@ -250,9 +251,7 @@ class InboxService extends TcService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 发送通知群组信息发生变更
|
|
|
|
* 通知用户收件箱有新的内容
|
|
|
|
*
|
|
|
|
|
|
|
|
* 发送通知时会同时清空群组信息缓存
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private async notifyUsersInboxUpdate(
|
|
|
|
private async notifyUsersInboxUpdate(
|
|
|
|
ctx: TcPureContext,
|
|
|
|
ctx: TcPureContext,
|
|
|
@ -260,6 +259,16 @@ class InboxService extends TcService {
|
|
|
|
): Promise<void> {
|
|
|
|
): Promise<void> {
|
|
|
|
await this.listcastNotify(ctx, userIds, 'updated', {});
|
|
|
|
await this.listcastNotify(ctx, userIds, 'updated', {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 向微服务通知有新的内容产生
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private async emitInboxAppendEvent(
|
|
|
|
|
|
|
|
ctx: TcPureContext,
|
|
|
|
|
|
|
|
inboxItem: InboxStruct
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
await ctx.emit('chat.inbox.append', inboxItem);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default InboxService;
|
|
|
|
export default InboxService;
|
|
|
|