rename public to visibilty
This commit is contained in:
parent
e640d325f1
commit
e54894821a
6 changed files with 34 additions and 34 deletions
|
@ -99,7 +99,7 @@ export const createRoom = {
|
|||
server: "string", // Unused/Ignored at the Moment
|
||||
title: "string-255",
|
||||
description: "string-255",
|
||||
public: "number",
|
||||
visibility: "number",
|
||||
icon: "string-255"
|
||||
},
|
||||
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
||||
|
@ -109,14 +109,14 @@ export const createRoom = {
|
|||
let req = await insert(
|
||||
rooms.name,
|
||||
rooms.owner,
|
||||
rooms.public,
|
||||
rooms.visibility,
|
||||
rooms.title,
|
||||
rooms.description,
|
||||
rooms.icon
|
||||
).add(
|
||||
data.room,
|
||||
client.accID,
|
||||
data.public,
|
||||
data.visibility,
|
||||
data.title,
|
||||
data.description,
|
||||
data.icon
|
||||
|
@ -164,21 +164,21 @@ export const listPublicRooms = {
|
|||
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
||||
let req = await select([
|
||||
rooms.name,
|
||||
rooms.public,
|
||||
rooms.publvisibilityic,
|
||||
rooms.title,
|
||||
rooms.description,
|
||||
rooms.icon
|
||||
], rooms)
|
||||
.where(ge(rooms.public, 0))
|
||||
.where(ge(rooms.visibility, 0))
|
||||
.query(db);
|
||||
let out = req.map(d => {
|
||||
let name = d[rooms.name];
|
||||
let isPublic = d[rooms.public];
|
||||
let visibility = d[rooms.visibility];
|
||||
let title = d[rooms.title];
|
||||
let description = d[rooms.description];
|
||||
let icon = d[rooms.icon];
|
||||
if (name != null && isPublic != null && title != null && description != null && icon != null) {
|
||||
return { name, public: isPublic, title, description, icon };
|
||||
if (name != null && visibility != null && title != null && description != null && icon != null) {
|
||||
return { name, visibility, title, description, icon };
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export const listLocalRooms: Act = {
|
|||
rooms.name,
|
||||
ownerAlias,
|
||||
rooms.rights,
|
||||
rooms.public,
|
||||
rooms.visibility,
|
||||
rooms.title,
|
||||
rooms.description,
|
||||
rooms.icon
|
||||
|
@ -32,12 +32,12 @@ export const listLocalRooms: Act = {
|
|||
let name = d[rooms.name];
|
||||
let owner = d[ownerAlias];
|
||||
let rights = d[rooms.rights];
|
||||
let isPublic = d[rooms.public];
|
||||
let visibility = d[rooms.visibility];
|
||||
let title = d[rooms.title];
|
||||
let description = d[rooms.description];
|
||||
let icon = d[rooms.icon];
|
||||
if (name != null && owner != null && rights != null && isPublic != null && title != null && description != null && icon != null) {
|
||||
return { name, owner, rights, public: isPublic, title, description, icon };
|
||||
if (name != null && owner != null && rights != null && visibility != null && title != null && description != null && icon != null) {
|
||||
return { name, owner, rights, visibility, title, description, icon };
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
@ -132,15 +132,15 @@ export const joinPublicRoom: Act = {
|
|||
server: "string", // Unused at the Moment
|
||||
},
|
||||
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
|
||||
let query = await select([rooms.roomID, rooms.public], rooms)
|
||||
let query = await select([rooms.roomID, rooms.visibility], rooms)
|
||||
.where(eq(rooms.name, data.room))
|
||||
.query(db);
|
||||
let roomID = (query[0] ?? {})[rooms.roomID];
|
||||
let isPublic = (query[0] ?? {})[rooms.public];
|
||||
if (typeof roomID != "number" || roomID < 0 || typeof isPublic != "number") {
|
||||
let visibility = (query[0] ?? {})[rooms.visibility];
|
||||
if (typeof roomID != "number" || roomID < 0 || typeof visibility != "number") {
|
||||
return void aws("error", "existence");
|
||||
}
|
||||
if (((client.state == STATE.client) && (isPublic < 1)) || ((client.state == STATE.remote) && (isPublic < 2))) {
|
||||
if (((client.state == STATE.client) && (visibility < 1)) || ((client.state == STATE.remote) && (visibility < 2))) {
|
||||
return void aws("error", "existence");
|
||||
}
|
||||
if (await isRoomFull(roomID)) return void aws("error", "limit");
|
||||
|
@ -335,14 +335,14 @@ export const roomSettings: Act = {
|
|||
room: "string",
|
||||
server: "string", // Unused at the Moment
|
||||
rights: "number", //see permissions.ts
|
||||
isPublic: "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) => {
|
||||
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.CHANGE_SETTINGS);
|
||||
if (roomID == -1) return void aws("error", "roomAdmin");
|
||||
let req = await update(rooms)
|
||||
.set(rooms.rights, data.rights)
|
||||
.set(rooms.public, data.isPublic)
|
||||
.set(rooms.visibility, data.visibility)
|
||||
.where(eq(rooms.roomID, roomID))
|
||||
.query(db);
|
||||
aws("ok", "");
|
||||
|
|
|
@ -38,7 +38,7 @@ var Methods: ([string, (req: Request, res: Response) => Promise<void>])[] = [
|
|||
}],
|
||||
["publicRooms", async (req: Request, res: Response) => {
|
||||
let data = await select([rooms.name, rooms.title, rooms.description, rooms.icon], rooms)
|
||||
.where(ge(rooms.public, 1))
|
||||
.where(ge(rooms.visibility, 1))
|
||||
.query(db);
|
||||
var out = data.map(d => {
|
||||
let name = d[rooms.name];
|
||||
|
|
|
@ -94,7 +94,7 @@ rooms.addAttributes({
|
|||
}
|
||||
},
|
||||
rights: { type: INT, default: 0b11111 },
|
||||
public: { type: BOOL, default: 0 },
|
||||
visibility: { type: BOOL, default: 0 },
|
||||
title: { type: TEXT, default: "" },
|
||||
description: { type: TEXT, default: "" },
|
||||
icon: { type: TEXT, default: "" }
|
||||
|
|
|
@ -146,7 +146,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}, "ok", "");
|
||||
await req({
|
||||
|
@ -156,7 +156,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}, "error", "existence");
|
||||
|
||||
|
@ -167,7 +167,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 2",
|
||||
description: "some desc 2",
|
||||
public: 1,
|
||||
visibility: 1,
|
||||
icon: ""
|
||||
}, "ok", "");
|
||||
await req({
|
||||
|
@ -177,7 +177,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 2",
|
||||
description: "some desc 2",
|
||||
public: 1,
|
||||
visibility: 1,
|
||||
icon: ""
|
||||
}, "error", "limit");
|
||||
|
||||
|
@ -190,7 +190,7 @@ const list = [
|
|||
rights: 0b11111,
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}, {
|
||||
name: room2,
|
||||
|
@ -198,7 +198,7 @@ const list = [
|
|||
rights: 0b11111,
|
||||
title: "Test Room 2",
|
||||
description: "some desc 2",
|
||||
public: 1,
|
||||
visibility: 1,
|
||||
icon: ""
|
||||
}
|
||||
]);
|
||||
|
@ -232,7 +232,7 @@ const list = [
|
|||
rights: 0b11111,
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}
|
||||
]);
|
||||
|
|
|
@ -147,7 +147,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}, "ok", "");
|
||||
await req(handler, "createRoom", {
|
||||
|
@ -155,7 +155,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}, "error", "existence");
|
||||
|
||||
|
@ -164,7 +164,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 2",
|
||||
description: "some desc 2",
|
||||
public: 1,
|
||||
visibility: 1,
|
||||
icon: ""
|
||||
}, "ok", "");
|
||||
|
||||
|
@ -173,7 +173,7 @@ const list = [
|
|||
server: "localhost:7224",
|
||||
title: "Test Room 2",
|
||||
description: "some desc 2",
|
||||
public: 1,
|
||||
visibility: 1,
|
||||
icon: ""
|
||||
}, "error", "limit");
|
||||
|
||||
|
@ -184,7 +184,7 @@ const list = [
|
|||
rights: 0b11111,
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}, {
|
||||
name: room2,
|
||||
|
@ -192,7 +192,7 @@ const list = [
|
|||
rights: 0b11111,
|
||||
title: "Test Room 2",
|
||||
description: "some desc 2",
|
||||
public: 1,
|
||||
visibility: 1,
|
||||
icon: ""
|
||||
}
|
||||
]);
|
||||
|
@ -215,7 +215,7 @@ const list = [
|
|||
rights: 0b11111,
|
||||
title: "Test Room 1",
|
||||
description: "some desc",
|
||||
public: 0,
|
||||
visibility: 0,
|
||||
icon: "shopping"
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue