fix: improve plugins functionality with server management
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
boolToInt,
|
||||
TransformMap
|
||||
} from './utils/applyUpdates';
|
||||
import { getCurrentUserScope, userOwnsRoom } from '../../current-user-scope';
|
||||
|
||||
const ROOM_TRANSFORMS: TransformMap = {
|
||||
hasPassword: boolToInt,
|
||||
@@ -32,6 +33,12 @@ export async function handleUpdateRoom(command: UpdateRoomCommand, dataSource: D
|
||||
const { roomId, updates } = command.payload;
|
||||
|
||||
await dataSource.transaction(async (manager) => {
|
||||
const currentUserId = await getCurrentUserScope(manager);
|
||||
|
||||
if (!await userOwnsRoom(manager, roomId, currentUserId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const repo = manager.getRepository(RoomEntity);
|
||||
const existing = await repo.findOne({ where: { id: roomId } });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user