From 356baaa67dc29916dab3f7f38baf21d079f93802 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 6 Sep 2016 14:01:49 +0100 Subject: [PATCH] Username or tox ID --- src/freedombone-mesh-visit-site | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/freedombone-mesh-visit-site b/src/freedombone-mesh-visit-site index 4c5e7b23..a3769acf 100755 --- a/src/freedombone-mesh-visit-site +++ b/src/freedombone-mesh-visit-site @@ -49,24 +49,23 @@ data=$(tempfile 2>/dev/null) trap "rm -f $data" 0 1 2 5 15 dialog --title $"Visit IPFS site" \ --backtitle $"Freedombone mesh" \ - --inputbox $"Enter the username for the site you wish to visit" 8 60 2>$data + --inputbox $"Enter the username or Tox ID for the site you wish to visit" 8 70 2>$data sel=$? case $sel in 0) - TOX_USERNAME=$(<$data) - if [ ${#TOX_USERNAME} -gt 0 ]; then - if ! grep -q "$TOX_USERNAME" $USERS_FILE; then - dialog --title $"Visit IPFS site" \ - --backtitle $"Freedombone mesh" \ - --msgbox $"The user '$TOX_USERNAME' was not found on the mesh" 8 60 - exit 2 + TOX_USERNAME_OR_ID=$(<$data) + if [ ${#TOX_USERNAME_OR_ID} -gt 0 ]; then + if ! grep -q "$TOX_USERNAME_OR_ID" $USERS_FILE; then + TOX_ID="$TOX_USERNAME_OR_ID" + else + TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME_OR_ID" | head -n 1 | sed "s|$TOX_USERNAME_OR_ID ||g" | sed -e 's/^[[:space:]]*//') fi - TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | sed "s|$TOX_USERNAME ||g" | sed -e 's/^[[:space:]]*//') + if [ ${#TOX_ID} -gt 5 ]; then if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then dialog --title $"Visit IPFS site" \ --backtitle $"Freedombone mesh" \ - --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60 + --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME_OR_ID'" 8 60 exit 3 fi IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')