From ac9668557b7e67c4a1be0cc7c64bda1b14541cf9 Mon Sep 17 00:00:00 2001 From: shockrah Date: Thu, 28 Jan 2021 17:56:40 -0800 Subject: [PATCH] Testing out a new module for channels api hits --- freechat-client/src/channels.js | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 freechat-client/src/channels.js diff --git a/freechat-client/src/channels.js b/freechat-client/src/channels.js new file mode 100644 index 0000000..9259119 --- /dev/null +++ b/freechat-client/src/channels.js @@ -0,0 +1,49 @@ +// Requesting channel data here +const auth = require('./auth.js') +const { Request } = require('./request.js') + +class Channel { + constructor(name, id, type, description) { + this.name = name + this.id = id + this.type = type + this.description = description + } + +} + + +/** + * + * @param {String} domain | domain of the instance we're looking at + * @param {Number} port | Should always be the default value of 4536 but other owner + * @param {Object} params | basic object with jwt + id fields + */ +function channels_list(domain, port, params) { + const url = `http://${domain}:${port}/channels/list` // input sanitzation is for bitches + Request('get', url, params).then( + response => { + const channels = response.body + console.log(channels) + }, + reason => { + } + ) +} + +/** + * Only requests + * @param {Object} server_conf Should contain at least id/secret + domain/port + * + */ +exports.get_channels = function(server_conf) { + // the first two checks are here to rpevent getting a 401 due to a bad/missing jwt + if('jwt' in server_conf) { + if(auth.valid_jwt(server['jwt'])) { + const params = { jwt: server['jwt'], id: server['id'] } + } + // do something else idk + } else { + // complain here + } +}