Username or tox ID

This commit is contained in:
Bob Mottram 2016-09-06 14:01:49 +01:00
parent de72aab857
commit 356baaa67d
1 changed files with 9 additions and 10 deletions

View File

@ -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}')