Update room management in AdminController: Modify updateRoom and deleteRoom methods to include userId as a parameter for improved access control.
This commit is contained in:
19
backend/migrations/add_chat_room_dialog_fields.sql
Normal file
19
backend/migrations/add_chat_room_dialog_fields.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE chat.room
|
||||
ADD COLUMN IF NOT EXISTS gender_restriction_id INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS min_age INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS max_age INTEGER,
|
||||
ADD COLUMN IF NOT EXISTS password VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS friends_of_owner_only BOOLEAN DEFAULT FALSE,
|
||||
ADD COLUMN IF NOT EXISTS required_user_right_id INTEGER;
|
||||
|
||||
UPDATE chat.room
|
||||
SET friends_of_owner_only = FALSE
|
||||
WHERE friends_of_owner_only IS NULL;
|
||||
|
||||
ALTER TABLE chat.room
|
||||
ALTER COLUMN friends_of_owner_only SET DEFAULT FALSE,
|
||||
ALTER COLUMN friends_of_owner_only SET NOT NULL;
|
||||
|
||||
COMMIT;
|
||||
@@ -15,7 +15,7 @@
|
||||
<tbody>
|
||||
<tr v-for="room in rooms" :key="room.id">
|
||||
<td>{{ room.title }}</td>
|
||||
<td>{{ room.roomTypeTr || room.roomTypeId }}</td>
|
||||
<td>{{ getRoomTypeLabel(room) }}</td>
|
||||
<td>{{ room.isPublic ? $t('common.yes') : $t('common.no') }}</td>
|
||||
<td>
|
||||
<button @click="editRoom(room)">{{ $t('common.edit') }}</button>
|
||||
@@ -48,6 +48,14 @@ export default {
|
||||
this.fetchRooms();
|
||||
},
|
||||
methods: {
|
||||
getRoomTypeLabel(room) {
|
||||
const roomTypeTr = room?.roomType?.tr || room?.roomTypeTr;
|
||||
if (!roomTypeTr) {
|
||||
return room?.roomTypeId ?? '-';
|
||||
}
|
||||
const translationKey = `admin.chatrooms.roomtype.${roomTypeTr}`;
|
||||
return this.$te(translationKey) ? this.$t(translationKey) : roomTypeTr;
|
||||
},
|
||||
openCreateDialog() {
|
||||
this.selectedRoom = null;
|
||||
this.$refs.roomDialog.open();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<tbody>
|
||||
<tr v-for="room in rooms" :key="room.id">
|
||||
<td>{{ room.title }}</td>
|
||||
<td>{{ room.roomTypeTr || room.roomTypeId }}</td>
|
||||
<td>{{ getRoomTypeLabel(room) }}</td>
|
||||
<td>{{ room.isPublic ? $t('common.yes') : $t('common.no') }}</td>
|
||||
<td>
|
||||
<button @click="editRoom(room)">{{ $t('common.edit') }}</button>
|
||||
@@ -68,6 +68,14 @@ export default {
|
||||
const res = await apiClient.get('/api/admin/chat/rooms');
|
||||
this.rooms = res.data;
|
||||
},
|
||||
getRoomTypeLabel(room) {
|
||||
const roomTypeTr = room?.roomType?.tr || room?.roomTypeTr;
|
||||
if (!roomTypeTr) {
|
||||
return room?.roomTypeId ?? '-';
|
||||
}
|
||||
const translationKey = `admin.chatrooms.roomtype.${roomTypeTr}`;
|
||||
return this.$te(translationKey) ? this.$t(translationKey) : roomTypeTr;
|
||||
},
|
||||
async saveRoom(roomData) {
|
||||
// Remove forbidden and associated object fields before sending to backend
|
||||
const { id, ownerId, passwordHash, roomType, genderRestriction, ...cleanData } = roomData;
|
||||
|
||||
Reference in New Issue
Block a user