diff --git a/mattermost/build.sh b/mattermost/build.sh index efef62b..916f510 100755 --- a/mattermost/build.sh +++ b/mattermost/build.sh @@ -1,8 +1,10 @@ #! /usr/bin/env bash +set -euo pipefail + cd "$( dirname "${BASH_SOURCE[0]}" )" echo "Building Server Plugin" -server/build-server.sh $1 +server/build-server.sh ${1:-} echo "Building Client Plugin" ( cd webapp && npx webpack --mode=production; ) diff --git a/mattermost/build.sh b/mattermost/build.sh index efef62b..916f510 100755 --- a/mattermost/build.sh +++ b/mattermost/build.sh @@ -1,8 +1,10 @@ #! /usr/bin/env bash +set -euo pipefail + cd "$( dirname "${BASH_SOURCE[0]}" )" echo "Building Server Plugin" -server/build-server.sh $1 +server/build-server.sh ${1:-} echo "Building Client Plugin" ( cd webapp && npx webpack --mode=production; ) diff --git a/mattermost/plugin.json b/mattermost/plugin.json index de87152..7082ecc 100644 --- a/mattermost/plugin.json +++ b/mattermost/plugin.json @@ -18,7 +18,8 @@ {"key":"UnknownIcons", "display_name":"Unknown icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors without their status set yet, 1 per door (or specify 1 for all)"}, {"key":"OpenIcons", "display_name":"Open icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are open, 1 per door (or specify 1 for all)"}, {"key":"ClosedIcons", "display_name":"Closed icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are closed, 1 per door (or specify 1 for all)"}, - {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"} + {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"}, + {"key":"DoorPasswords", "display_name":"Door passwords", "type":"text", "default":"", "help_text":"|-separated list of passwords used to access status update calls (pubkey alternative)"} ] } } diff --git a/mattermost/build.sh b/mattermost/build.sh index efef62b..916f510 100755 --- a/mattermost/build.sh +++ b/mattermost/build.sh @@ -1,8 +1,10 @@ #! /usr/bin/env bash +set -euo pipefail + cd "$( dirname "${BASH_SOURCE[0]}" )" echo "Building Server Plugin" -server/build-server.sh $1 +server/build-server.sh ${1:-} echo "Building Client Plugin" ( cd webapp && npx webpack --mode=production; ) diff --git a/mattermost/plugin.json b/mattermost/plugin.json index de87152..7082ecc 100644 --- a/mattermost/plugin.json +++ b/mattermost/plugin.json @@ -18,7 +18,8 @@ {"key":"UnknownIcons", "display_name":"Unknown icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors without their status set yet, 1 per door (or specify 1 for all)"}, {"key":"OpenIcons", "display_name":"Open icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are open, 1 per door (or specify 1 for all)"}, {"key":"ClosedIcons", "display_name":"Closed icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are closed, 1 per door (or specify 1 for all)"}, - {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"} + {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"}, + {"key":"DoorPasswords", "display_name":"Door passwords", "type":"text", "default":"", "help_text":"|-separated list of passwords used to access status update calls (pubkey alternative)"} ] } } diff --git a/mattermost/plugin_template.json b/mattermost/plugin_template.json index ed49928..4318f1a 100644 --- a/mattermost/plugin_template.json +++ b/mattermost/plugin_template.json @@ -18,7 +18,8 @@ {"key":"UnknownIcons", "display_name":"Unknown icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors without their status set yet, 1 per door (or specify 1 for all)"}, {"key":"OpenIcons", "display_name":"Open icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are open, 1 per door (or specify 1 for all)"}, {"key":"ClosedIcons", "display_name":"Closed icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are closed, 1 per door (or specify 1 for all)"}, - {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"} + {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"}, + {"key":"DoorPasswords", "display_name":"Door passwords", "type":"text", "default":"", "help_text":"|-separated list of passwords used to access status update calls (pubkey alternative)"} ] } } diff --git a/mattermost/build.sh b/mattermost/build.sh index efef62b..916f510 100755 --- a/mattermost/build.sh +++ b/mattermost/build.sh @@ -1,8 +1,10 @@ #! /usr/bin/env bash +set -euo pipefail + cd "$( dirname "${BASH_SOURCE[0]}" )" echo "Building Server Plugin" -server/build-server.sh $1 +server/build-server.sh ${1:-} echo "Building Client Plugin" ( cd webapp && npx webpack --mode=production; ) diff --git a/mattermost/plugin.json b/mattermost/plugin.json index de87152..7082ecc 100644 --- a/mattermost/plugin.json +++ b/mattermost/plugin.json @@ -18,7 +18,8 @@ {"key":"UnknownIcons", "display_name":"Unknown icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors without their status set yet, 1 per door (or specify 1 for all)"}, {"key":"OpenIcons", "display_name":"Open icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are open, 1 per door (or specify 1 for all)"}, {"key":"ClosedIcons", "display_name":"Closed icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are closed, 1 per door (or specify 1 for all)"}, - {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"} + {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"}, + {"key":"DoorPasswords", "display_name":"Door passwords", "type":"text", "default":"", "help_text":"|-separated list of passwords used to access status update calls (pubkey alternative)"} ] } } diff --git a/mattermost/plugin_template.json b/mattermost/plugin_template.json index ed49928..4318f1a 100644 --- a/mattermost/plugin_template.json +++ b/mattermost/plugin_template.json @@ -18,7 +18,8 @@ {"key":"UnknownIcons", "display_name":"Unknown icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors without their status set yet, 1 per door (or specify 1 for all)"}, {"key":"OpenIcons", "display_name":"Open icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are open, 1 per door (or specify 1 for all)"}, {"key":"ClosedIcons", "display_name":"Closed icon url", "type":"text", "default":"", "help_text":"(Relative) URL of the icon to display for doors that are closed, 1 per door (or specify 1 for all)"}, - {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"} + {"key":"DoorOrder", "display_name":"Door order", "type":"text", "default":"", "help_text":"Order of the door IDs for display in the widget (comma separated)"}, + {"key":"DoorPasswords", "display_name":"Door passwords", "type":"text", "default":"", "help_text":"|-separated list of passwords used to access status update calls (pubkey alternative)"} ] } } diff --git a/mattermost/server/main/bathroom.go b/mattermost/server/main/bathroom.go index 2a6f545..32fa04b 100644 --- a/mattermost/server/main/bathroom.go +++ b/mattermost/server/main/bathroom.go @@ -110,6 +110,9 @@ DoorOrder string doorOrder []uint8 + DoorPasswords string + doorPasswords []string + settingsJson map[string]interface{} } @@ -392,7 +395,18 @@ p.doorLock.Lock() defer p.doorLock.Unlock() + requireVerification := true + if r.URL.Path == "/admin-status-update" { + requireVerification = false + } + + password, ok := r.Form["password"] + if ok && len(password) > 0 && int(doorId8) <= len(p.config.doorPasswords) && password[0] == p.config.doorPasswords[doorId8-1] { + requireVerification = false + } + + if !requireVerification { err = p.setDoorStatus(doorId8, statusVal, true) fmt.Fprintf(w, "Door %d set to status %d", doorId8, statusVal) return @@ -588,6 +602,15 @@ } } + newConfig.doorPasswords = make([]string, 0, 4) + split = strings.Split(newConfig.DoorPasswords, "|") + for _, un := range split { + trimmed := strings.Trim(un, ", \t\n") + if trimmed != "" { + newConfig.doorPasswords = append(newConfig.doorPasswords, trimmed) + } + } + newConfig.unknownIcons = make([]string, 0, 4) split = strings.Split(newConfig.UnknownIcons, ",") for _, un := range split {