forked from mirrors/misskey
Merge commit from fork
* fix(backend): restrict chat room / chat message permissions * spec: モデレーター以上の権限では全てを閲覧可能
This commit is contained in:
parent
6c40c96369
commit
04f18fe919
2 changed files with 25 additions and 0 deletions
|
|
@ -572,6 +572,27 @@ export class ChatService {
|
|||
return created;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async hasPermissionToViewRoomInfo(meId: MiUser['id'], room: MiChatRoom) {
|
||||
if (room.ownerId === meId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (await this.isRoomMember(room, meId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (await this.chatRoomInvitationsRepository.findOneBy({ roomId: room.id, userId: meId })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (await this.roleService.isModerator({ id: meId })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async hasPermissionToDeleteRoom(meId: MiUser['id'], room: MiChatRoom) {
|
||||
if (room.ownerId === meId) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
throw new ApiError(meta.errors.noSuchRoom);
|
||||
}
|
||||
|
||||
if (!await this.chatService.hasPermissionToViewRoomInfo(me.id, room)) {
|
||||
throw new ApiError(meta.errors.noSuchRoom);
|
||||
}
|
||||
|
||||
return this.chatEntityService.packRoom(room, me);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue