1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-01 07:35:57 +09:00

「すべて既読にする」でグループメッセージが既読にならない問題を修正 (#6476)

This commit is contained in:
fuyu 2020-07-04 10:45:36 +09:00 committed by GitHub
parent ca25b9acc1
commit 37c16e5b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { publishMainStream } from '../../../../services/stream';
import define from '../../define';
import { MessagingMessages } from '../../../../models';
import { MessagingMessages, UserGroupJoinings } from '../../../../models';
export const meta = {
desc: {
@ -27,5 +27,16 @@ export default define(meta, async (ps, user) => {
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');
});