mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-24 20:13:09 +02:00
「すべて既読にする」でグループメッセージが既読にならない問題を修正 (#6476)
This commit is contained in:
parent
ca25b9acc1
commit
37c16e5b45
1 changed files with 12 additions and 1 deletions
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue