Add chat channels/rooms

This commit is contained in:
Basti 2021-07-30 09:57:26 +02:00
parent 86c2ac04ba
commit 3601440d9d
Signed by untrusted user: basti
GPG Key ID: 9F88009D31D99C72

View File

@ -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