diff --git a/cli/boost b/cli/boost index 2823d4c2622c799ba6d9ea6281f8b57d249a80d2..f15d990244ed34fa993dd3b8360798f81362d223 100755 --- a/cli/boost +++ b/cli/boost @@ -22,6 +22,7 @@ print_usage(){ echo " list-channels" echo " list-numbers" echo " release-numbers" + echo " trust" echo "" echo "To learn what these commands do, run:" echo "" @@ -34,7 +35,8 @@ if [[ $command != "help" ]] && [[ $command != "create-number" ]] && [[ $command != "list-channels" ]] && [[ $command != "list-numbers" ]] && - [[ $command != "release-numbers" ]] + [[ $command != "release-numbers" ]] && + [[ $command != "trust" ]] then print_usage exit 1 diff --git a/cli/boost-commands/help b/cli/boost-commands/help index da55cafbb794aef3bb3b9c2a4ae6896e7604e404..237f16d2eea96685fc6b7071138c34f1f1e86595 100755 --- a/cli/boost-commands/help +++ b/cli/boost-commands/help @@ -21,6 +21,9 @@ boost cli supports the following commands: release-numbers <path> - releases all phone numbers with twilio ids listed at given path + trust <user phone number> + - trusts all safety numbers associated with a user's phone number + for more detailed instructions on any command, run: boost <command> -h diff --git a/cli/boost-commands/trust b/cli/boost-commands/trust new file mode 100755 index 0000000000000000000000000000000000000000..7227c4372bf2707cdab67b282db959cfb0bb341f --- /dev/null +++ b/cli/boost-commands/trust @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +if [[ $1 == "-h" ]] || [[ $1 == "--help" ]];then + echo "this command trusts all safety numbers associated with a user's phone number. valid options are:" + echo "" + echo "-p : user phone number"; + echo "-u : url to target (in dev, use signalboost.ngrok.io)"; + echo "" + exit 1 +fi + +echo "--- checking environment and args..." + +if [ -z $SIGNALBOOST_API_TOKEN ];then + echo "--- ERROR: no SIGNALBOOST_API_TOKEN found. try \`\$ set -a && source .env && set +a\`" + exit 1 +fi + +while getopts ":p:n:s:u:" opt; do + case "$opt" in + p) + phone_number="$OPTARG" + ;; + u) + url="$OPTARG" + ;; + esac +done + +if [[ ! $phone_number =~ ^\+(1|52)[0-9]{10}$ ]];then + echo "> ERROR: -p must be a 10 digit phone number prefixed by a country code (+1 or +52)" + exit 1 +fi + +if [ -z $url ];then url=${SIGNALBOOST_HOST_URL}; fi + +echo "--- trusting all safety numbers for user phone number ${phone_number} at url ${url}" + +curl -s -X POST \ + -H "Content-Type: application/json" \ + -H "Token: $SIGNALBOOST_API_TOKEN" \ + -d "{ \"memberPhoneNumber\": \"$phone_number\" }" \ + https://${url}/channels | jq