-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: fmrl-client
action: commit
revision:
path_from:
revision_from: 69552e4291846e6283bd26c3efd586fff12b10c8:
path_to:
revision_to:

git.thebackupbox.net

fmrl-client

git://git.thebackupbox.net/fmrl-client

commit 69552e4291846e6283bd26c3efd586fff12b10c8
Author: epoch <epoch@enzo.thebackupbox.net>
Date:   Tue Feb 15 02:33:44 2022 +0000

    lots of things. I don't want to look at the changes and describe them atm.

diff --git a/fmrl-contacts-to-URIs b/fmrl-contacts-to-URIs

index 92064e776f71361d07caf9e6a726d4d6c540a996..

index ..7d01aa1a50e73b5faa07da86dce82696e687af3c 100755

--- a/fmrl-contacts-to-URIs
+++ b/fmrl-contacts-to-URIs
@@ -1,2 +1,2 @@
 #!/usr/bin/env bash
-sort | tr '@' ' ' | awk '{print $2, $1}' | clump | sed 's|:|/fmrl/users?|;s| |\&user=|g;s|?&|?|;s|^|https://|'
+sort | tr '@' ' ' | awk '{print $2, $1}' | clump | sed 's|:|/.well-known/fmrl/users?|;s| |\&user=|g;s|?&|?|;s|^|https://|'
diff --git a/fmrl-get-contact-list b/fmrl-get-contact-list

index d57b9d70b78ddfb580ff8c0d0cba5d07f25f3aff..

index ..172c0b88ef8bea82aa8518dc5502a3de6221766d 100755

--- a/fmrl-get-contact-list
+++ b/fmrl-get-contact-list
@@ -1,7 +1,10 @@
 #!/usr/bin/env bash
 mkdir -p ~/.cache/fmrl/
 me="$(cat ~/.config/fmrl-client/me)"
-fmrl-contacts-to-URIs | while read uri;do
+fmrl-contacts-to-URIs | while read -r uri;do
   host="$(printf "%s\n" "$uri" | uricut -d)"
-  curl -H "Referer: ${me}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "~/.cache/fmrl/@${host}")")" -g "$uri" -o "~/.cache/fmrl/@${host}"
+  printf "uri: %s\n" "$uri" >&2
+  uricut <<< "$uri"
+  printf "host: %s\n" "$host" >&2
+  curl -H "Referer: ${me}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "~/.cache/fmrl/@${host}")")" -g "$uri" -o ~/.cache/fmrl/@"${host}"
 done
diff --git a/fmrl-get-status b/fmrl-get-status

index cdcd24353d2b3938556ea28cf657000d5d75a2a3..

index ..1896cc8d72d6adeef641367b66d0460cb4ef6919 100755

--- a/fmrl-get-status
+++ b/fmrl-get-status
@@ -19,42 +19,16 @@ cache_file=~/.cache/fmrl/"${user}"@"${host}"
 scheme=https

 url="${scheme}://${host}/.well-known/fmrl/users?user=${user}"
-code="$(curl -w '%{http_code}' -s -A "$ua" -H "Referer: ${ref}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -g "$url" -o "/tmp/${user}@${host}")"
+#code="$(curl -w '%{http_code}' -s -A "$ua" -H "Referer: ${ref}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -g "$url" -o "/tmp/${user}@${host}")"
+code="$(curl -w '%{http_code}' -s -A "$ua" -H "Referer: ${ref}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -g "$url" -o "${cache_file}")"
 echo code: $code url: $url >&2
 if [ "$code" != "200" ];then
   scheme=http
   rm -f "/tmp/${user}@${host}"
   url="${scheme}://${host}/.well-known/fmrl/users?user=${user}"
-  code="$(curl -w '%{http_code}' -s -A "$ua" -H "Referer: ${ref}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -g "$url" -o "/tmp/${user}@${host}")"
+  #code="$(curl -w '%{http_code}' -s -A "$ua" -H "Referer: ${ref}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -g "$url" -o "/tmp/${user}@${host}")"
+  code="$(curl -w '%{http_code}' -s -A "$ua" -H "Referer: ${ref}" -H "If-Modified-Since: $(rfc7231date "$(stat -c '%Y' "${cache_file}")")" -g "$url" -o "${cache_file}")"
   echo code: $code url: $url >&2
 fi

