From 18f9b76326877aee66bf7494d105d6145c91152d Mon Sep 17 00:00:00 2001 From: Elliu <elliu@hashi.re> Date: Mon, 10 Apr 2023 19:11:08 +0200 Subject: [PATCH] stpkg: ask for homeserver token only if we need to upload things --- stpkg | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stpkg b/stpkg index 0bd4aee..7a8f230 100755 --- a/stpkg +++ b/stpkg @@ -226,6 +226,13 @@ __upload_file() { local TYPE=$1 # The type of file (png/gif) local FILE=$2 # The file local NAME=$3 # The pretty name for the sticker + + if [ "x$STPKG_TOKEN" = "x" ]; then + read -sp "`__yellow 'Enter your access token:'`" STPKG_TOKEN + echo '' + fi + validate_token # Validate token, will exit if invalid + # TODO: Use jq here curl -s -X POST -H \ "Content-Type: $TYPE" --data-binary "@$FILE" "https://$STPKG_HOMESERV/_matrix/media/r0/upload?access_token=$STPKG_TOKEN" | \ @@ -936,11 +943,6 @@ __do_command() { STPKG_TOKEN="$2" shift 2 fi - if [ "x$STPKG_TOKEN" = "x" ]; then - read -sp "`__yellow 'Enter your access token:'`" STPKG_TOKEN - echo '' - fi - validate_token # Validate token, will exit if invalid local PARSE_FLAGS=1 -- GitLab