From 3601440d9d86ef5999d410721691c7ac9439aee2 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Fri, 30 Jul 2021 09:57:26 +0200 Subject: [PATCH] Add chat channels/rooms --- index.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 0a93d03..a6bd475 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,28 @@ const Kosmos = function(privateClient/*, publicClient*/) { ] }); + privateClient.declareType('chat-channel', { + "type": "object", + "properties": { + "id": { + "type": "string", + }, + "accountId": { + "type": "string" + }, + "displayName": { + "type": [ "string", "null" ] + }, + "userNickname": { + "type": [ "string", "null" ] + } + }, + "required": [ + "id", + "accountId" + ] + }); + // // Public functions // @@ -55,7 +77,6 @@ const Kosmos = function(privateClient/*, publicClient*/) { const kosmos = { accounts: { - getIds() { return privateClient.getListing('chat/').then(listing => { return Object.keys(listing).map(id => id.replace(/\/$/, '')); @@ -74,7 +95,20 @@ const Kosmos = function(privateClient/*, publicClient*/) { remove(id) { return privateClient.remove(`chat/${id}/account`); } + }, + channels: { + getAll(accountId) { + return privateClient.getAll(`chat/${accountId}/channels/`); + }, + + store(obj) { + return privateClient.storeObject('chat-channel', `chat/${obj.accountId}/channels/${obj.id}`, obj); + }, + + remove(accountId, id) { + return privateClient.remove(`chat/${accountId}/${id}`); + } }, // TODO remove