room rights restructur
This commit is contained in:
parent
7acac390aa
commit
a717f40a23
2 changed files with 31 additions and 9 deletions
|
@ -435,7 +435,7 @@ export const setAdminStatus: Act = {
|
|||
aws(resp.state, resp.data);
|
||||
return;
|
||||
}
|
||||
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.MANAGE_MEMBERS);
|
||||
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.CHANGE_ADMIN);
|
||||
if (roomID == -1) return void aws("error", "roomAdmin");
|
||||
let req = await update(roomMembers)
|
||||
.set(roomMembers.admin, data.admin)
|
||||
|
@ -499,13 +499,12 @@ export const leaveRoom: Act = {
|
|||
}
|
||||
};
|
||||
|
||||
export const roomSettings: Act = {
|
||||
export const setVisibility: Act = {
|
||||
state: STATE.client | STATE.remote,
|
||||
right: 0,
|
||||
data: {
|
||||
room: "string",
|
||||
server: "string",
|
||||
rights: "number", //see permissions.ts
|
||||
visibility: "number" //0 is not, 1 only to clients, 2 or bigger everywhere
|
||||
},
|
||||
func: async (client, data, aws) => {
|
||||
|
@ -515,18 +514,41 @@ export const roomSettings: Act = {
|
|||
aws(resp.state, resp.data);
|
||||
return;
|
||||
}
|
||||
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.CHANGE_SETTINGS);
|
||||
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.OTA);
|
||||
if (roomID == -1) return void aws("error", "roomAdmin");
|
||||
let req = await update(rooms)
|
||||
.set(rooms.rights, data.rights)
|
||||
.set(rooms.visibility, data.visibility)
|
||||
.where(eq(rooms.roomID, roomID))
|
||||
.query(db);
|
||||
aws("ok", "");
|
||||
}
|
||||
};
|
||||
export const setRoomRight: Act = {
|
||||
state: STATE.client | STATE.remote,
|
||||
right: 0,
|
||||
data: {
|
||||
room: "string",
|
||||
server: "string",
|
||||
rights: "number", //see permissions.ts
|
||||
},
|
||||
func: async (client, data, aws) => {
|
||||
if (!checkSelfTag(data.server)) {
|
||||
if (client.state != STATE.client) return void aws("error", "right");
|
||||
let resp = await client.pass(data.server, "roomSettings", data);
|
||||
aws(resp.state, resp.data);
|
||||
return;
|
||||
}
|
||||
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.CHANGE_ADMIN);
|
||||
if (roomID == -1) return void aws("error", "roomAdmin");
|
||||
let req = await update(rooms)
|
||||
.set(rooms.rights, data.rights)
|
||||
.where(eq(rooms.roomID, roomID))
|
||||
.query(db);
|
||||
aws("ok", "");
|
||||
}
|
||||
};
|
||||
|
||||
export const roomMeta: Act = {
|
||||
export const changeRoomMeta: Act = {
|
||||
state: STATE.client | STATE.remote,
|
||||
right: 0,
|
||||
data: {
|
||||
|
|
|
@ -21,6 +21,6 @@ export const ROOM_RIGHTS = { //when changing, look in main (db defaults)
|
|||
LIST_GROUPS_ITEMS: 0b0000100, //edit room intern listGroups and listItems
|
||||
CHANGE_META: 0b0001000,
|
||||
OTA: 0b0010000, //edit otas
|
||||
CHANGE_SETTINGS: 0b0100000,
|
||||
MANAGE_MEMBERS: 0b1000000,
|
||||
MANAGE_MEMBERS: 0b0100000,
|
||||
CHANGE_ADMIN: 0b1000000,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue