「すべて既読にする」でグループメッセージが既読にならない問題を修正 (#6476)
This commit is contained in:
parent
ca25b9acc1
commit
37c16e5b45
|
@ -1,6 +1,6 @@
|
||||||
import { publishMainStream } from '../../../../services/stream';
|
import { publishMainStream } from '../../../../services/stream';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { MessagingMessages } from '../../../../models';
|
import { MessagingMessages, UserGroupJoinings } from '../../../../models';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
|
@ -27,5 +27,16 @@ export default define(meta, async (ps, user) => {
|
||||||
isRead: true
|
isRead: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const joinings = await UserGroupJoinings.find({ userId: user.id });
|
||||||
|
|
||||||
|
await Promise.all(joinings.map(j => MessagingMessages.createQueryBuilder().update()
|
||||||
|
.set({
|
||||||
|
reads: (() => `array_append("reads", '${user.id}')`) as any
|
||||||
|
})
|
||||||
|
.where(`groupId = :groupId`, { groupId: j.userGroupId })
|
||||||
|
.andWhere('userId != :userId', { userId: user.id })
|
||||||
|
.andWhere('NOT (:userId = ANY(reads))', { userId: user.id })
|
||||||
|
.execute()));
|
||||||
|
|
||||||
publishMainStream(user.id, 'readAllMessagingMessages');
|
publishMainStream(user.id, 'readAllMessagingMessages');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue