diff --git a/src/api/acts/client.ts b/src/api/acts/client.ts index 476ce1d..313208d 100644 --- a/src/api/acts/client.ts +++ b/src/api/acts/client.ts @@ -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; }); diff --git a/src/api/acts/rooms.ts b/src/api/acts/rooms.ts index dcc37e6..c955ca8 100644 --- a/src/api/acts/rooms.ts +++ b/src/api/acts/rooms.ts @@ -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", ""); diff --git a/src/api/get.ts b/src/api/get.ts index c3b7371..3e63343 100644 --- a/src/api/get.ts +++ b/src/api/get.ts @@ -38,7 +38,7 @@ var Methods: ([string, (req: Request, res: Response) => Promise])[] = [ }], ["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]; diff --git a/src/sys/db.ts b/src/sys/db.ts index a83834a..f689911 100644 --- a/src/sys/db.ts +++ b/src/sys/db.ts @@ -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: "" } diff --git a/tests/tests/post.js b/tests/tests/post.js index 6faf8b5..0b56637 100644 --- a/tests/tests/post.js +++ b/tests/tests/post.js @@ -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" } ]); diff --git a/tests/tests/ws.js b/tests/tests/ws.js index 78a8f5e..c941f35 100644 --- a/tests/tests/ws.js +++ b/tests/tests/ws.js @@ -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" } ]);