rename public to visibilty

This commit is contained in:
jusax23 2023-03-18 17:58:59 +01:00
parent e640d325f1
commit e54894821a
Signed by: jusax23
GPG key ID: 499E2AA870C1CD41
6 changed files with 34 additions and 34 deletions

View file

@ -99,7 +99,7 @@ export const createRoom = {
server: "string", // Unused/Ignored at the Moment server: "string", // Unused/Ignored at the Moment
title: "string-255", title: "string-255",
description: "string-255", description: "string-255",
public: "number", visibility: "number",
icon: "string-255" icon: "string-255"
}, },
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => { func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
@ -109,14 +109,14 @@ export const createRoom = {
let req = await insert( let req = await insert(
rooms.name, rooms.name,
rooms.owner, rooms.owner,
rooms.public, rooms.visibility,
rooms.title, rooms.title,
rooms.description, rooms.description,
rooms.icon rooms.icon
).add( ).add(
data.room, data.room,
client.accID, client.accID,
data.public, data.visibility,
data.title, data.title,
data.description, data.description,
data.icon data.icon
@ -164,21 +164,21 @@ export const listPublicRooms = {
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => { func: async (client: Client, data: any, aws: (code: string, data: any) => void) => {
let req = await select([ let req = await select([
rooms.name, rooms.name,
rooms.public, rooms.publvisibilityic,
rooms.title, rooms.title,
rooms.description, rooms.description,
rooms.icon rooms.icon
], rooms) ], rooms)
.where(ge(rooms.public, 0)) .where(ge(rooms.visibility, 0))
.query(db); .query(db);
let out = req.map(d => { let out = req.map(d => {
let name = d[rooms.name]; let name = d[rooms.name];
let isPublic = d[rooms.public]; let visibility = d[rooms.visibility];
let title = d[rooms.title]; let title = d[rooms.title];
let description = d[rooms.description]; let description = d[rooms.description];
let icon = d[rooms.icon]; let icon = d[rooms.icon];
if (name != null && isPublic != null && title != null && description != null && icon != null) { if (name != null && visibility != null && title != null && description != null && icon != null) {
return { name, public: isPublic, title, description, icon }; return { name, visibility, title, description, icon };
} }
return null; return null;
}); });

View file

@ -18,7 +18,7 @@ export const listLocalRooms: Act = {
rooms.name, rooms.name,
ownerAlias, ownerAlias,
rooms.rights, rooms.rights,
rooms.public, rooms.visibility,
rooms.title, rooms.title,
rooms.description, rooms.description,
rooms.icon rooms.icon
@ -32,12 +32,12 @@ export const listLocalRooms: Act = {
let name = d[rooms.name]; let name = d[rooms.name];
let owner = d[ownerAlias]; let owner = d[ownerAlias];
let rights = d[rooms.rights]; let rights = d[rooms.rights];
let isPublic = d[rooms.public]; let visibility = d[rooms.visibility];
let title = d[rooms.title]; let title = d[rooms.title];
let description = d[rooms.description]; let description = d[rooms.description];
let icon = d[rooms.icon]; let icon = d[rooms.icon];
if (name != null && owner != null && rights != null && isPublic != null && title != null && description != null && icon != null) { if (name != null && owner != null && rights != null && visibility != null && title != null && description != null && icon != null) {
return { name, owner, rights, public: isPublic, title, description, icon }; return { name, owner, rights, visibility, title, description, icon };
} }
return null; return null;
}); });
@ -132,15 +132,15 @@ export const joinPublicRoom: Act = {
server: "string", // Unused at the Moment server: "string", // Unused at the Moment
}, },
func: async (client: Client, data: any, aws: (code: string, data: any) => void) => { 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)) .where(eq(rooms.name, data.room))
.query(db); .query(db);
let roomID = (query[0] ?? {})[rooms.roomID]; let roomID = (query[0] ?? {})[rooms.roomID];
let isPublic = (query[0] ?? {})[rooms.public]; let visibility = (query[0] ?? {})[rooms.visibility];
if (typeof roomID != "number" || roomID < 0 || typeof isPublic != "number") { if (typeof roomID != "number" || roomID < 0 || typeof visibility != "number") {
return void aws("error", "existence"); 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"); return void aws("error", "existence");
} }
if (await isRoomFull(roomID)) return void aws("error", "limit"); if (await isRoomFull(roomID)) return void aws("error", "limit");
@ -335,14 +335,14 @@ export const roomSettings: Act = {
room: "string", room: "string",
server: "string", // Unused at the Moment server: "string", // Unused at the Moment
rights: "number", //see permissions.ts 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) => { func: async (client, data, aws) => {
let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.CHANGE_SETTINGS); let roomID = await client.isRoomAdmin(data.room, ROOM_RIGHTS.CHANGE_SETTINGS);
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.rights, data.rights)
.set(rooms.public, data.isPublic) .set(rooms.visibility, data.visibility)
.where(eq(rooms.roomID, roomID)) .where(eq(rooms.roomID, roomID))
.query(db); .query(db);
aws("ok", ""); aws("ok", "");

View file

@ -38,7 +38,7 @@ var Methods: ([string, (req: Request, res: Response) => Promise<void>])[] = [
}], }],
["publicRooms", async (req: Request, res: Response) => { ["publicRooms", async (req: Request, res: Response) => {
let data = await select([rooms.name, rooms.title, rooms.description, rooms.icon], rooms) 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); .query(db);
var out = data.map(d => { var out = data.map(d => {
let name = d[rooms.name]; let name = d[rooms.name];

View file

@ -94,7 +94,7 @@ rooms.addAttributes({
} }
}, },
rights: { type: INT, default: 0b11111 }, rights: { type: INT, default: 0b11111 },
public: { type: BOOL, default: 0 }, visibility: { type: BOOL, default: 0 },
title: { type: TEXT, default: "" }, title: { type: TEXT, default: "" },
description: { type: TEXT, default: "" }, description: { type: TEXT, default: "" },
icon: { type: TEXT, default: "" } icon: { type: TEXT, default: "" }

View file

@ -146,7 +146,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
}, "ok", ""); }, "ok", "");
await req({ await req({
@ -156,7 +156,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
}, "error", "existence"); }, "error", "existence");
@ -167,7 +167,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 2", title: "Test Room 2",
description: "some desc 2", description: "some desc 2",
public: 1, visibility: 1,
icon: "" icon: ""
}, "ok", ""); }, "ok", "");
await req({ await req({
@ -177,7 +177,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 2", title: "Test Room 2",
description: "some desc 2", description: "some desc 2",
public: 1, visibility: 1,
icon: "" icon: ""
}, "error", "limit"); }, "error", "limit");
@ -190,7 +190,7 @@ const list = [
rights: 0b11111, rights: 0b11111,
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
}, { }, {
name: room2, name: room2,
@ -198,7 +198,7 @@ const list = [
rights: 0b11111, rights: 0b11111,
title: "Test Room 2", title: "Test Room 2",
description: "some desc 2", description: "some desc 2",
public: 1, visibility: 1,
icon: "" icon: ""
} }
]); ]);
@ -232,7 +232,7 @@ const list = [
rights: 0b11111, rights: 0b11111,
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
} }
]); ]);

