From e801ec0eeb893bb7b4c88ca8374ffdeb5a004884 Mon Sep 17 00:00:00 2001
From: Elliu <elliu@hashi.re>
Date: Sat, 30 Sep 2023 17:29:16 +0200
Subject: [PATCH] Ask for the matrix token earlier if it's not in conf

---
 stpkg | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/stpkg b/stpkg
index b8c1278..ae9b975 100755
--- a/stpkg
+++ b/stpkg
@@ -226,11 +226,6 @@ __upload_file() {
     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
-        validate_token # Validate token, will exit if invalid
-    fi
-
     MXC=$(curl -s -X POST -H \
         "Content-Type: $TYPE" --data-binary "@$FILE" "https://$STPKG_HOMESERV/_matrix/media/r0/upload?access_token=$STPKG_TOKEN" | \
         tee /tmp/toto | jq -r ".content_uri")
@@ -602,6 +597,11 @@ process_sticker_file() {
     FILE="$1"
     local -n JSON_REF="$2"
 
+    if [ "x$STPKG_TOKEN" = "x" ]; then
+        read -sp "`__yellow 'Enter your access token:'`" STPKG_TOKEN
+        validate_token # Validate token, will exit if invalid
+    fi
+
     # Get the names and extensions
     local INIT_TYPE=$(file_get_type "$FILE")
     local INIT_EXT=$(file_get_ext_from_type "$INIT_TYPE")
-- 
GitLab