WIP Convert spaces into accounts
This commit is contained in:
parent
f92d87bdde
commit
8ad60aa249
86
index.js
86
index.js
@ -1,40 +1,28 @@
|
|||||||
var RemoteStorage = require('remotestoragejs');
|
const Kosmos = function(privateClient/*, publicClient*/) {
|
||||||
|
|
||||||
var Kosmos = function(privateClient/*, publicClient*/) {
|
|
||||||
|
|
||||||
var extend = RemoteStorage.util.extend;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Types/Schemas
|
// Types/Schemas
|
||||||
//
|
//
|
||||||
|
|
||||||
var baseProperties = {
|
privateClient.declareType('chat-account', {
|
||||||
"id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"createdAt": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
},
|
|
||||||
"updatedAt": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
privateClient.declareType('space', {
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": extend({
|
"properties": {
|
||||||
"id": {
|
"id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
},
|
},
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
},
|
|
||||||
"protocol": {
|
"protocol": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "IRC",
|
"default": "IRC",
|
||||||
"enum": ["IRC", "XMPP", "Mattermost", "Slack"]
|
"enum": ["IRC", "XMPP"] // Mattermost, Slack, ...
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"password": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"nickname": {
|
||||||
|
"type": "string"
|
||||||
},
|
},
|
||||||
"server": {
|
"server": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@ -47,49 +35,45 @@ var Kosmos = function(privateClient/*, publicClient*/) {
|
|||||||
},
|
},
|
||||||
"secure": {
|
"secure": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
}
|
||||||
"username": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"password": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"nickname": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"channels": {
|
|
||||||
"type": "array",
|
|
||||||
"default": []
|
|
||||||
},
|
|
||||||
"botkaURL": {
|
"botkaURL": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
},
|
||||||
}, baseProperties),
|
...timestampProperties
|
||||||
"required": ["id", "name", "protocol", "server"]
|
},
|
||||||
|
"required": [
|
||||||
|
"id",
|
||||||
|
"protocol"
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
//
|
||||||
// Public functions
|
// Public functions
|
||||||
//
|
//
|
||||||
|
|
||||||
var kosmos = {
|
const kosmos = {
|
||||||
|
|
||||||
spaces: {
|
accounts: {
|
||||||
|
|
||||||
getAll() {
|
getIds() {
|
||||||
return privateClient.getAll('spaces/');
|
return privateClient.getListing('chat/').then(listing => {
|
||||||
|
return Object.keys(listing.items);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
store(params) {
|
getConfig(id) {
|
||||||
if (!params.createdAt) { params.createdAt = new Date().toISOString(); }
|
return privateClient.getAll(`chat/${id}/account`);
|
||||||
|
|
||||||
return privateClient.storeObject('space', `spaces/${params.id}`, params);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
storeConfig(obj) {
|
||||||
|
return privateClient.storeObject('chat-account', `chat/${obj.id}/account`, obj);
|
||||||
|
},
|
||||||
|
|
||||||
|
// TODO recursively remove all files
|
||||||
remove(id) {
|
remove(id) {
|
||||||
return privateClient.remove(`spaces/${id}`);
|
return privateClient.remove(`chat/${id}/account`);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user