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 + } +}