-- Leo's gemini proxy

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

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: actpub
action: commit
revision:
path_from:
revision_from: 05d3d215714b629b0a9eb4920d18dec85683a2e6:
path_to:
revision_to:

git.thebackupbox.net

actpub

git://git.thebackupbox.net/actpub

commit 05d3d215714b629b0a9eb4920d18dec85683a2e6
Author: epoch <epoch@thebackupbox.net>
Date:   Wed Sep 20 09:45:27 2023 +0000

    lol. fuck this merge. just copy it with xclip

diff --git a/ap-create-note b/ap-create-note
old mode 100755
new mode 100644
index bea2df9a96ba5419aa024a1843535a7927f9fd79..4e6a885dc58f26ca4369b41ee17dc739ab321a33
--- a/ap-create-note
+++ b/ap-create-note
@@ -39,6 +39,7 @@ fi

 type="Create"
 tagged_users="$(grep '^@' <<< "$1")" #close enough. just don't do dumb shit.
+hashtags="$(grep '^#' <<< "$1")"
 content="$(ap-content2html "text/plain" "$1")"
 content_json_escaped="$(printf "%s" "$content" | jq -Rs '.')"

@@ -59,18 +60,27 @@ if [ "$summary" ];then
   summary=',"summary":'"$summary_json_escaped"',"sensitive":true'
 fi

-if [ "${tagged_users}" ];then
-  tagged_actors="$(xargs -n1 ap-getactoruri <<< "${tagged_users}")"
-  tag_json="$(for tagged_user in ${tagged_users};do
+tagged_actors="$(if [ "${tagged_users}" ];then xargs -n1 ap-getactoruri <<< "${tagged_users}";fi)"
+tag_user_json="$(if [ "${tagged_users}" ];then
+  for tagged_user in ${tagged_users};do
     printf '{'
     printf '"type":"Mention",'
     printf '"href":%s,' "$(ap-getactoruri "${tagged_user}" | jq -R .)" ##TODO! JSON ESCAPE THIS!
     printf '"name":%s' "$(jq -R . <<< "${tagged_user}")"
     printf '}\n'
-  done | sort | uniq | jq -s .)"
-else
-  tag_json="[]"
-fi
+  done
+fi)"
+tag_hash_json="$(if [ "${hashtags}" ];then
+  for hashtag in ${hashtags};do
+    printf '{'
+    printf '"type":"Hashtag",'
+    printf '"href":"%s",' "${hashtag}"
+    printf '"name":"%s"' "${hashtag}"
+    printf '}\n'
+  done
+fi)"
+### it'll turn into [] if the strings are empty anyway.
+tag_json="$(printf '%s%s' "$tag_user_json" "${tag_hash_json}" | sort | uniq | jq -s .)"

 if [ "$in_reply_to" ];then
   reply=',"inReplyTo":"'"${in_reply_to}"'"'
@@ -80,9 +90,14 @@ if [ "$in_reply_to" ];then
   irt_actor_object="$(ap-cacheactor "${irt_actor}")"
   irt_followers="$(jq -r '.followers' < "${irt_actor_object}")"
   irt_cc="$(jq -r '.cc[]//""' < "${irt_object}")"
+  irt_to="$(jq -r '.to[]//""' < "${irt_object}")"
 fi

-cc_json="$(printf "%s\n%s\n%s\n%s\n%s\n" "$irt_actor" "$irt_followers" "$irt_cc" "$cc" "$tagged_actors" | grep -v '^$' | sort | uniq | jq -R . | jq -s .)"
+to_list="$(printf "%s\n%s\n" "$to" "$irt_to" | grep -v '^$' | grep -v '^null$' | sort | uniq)"
+cc_list="$(printf "%s\n%s\n%s\n%s\n%s\n" "$irt_actor" "$irt_followers" "$irt_cc" "$cc" "$tagged_actors" | grep -v '^$' | grep -v '^null$' | sort | uniq)"
+
+to_json="$(printf '%s\n' "${to_list}" | jq -R . | jq -s .)"
+cc_json="$(printf "%s\n" "${cc_list}" | jq -R . | jq -s .)"

 ### reply and summary added into the object is kind of hacky. :/

@@ -93,9 +108,7 @@ object='{
   "content":		 '"${content_json_escaped}"',
   "tag":                 '"$tag_json"',
   "published":		"'"${ap_date}"'",
-  "to": [
-    "'"${to}"'"
-  ],
+  "to": '"$to_json"',
   "cc": '"$cc_json"'
   '"$reply""$summary"'
 }'
@@ -107,26 +120,33 @@ export POST_DATA='{
   "actor":	"'"${actor}"'",
   "published":	"'"${ap_date}"'",
   "object":	 '"${object}"',
-  "to": [
-    "'"${to}"'"
-  ],
+  "to": '"$to_json"',
   "cc": '"$cc_json"'
 }'

 printf "%s\n" "$POST_DATA" | jq . || exit "$(printf "BAD POST_DATA:\n\n%s\n\n" "$POST_DATA" >&2 ; echo 1)"

+followers_list="$(ap-getfollowers "${acct}")"
+#to_list
+#cc_list set at top of script.
+target_list="$(printf "%s\n%s\n%s\n" "$followers_list" "$to_list" "$cc_list")"
+echo "going to send this to the inboxes all of these targets: ${target_list}"
+
+target_inboxes="$(printf "%s\n" "$target_list" | xargs -n1 ap-getendpoint | sort | uniq)"
+
+echo "the inboxes for all of them: ${target_inboxes}"
+
 printf "/!\\ DOES THIS ALL LOOK GOOD? /!\\\n"
 read confirm
 [ "$confirm" == "yes" ] || exit "$(printf "KK. NOT POSTING\n" >&2 ; echo 1)"

 ### create the outbox entry.
-mkdir -p ~/.cache/ap/outbox
 cache_file=~/.cache/ap/outbox/"${uuid}"
 printf "%s" "$POST_DATA" > "${cache_file}"
 printf "ap-create-note: local cache file of create activity: %s\n" "${cache_file}" >&2
 ap-upload-to-outbox "${cache_file}"

-for target_inbox in $(ap-getfollowers "${acct}" | xargs -n1 ap-getendpoint | sort | uniq);do
+for target_inbox in $(printf "%s\n" "$target_list" | xargs -n1 ap-getendpoint | sort | uniq);do
 	ap-signed-post "${target_inbox}"
 done
 echo 'ap-create-note: [DONE]' >&2

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

-- Response ended

-- Page fetched on Sun Jun 2 15:24:46 2024