瀏覽代碼

Better handling of users file

Bob Mottram 8 年之前
父節點
當前提交
9f8b5e0030
共有 1 個檔案被更改,包括 10 行新增8 行删除
  1. 10
    8
      src/freedombone-mesh-visit-site

+ 10
- 8
src/freedombone-mesh-visit-site 查看文件

@@ -61,15 +61,17 @@ case $sel in
61 61
                        --msgbox $"The user '$TOX_USERNAME' was not found on the mesh" 8 60
62 62
                 exit 2
63 63
             fi
64
-            TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | awk -F ' ' '{print $2}')
65
-            if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
66
-                dialog --title $"Visit IPFS site" \
67
-                       --backtitle $"Freedombone mesh" \
68
-                       --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60
69
-                exit 3
64
+            TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | sed "s|$TOX_USERNAME ||g" | sed -e 's/^[[:space:]]*//')
65
+            if [ ${#TOX_ID} -gt 5 ]; then
66
+                if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
67
+                    dialog --title $"Visit IPFS site" \
68
+                           --backtitle $"Freedombone mesh" \
69
+                           --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60
70
+                    exit 3
71
+                fi
72
+                IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
73
+                $BROWSER $IPFS_FULL_URL
70 74
             fi
71
-            IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
72
-            $BROWSER $IPFS_FULL_URL
73 75
         else
74 76
             exit 1
75 77
         fi