View file

@ -147,7 +147,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
}, "ok", ""); }, "ok", "");
await req(handler, "createRoom", { await req(handler, "createRoom", {
@ -155,7 +155,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
}, "error", "existence"); }, "error", "existence");
@ -164,7 +164,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 2", title: "Test Room 2",
description: "some desc 2", description: "some desc 2",
public: 1, visibility: 1,
icon: "" icon: ""
}, "ok", ""); }, "ok", "");
@ -173,7 +173,7 @@ const list = [
server: "localhost:7224", server: "localhost:7224",
title: "Test Room 2", title: "Test Room 2",
description: "some desc 2", description: "some desc 2",
public: 1, visibility: 1,
icon: "" icon: ""
}, "error", "limit"); }, "error", "limit");
@ -184,7 +184,7 @@ const list = [
rights: 0b11111, rights: 0b11111,
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
}, { }, {
name: room2, name: room2,
@ -192,7 +192,7 @@ const list = [
rights: 0b11111, rights: 0b11111,
title: "Test Room 2", title: "Test Room 2",
description: "some desc 2", description: "some desc 2",
public: 1, visibility: 1,
icon: "" icon: ""
} }
]); ]);
@ -215,7 +215,7 @@ const list = [
rights: 0b11111, rights: 0b11111,
title: "Test Room 1", title: "Test Room 1",
description: "some desc", description: "some desc",
public: 0, visibility: 0,
icon: "shopping" icon: "shopping"
} }
]); ]);