mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 04:54:32 +00:00
fix(backend): 自分がオーナーではない参加中のルームにメッセージを送信すると不必要な通知が発生するのを修正
This commit is contained in:
parent
2272eceffa
commit
1736955694
1 changed files with 7 additions and 5 deletions
|
@ -199,6 +199,8 @@ export class ChatService {
|
||||||
throw new Error('you are not a member of the room');
|
throw new Error('you are not a member of the room');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const membershipsOtherThanMe = memberships.filter(member => member.userId !== fromUser.id);
|
||||||
|
|
||||||
const message = {
|
const message = {
|
||||||
id: this.idService.gen(),
|
id: this.idService.gen(),
|
||||||
fromUserId: fromUser.id,
|
fromUserId: fromUser.id,
|
||||||
|
@ -216,7 +218,7 @@ export class ChatService {
|
||||||
this.globalEventService.publishChatRoomStream(toRoom.id, 'message', packedMessage);
|
this.globalEventService.publishChatRoomStream(toRoom.id, 'message', packedMessage);
|
||||||
|
|
||||||
const redisPipeline = this.redisClient.pipeline();
|
const redisPipeline = this.redisClient.pipeline();
|
||||||
for (const membership of memberships) {
|
for (const membership of membershipsOtherThanMe) {
|
||||||
if (membership.isMuted) continue;
|
if (membership.isMuted) continue;
|
||||||
|
|
||||||
redisPipeline.set(`newRoomChatMessageExists:${membership.userId}:${toRoom.id}`, message.id);
|
redisPipeline.set(`newRoomChatMessageExists:${membership.userId}:${toRoom.id}`, message.id);
|
||||||
|
@ -227,7 +229,7 @@ export class ChatService {
|
||||||
// 3秒経っても既読にならなかったらイベント発行
|
// 3秒経っても既読にならなかったらイベント発行
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
const redisPipeline = this.redisClient.pipeline();
|
const redisPipeline = this.redisClient.pipeline();
|
||||||
for (const membership of memberships) {
|
for (const membership of membershipsOtherThanMe) {
|
||||||
redisPipeline.get(`newRoomChatMessageExists:${membership.userId}:${toRoom.id}`);
|
redisPipeline.get(`newRoomChatMessageExists:${membership.userId}:${toRoom.id}`);
|
||||||
}
|
}
|
||||||
const markers = await redisPipeline.exec();
|
const markers = await redisPipeline.exec();
|
||||||
|
@ -237,12 +239,12 @@ export class ChatService {
|
||||||
|
|
||||||
const packedMessageForTo = await this.chatEntityService.packMessageDetailed(inserted);
|
const packedMessageForTo = await this.chatEntityService.packMessageDetailed(inserted);
|
||||||
|
|
||||||
for (let i = 0; i < memberships.length; i++) {
|
for (let i = 0; i < membershipsOtherThanMe.length; i++) {
|
||||||
const marker = markers[i][1];
|
const marker = markers[i][1];
|
||||||
if (marker == null) continue;
|
if (marker == null) continue;
|
||||||
|
|
||||||
this.globalEventService.publishMainStream(memberships[i].userId, 'newChatMessage', packedMessageForTo);
|
this.globalEventService.publishMainStream(membershipsOtherThanMe[i].userId, 'newChatMessage', packedMessageForTo);
|
||||||
//this.pushNotificationService.pushNotification(memberships[i].userId, 'newChatMessage', packedMessageForTo);
|
//this.pushNotificationService.pushNotification(membershipsOtherThanMe[i].userId, 'newChatMessage', packedMessageForTo);
|
||||||
}
|
}
|
||||||
}, 3000);
|
}, 3000);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue