room rights restructur
This commit is contained in:
parent
7acac390aa
commit
a717f40a23
2 changed files with 31 additions and 9 deletions
|
@ -110,7 +110,7 @@ export const getRoomInfo: Act = {
|
||||||
title: req[0][rooms.title],
|
title: req[0][rooms.title],
|
||||||
description: req[0][rooms.description],
|
description: req[0][rooms.description],
|
||||||
icon: req[0][rooms.icon],
|
icon: req[0][rooms.icon],
|
||||||
|
|
||||||
isAdmin: req[0][roomMembers.admin] ? true : false,
|
isAdmin: req[0][roomMembers.admin] ? true : false,
|
||||||
isOwner: client.state == STATE.client && req[0][ownerAlias] == client.name,
|
isOwner: client.state == STATE.client && req[0][ownerAlias] == client.name,
|
||||||
})
|
})
|
||||||
|
@ -435,7 +435,7 @@ export const setAdminStatus: Act = {
|
||||||
aws(resp.state, resp.data);
|
aws(resp.state, resp.data);
|
||||||
return;
|
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");
|
if (roomID == -1) return void aws("error", "roomAdmin");
|
||||||
let req = await update(roomMembers)
|
let req = await update(roomMembers)
|
||||||
.set(roomMembers.admin, data.admin)
|
.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,
|
state: STATE.client | STATE.remote,
|
||||||
right: 0,
|
right: 0,
|
||||||
data: {
|
data: {
|
||||||
room: "string",
|
room: "string",
|
||||||
server: "string",
|
server: "string",
|
||||||
rights: "number", //see permissions.ts
|
|
||||||
visibility: "number" //0 is not, 1 only to clients, 2 or bigger everywhere
|
visibility: "number" //0 is not, 1 only to clients, 2 or bigger everywhere
|
||||||
},
|
},
|
||||||
func: async (client, data, aws) => {
|
func: async (client, data, aws) => {
|
||||||
|
@ -515,18 +514,41 @@ export const roomSettings: Act = {
|
||||||
aws(resp.state, resp.data);
|
aws(resp.state, resp.data);
|
||||||
return;
|
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");
|
if (roomID == -1) return void aws("error", "roomAdmin");
|
||||||
let req = await update(rooms)
|
let req = await update(rooms)
|
||||||
.set(rooms.rights, data.rights)
|
|
||||||
.set(rooms.visibility, data.visibility)
|
.set(rooms.visibility, data.visibility)
|
||||||
.where(eq(rooms.roomID, roomID))
|
.where(eq(rooms.roomID, roomID))
|
||||||
.query(db);
|
.query(db);
|
||||||
aws("ok", "");
|
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,
|
state: STATE.client | STATE.remote,
|
||||||
right: 0,
|
right: 0,
|
||||||
data: {
|
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
|
LIST_GROUPS_ITEMS: 0b0000100, //edit room intern listGroups and listItems
|
||||||
CHANGE_META: 0b0001000,
|
CHANGE_META: 0b0001000,
|
||||||
OTA: 0b0010000, //edit otas
|
OTA: 0b0010000, //edit otas
|
||||||
CHANGE_SETTINGS: 0b0100000,
|
MANAGE_MEMBERS: 0b0100000,
|
||||||
MANAGE_MEMBERS: 0b1000000,
|
CHANGE_ADMIN: 0b1000000,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue