diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-25 15:51:45 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-25 15:51:45 +0900 |
| commit | a01ae38a07f949cbcd5ce555cd90e8570bb985cc (patch) | |
| tree | 9227b0625a95a97ccf11970b479ac86b1f42a57b /packages/backend/src/core | |
| parent | enhance: チャットルームに招待されたときの通知を追加 (diff) | |
| download | sharkey-a01ae38a07f949cbcd5ce555cd90e8570bb985cc.tar.gz sharkey-a01ae38a07f949cbcd5ce555cd90e8570bb985cc.tar.bz2 sharkey-a01ae38a07f949cbcd5ce555cd90e8570bb985cc.zip | |
enhance: モデレーターがチャットルームの内容を確認・削除できるように
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/ChatService.ts | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/packages/backend/src/core/ChatService.ts b/packages/backend/src/core/ChatService.ts index 4c010b2ef7..35819a4bc2 100644 --- a/packages/backend/src/core/ChatService.ts +++ b/packages/backend/src/core/ChatService.ts @@ -27,6 +27,7 @@ import { sqlLikeEscape } from '@/misc/sql-like-escape.js'; import { CustomEmojiService } from '@/core/CustomEmojiService.js'; import { emojiRegex } from '@/misc/emoji-regex.js'; import { NotificationService } from '@/core/NotificationService.js'; +import { ModerationLogService } from '@/core/ModerationLogService.js'; const MAX_ROOM_MEMBERS = 30; const MAX_REACTIONS_PER_MESSAGE = 100; @@ -75,6 +76,7 @@ export class ChatService { private roleService: RoleService, private userFollowingService: UserFollowingService, private customEmojiService: CustomEmojiService, + private moderationLogService: ModerationLogService, ) { } @@ -286,6 +288,20 @@ export class ChatService { } @bindThis + public async hasPermissionToViewRoomTimeline(meId: MiUser['id'], room: MiChatRoom) { + if (await this.isRoomMember(room, meId)) { + return true; + } else { + const iAmModerator = await this.roleService.isModerator({ id: meId }); + if (iAmModerator) { + return true; + } + + return false; + } + } + + @bindThis public async deleteMessage(message: MiChatMessage) { await this.chatMessagesRepository.delete(message.id); @@ -493,8 +509,29 @@ export class ChatService { } @bindThis - public async deleteRoom(room: MiChatRoom) { + public async hasPermissionToDeleteRoom(meId: MiUser['id'], room: MiChatRoom) { + if (room.ownerId === meId) { + return true; + } + + const iAmModerator = await this.roleService.isModerator({ id: meId }); + if (iAmModerator) { + return true; + } + + return false; + } + + @bindThis + public async deleteRoom(room: MiChatRoom, moderator?: MiUser) { await this.chatRoomsRepository.delete(room.id); + + if (moderator) { + this.moderationLogService.log(moderator, 'deleteChatRoom', { + roomId: room.id, + room: room, + }); + } } @bindThis |