-u_code="$(jq -r '.[0].code' < "/tmp/${user}@${host}")"
-
-if [ "$u_code" == 200 ];then ## we only need to update our version if we got a real response.
-  jq -r '.[0].data' < /tmp/${user}@${host} > "${cache_file}"
-fi
-
-if [ ! -e "${cache_file}" ];then
-  printf "[!!!] something went wrong. there is no file to use.\r\n"
-  exit 1
-fi
-
-u_avatar_url="${scheme}://${host}$(jq -r .avatar.original < "${cache_file}")"
-u_status="$(jq -r .status < "${cache_file}")"
-u_name="$(jq -r .name < "${cache_file}")"
-u_emoji="$(jq -r .emoji < "${cache_file}")"
-u_media="$(jq -r .media < "${cache_file}")"
-u_media_type="$(jq -r .media_type < "${cache_file}" | tr -cd '0-9')"
-
-avatar_cache=~/.cache/fmrl/"${user}"@"${host}".png
-
-if [ ! -e "${avatar_cache}" -o "$no_cache" ];then
-  echo "downloading avatar..." >&2
-  curl -s -A "$ua" -H "Referer: ${ref}" -g "$u_avatar_url" > "${avatar_cache}"
-else
-  echo "using cached avatar..." >&2
-fi
-
-media_verb="reading,watching,watching,listening to,listening to,playing"
-u_media_verb="$(printf "%s\n" "$media_verb" | cut -d, -f$u_media_type)"
+cat /tmp/${user}@${host}
diff --git a/fmrl-make-json b/fmrl-make-json

index c753fa7d9f332d6dd6a1d96d95109f7a2c5f03e8..

index ..33cec3c3a9c9f06dffa4372265b89f41670c098c 100755

--- a/fmrl-make-json
+++ b/fmrl-make-json
@@ -25,9 +25,13 @@ while [ "$1" ];do
   shift
   media_type="$(printf "%s\n" "$1" | tr -cd '0-9')"
 ;;
+-u|--uri)
+  shift
+  uri="$(printf "%s\n" "$1" | sed 's|"|\\"|g')"
+;;
 *)
   printf "unknown option: %s\n" "$1"
-  printf "usage: -n|--name|-s|--status|-e|--emoji|-m|--media|-t|--media-type value-for-each\n"
+  printf "usage: -n|--name|-s|--status|-e|--emoji|-m|--media|-t|--media-type|-u|--uri value-for-each\n"
 printf "media types:\n"
 cat <<EOF
 1 Text (book, article, etc)
@@ -46,11 +50,12 @@ if [ ! "${media_type}" ];then media_type=0;fi
 json="{}"


-if [ "${name}" ];then       json="$(printf "%s\n" "${json}" | jq '. += {"name"      :"'"${name}"'"}')";fi
-if [ "${status}" ];then     json="$(printf "%s\n" "${json}" | jq '. += {"status"    :"'"${status}"'"}')";fi
-if [ "${emoji}" ];then      json="$(printf "%s\n" "${json}" | jq '. += {"emoji"     :"'"${emoji}"'"}')";fi
-if [ "${media}" ];then      json="$(printf "%s\n" "${json}" | jq '. += {"media"     :"'"${media}"'"}')";fi
-if [ "${media_type}" != "0" ];then json="$(printf "%s\n" "${json}" | jq '. += {"media_type":'"${media_type}"'}')";fi
+if [ "${name}" ];then       		json="$(printf "%s\n" "${json}" | jq '. += {"name"      :"'"${name}"'"}')";fi
+if [ "${status}" ];then     		json="$(printf "%s\n" "${json}" | jq '. += {"status"    :"'"${status}"'"}')";fi
+if [ "${emoji}" ];then      		json="$(printf "%s\n" "${json}" | jq '. += {"emoji"     :"'"${emoji}"'"}')";fi
+if [ "${media}" ];then      		json="$(printf "%s\n" "${json}" | jq '. += {"media"     :"'"${media}"'"}')";fi
+if [ "${media_type}" != "0" ];then	json="$(printf "%s\n" "${json}" | jq '. += {"media_type":'"${media_type}"'}')";fi
+if [ "${uri}" ];then      		json="$(printf "%s\n" "${json}" | jq '. += {"uri"       :"'"${uri}"'"}')";fi

 tmpfile="$(mktemp -t fmrl.XXXX)"

diff --git a/fmrl-parse-status b/fmrl-parse-status
new file mode 100755
index 0000000000000000000000000000000000000000..259ecf21fa1c9a3cea08201fde20fe282f345a2c
--- /dev/null
+++ b/fmrl-parse-status
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
+user="$(printf "$1\n" | cut -d: -f2 | sed 's/^@*//g' | cut -d@ -f1 )"
+host="$(printf "$1\n" | cut -d: -f2 | sed 's/^@*//g' | cut -d@ -f2 )"
+
+echo $user
+echo $host
+
+host_cache_file=~/.cache/fmrl/@"${host}"
+
+if [ ! -e "${host_cache_file}" ];then
+  printf "host cache file is missing. need to grab that first.\n" 2>&1
+  exit 1
+fi
+
+u_code="$(jq -r '.[] | select(.username == "epoch").code' < "${host_cache_file}")"
+
+user_cache_file=~/.cache/fmrl/"${user}"@"${host}"
+if [ "$u_code" == 200 ];then ## we only need to update our version if we got a real response.
+  jq -r '.[] | select(.username == "'"${user}"'").data' < "${host_cache_file}" > "${user_cache_file}"
+fi
+
+if [ ! -e "${user_cache_file}" ];then
+  printf "[!!!] something went wrong. missing: %s\r\n" "${user_cache_file}"
+  exit 1
+fi
+
+
+u_avatar_url="${scheme}://${host}$(jq -r .avatar.original < "${user_cache_file}")"
+u_status="$(jq -r .status < "${user_cache_file}")"
+u_name="$(jq -r .name < "${user_cache_file}")"
+u_emoji="$(jq -r .emoji < "${user_cache_file}")"
+u_media="$(jq -r .media < "${user_cache_file}")"
+u_media_type="$(jq -r .media_type < "${user_cache_file}" | tr -cd '0-9')"
+u_uri="$(jq -r .uri < "${user_cache_file}")"
+
+avatar_cache=~/.cache/fmrl/"${user}"@"${host}".png
+
+if [ ! -e "${avatar_cache}" -o "$no_cache" ];then
+  echo "downloading avatar..." >&2
+  curl -s -A "$ua" -H "Referer: ${ref}" -g "$u_avatar_url" > "${avatar_cache}"
+else
+  echo "using cached avatar..." >&2
+fi
+
+media_verb="reading,watching,watching,listening to,listening to,playing"
+u_media_verb="$(printf "%s\n" "$media_verb" | cut -d, -f$u_media_type)"
diff --git a/fmrl-status-gdbus-notify b/fmrl-status-gdbus-notify
new file mode 100755
index 0000000000000000000000000000000000000000..611ee869e93c3252a81f55a7b95ba0b4d65183d0
--- /dev/null
+++ b/fmrl-status-gdbus-notify
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+if [ "$1" = "--force" -o "$1" = "-f" ];then
+  force=1
+  shift
+fi
+
+while [ "$1" ];do
+#  . "$(which fmrl-get-status)"
+  . fmrl-parse-status
+  if [ "$u_code" != 200 -a ! "$force" ];then
+    echo "code: $code user: $1" >&2
+    shift
+    continue
+  fi
+
+  # not used atm: actions='["label", "command"]'
+  actions='[]'
+
+  gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify -- \
+  "fmrl-client" \
+  "0" \
+  "${avatar_cache}" \
+  "fmrl status for: \"$u_name\" <@${user}@${host}>" \
+  "${u_emoji} ${u_status}"$'\n'"${u_media_verb} ${u_media}"$'\n'"${u_uri}" \
+  "${actions}" \
+  "[]" \
+  "int32 0"
+
+  shift
+done
diff --git a/fmrl-status-sixel b/fmrl-status-sixel

index 95a99774d3b906c497f83e5bfdd93eef7e99f877..

index ..3c987c9d0f11e9fe6add999a483f52a6f775e3a7 100755

--- a/fmrl-status-sixel
+++ b/fmrl-status-sixel
@@ -7,6 +7,7 @@ fi

 while [ "$1" ];do
   . fmrl-get-status
+  . fmrl-parse-status
   if [ "$u_code" != "200" -a ! "$force" ];then
     echo "code: $code user: $1" >&2
     shift
diff --git a/fmrl-status-yaml b/fmrl-status-yaml
new file mode 100755
index 0000000000000000000000000000000000000000..d48f348122acc0bca85df712802f8190e93d968b
--- /dev/null
+++ b/fmrl-status-yaml
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+if [ "$1" = "-f" ];then
+  force=1
+  shift
+fi
+
+while [ "$1" ];do
+  . fmrl-get-status
+  if [ "$u_code" != "200" -a ! "$force" ];then
+    echo "code: $code user: $1" >&2
+    shift
+    continue
+  fi
+  printf "name: %s\n" "$u_name"
+  printf "emoji: %s\n" "$u_emoji"
+  printf "status: %s\n" "$u_status"
+  printf "media_type: %s\n" "$u_media_type"
+  printf "media: %s\n" "$u_media"
+  shift
+done
diff --git a/fmrl-update-with-patch-httpba b/fmrl-update-with-patch-httpba
new file mode 100755
index 0000000000000000000000000000000000000000..8b12e8b56a611550e74e145cb5e34c4b8f50cb15
--- /dev/null
+++ b/fmrl-update-with-patch-httpba
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+
+if [ "$1" == "--dry-run" ];then
+  dry=1
+  shift
+fi
+
+me="$(cat ~/.config/fmrl-client/me)"
+
+if grep "@" <<< "$1" 2>&1 >/dev/null;then
+  me="$1"
+  shift
+fi
+
+user="$(printf "%s\n" "$me" | grep '@' | sed 's/^@//' | cut -d@ -f1)"
+host="$(printf "%s\n" "$me" | grep '@' | sed 's/^@//' | cut -d@ -f2)"
+
+if [ ! "$user" -o ! "$host" ];then
+  printf "not sure where to send the update to\n" >&2
+  exit 1
+fi
+
+file="$(fmrl-make-json "$@")"
+
+echo "going to PATCH this:"
+cat "$file"
+
+ba_user=${user} ### HAS to be the same, so sayeth the spec.
+uri="https://${ba_user}@{host}/.well-known/fmrl/user/${user}"
+#ba_pass="$(secret-get "${uri}")"
+ba_pass="password"
+uri="$(cat <(printf "%s\n" "$uri" | uricut) \
+           <(printf "password: %s\n" "${ba_pass}" ) \
+        | urijoin)"
+echo "$uri"
+exit 1
+
+if [ "$dry" ];then
+  echo "would have done this:"
+  echo curl \
+    -A "https://git.thebackupbox.net/fmrl-client/blob/refs/heads/trunk:/fmrl-update-with-patch" \
+    -H \""X-Face: $(cat ~/.config/xface)"\" \
+    -X PATCH \
+    -g "https://${ba_user}:[censored]@${host}/.well-known/fmrl/user/${user}" \
+    -T"${file}"
+else
+  curl \
+    -A "https://git.thebackupbox.net/fmrl-client/blob/refs/heads/trunk:/fmrl-update-with-patch" \
+    -H "X-Face: $(cat ~/.config/xface)" \
+    -X PATCH \
+    -g "https://${ba_user}:${ba_pass}@${host}/.well-known/fmrl/user/${user}" \
+    -T"${file}"
+fi
+rm "${file}"

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 16:31:58 2024