Skip to content

Commit

Permalink
Merge pull request #135 from gempir/admin
Browse files Browse the repository at this point in the history
fix duplication of userids on config when added via api #134
  • Loading branch information
gempir committed Nov 23, 2021
2 parents fe6fd8c + 345b9ed commit 84acc65
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 21 deletions.
8 changes: 5 additions & 3 deletions api/admin.go
Expand Up @@ -18,16 +18,18 @@ func (s *Server) authenticateAdmin(w http.ResponseWriter, r *http.Request) bool
}

type channelsDeleteRequest struct {
// list of userIds
Channels []string `json:"channels"`
}

type channelConfigsJoinRequest struct {
// list of userIds
Channels []string `json:"channels"`
}

// swagger:route POST /admin/channels admin addChannels
//
// Will add the channels to log
// Will add the channels to log, only works with userIds
//
// Consumes:
// - application/json
Expand All @@ -49,7 +51,7 @@ type channelConfigsJoinRequest struct {

// swagger:route DELETE /admin/channels admin deleteChannels
//
// Will remove the channels to log
// Will remove the channels to log, only works with userIds
//
// Consumes:
// - application/json
Expand Down Expand Up @@ -115,5 +117,5 @@ func (s *Server) writeChannels(w http.ResponseWriter, r *http.Request) {
s.bot.Join(userData.Login)
}

writeJSON(fmt.Sprintf("Doubters? Joined channels %v", request.Channels), http.StatusOK, w, r)
writeJSON(fmt.Sprintf("Doubters? Joined channels or already in: %v", request.Channels), http.StatusOK, w, r)
}
1 change: 0 additions & 1 deletion config/main.go
Expand Up @@ -39,7 +39,6 @@ func NewConfig(filePath string) *Config {

// AddChannels adds channels to the config
func (cfg *Config) AddChannels(channelIDs ...string) {
cfg.Channels = append(cfg.Channels, channelIDs...)
for _, id := range channelIDs {
cfg.Channels = appendIfMissing(cfg.Channels, id)
}
Expand Down
14 changes: 7 additions & 7 deletions web/build/asset-manifest.json
@@ -1,20 +1,20 @@
{
"files": {
"main.js": "/static/js/main.a8e5a8d3.chunk.js",
"main.js.map": "/static/js/main.a8e5a8d3.chunk.js.map",
"main.js": "/static/js/main.b632c989.chunk.js",
"main.js.map": "/static/js/main.b632c989.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.aef01254.js",
"runtime-main.js.map": "/static/js/runtime-main.aef01254.js.map",
"static/css/2.bc4e7c69.chunk.css": "/static/css/2.bc4e7c69.chunk.css",
"static/js/2.994a8234.chunk.js": "/static/js/2.994a8234.chunk.js",
"static/js/2.994a8234.chunk.js.map": "/static/js/2.994a8234.chunk.js.map",
"static/js/2.44294195.chunk.js": "/static/js/2.44294195.chunk.js",
"static/js/2.44294195.chunk.js.map": "/static/js/2.44294195.chunk.js.map",
"index.html": "/index.html",
"static/css/2.bc4e7c69.chunk.css.map": "/static/css/2.bc4e7c69.chunk.css.map",
"static/js/2.994a8234.chunk.js.LICENSE.txt": "/static/js/2.994a8234.chunk.js.LICENSE.txt"
"static/js/2.44294195.chunk.js.LICENSE.txt": "/static/js/2.44294195.chunk.js.LICENSE.txt"
},
"entrypoints": [
"static/js/runtime-main.aef01254.js",
"static/css/2.bc4e7c69.chunk.css",
"static/js/2.994a8234.chunk.js",
"static/js/main.a8e5a8d3.chunk.js"
"static/js/2.44294195.chunk.js",
"static/js/main.b632c989.chunk.js"
]
}
2 changes: 1 addition & 1 deletion web/build/index.html
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#090A0B"/><title>justlog</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><style>:root{--bg:#0e0e10;--bg-bright:#18181b;--bg-brighter:#3d4146;--bg-dark:#121416;--theme:#00CC66;--theme-bright:#00FF80;--theme2:#2980b9;--theme2-bright:#3498db;--text:#F5F5F5;--text-dark:#616161;--danger:#e74c3c}body{margin:0;padding:0;background:var(--bg);font-family:Helvetica,Arial,sans-serif;height:100%;width:100%}*{box-sizing:border-box}</style><link href="/static/css/2.bc4e7c69.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,f=r[0],i=r[1],a=r[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,f=1;f<t.length;f++){var i=t[f];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var f=this.webpackJsonpweb=this.webpackJsonpweb||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var a=0;a<f.length;a++)r(f[a]);var p=i;t()}([])</script><script src="/static/js/2.994a8234.chunk.js"></script><script src="/static/js/main.a8e5a8d3.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#090A0B"/><title>justlog</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><style>:root{--bg:#0e0e10;--bg-bright:#18181b;--bg-brighter:#3d4146;--bg-dark:#121416;--theme:#00CC66;--theme-bright:#00FF80;--theme2:#2980b9;--theme2-bright:#3498db;--text:#F5F5F5;--text-dark:#616161;--danger:#e74c3c}body{margin:0;padding:0;background:var(--bg);font-family:Helvetica,Arial,sans-serif;height:100%;width:100%}*{box-sizing:border-box}</style><link href="/static/css/2.bc4e7c69.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,f=r[0],i=r[1],a=r[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,a||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,f=1;f<t.length;f++){var i=t[f];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/";var f=this.webpackJsonpweb=this.webpackJsonpweb||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var a=0;a<f.length;a++)r(f[a]);var p=i;t()}([])</script><script src="/static/js/2.44294195.chunk.js"></script><script src="/static/js/main.b632c989.chunk.js"></script></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web/build/static/js/main.a8e5a8d3.chunk.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/build/static/js/main.b632c989.chunk.js.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions web/build/swagger.json
Expand Up @@ -24,7 +24,7 @@
"api_key": []
}
],
"description": "Will add the channels to log",
"description": "Will add the channels to log, only works with userIds",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -69,7 +69,7 @@
"api_key": []
}
],
"description": "Will remove the channels to log",
"description": "Will remove the channels to log, only works with userIds",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -1187,6 +1187,7 @@
"type": "object",
"properties": {
"channels": {
"description": "list of userIds",
"type": "array",
"items": {
"type": "string"
Expand All @@ -1200,6 +1201,7 @@
"type": "object",
"properties": {
"channels": {
"description": "list of userIds",
"type": "array",
"items": {
"type": "string"
Expand Down
6 changes: 4 additions & 2 deletions web/public/swagger.json
Expand Up @@ -24,7 +24,7 @@
"api_key": []
}
],
"description": "Will add the channels to log",
"description": "Will add the channels to log, only works with userIds",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -69,7 +69,7 @@
"api_key": []
}
],
"description": "Will remove the channels to log",
"description": "Will remove the channels to log, only works with userIds",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -1187,6 +1187,7 @@
"type": "object",
"properties": {
"channels": {
"description": "list of userIds",
"type": "array",
"items": {
"type": "string"
Expand All @@ -1200,6 +1201,7 @@
"type": "object",
"properties": {
"channels": {
"description": "list of userIds",
"type": "array",
"items": {
"type": "string"
Expand Down

0 comments on commit 84acc65

Please sign in to comment.