repo: actpub action: blob revision: path_from: ap-create-handler revision_from: refs/heads/master: path_to: revision_to:
blob of:
/ ap-create-handler
refs/heads/master:/ap-create-handler
#!/usr/bin/env bash
uri="$1"
export QUERY_STRING="$(uricut -q <<< "$uri")"
inReplyTo="$(uriunescape "$(query_param object)")"
### inReplyTo is the URI of the post this is replying to, so this script
### should scrape the content of it, grab all the tagged users, and include those users
### in the body of the post.
### converting them to tags is ap-create-note's job.
### ap-create-note should probably take markdown as the input?
### that way it is easier to scrape tagged users from it.
summary="$(echo | choose "new activitypub note's summary:")"
if [ "$inReplyTo" ];then
printf "grabbing object: %s\n" "${inReplyTo}" >&2
irt_objectfile="$(ap-cacheobject "${inReplyTo}")"
irt_actor="$(jq -r '.attributedTo' "${irt_objectfile}")"
irt_acct="$(uricut -p <<< "$(ap-actor2acct "${irt_actor}")")"
actor_instance="$(cut -d@ -f2 <<< "${irt_acct}")"
everyone_else="$(jq -r '.tag[] | select( .type == "Mention") | .name' "${irt_objectfile}" | sed 's|^\(@[^@][^@]*\)$|\1@'"${actor_instance}"'|g')"
#echo here >&2
if [ "$summary" ];then
ap-create-note -s "$summary" -r "${inReplyTo}" "$(printf '@%s\n%s\n\n' "${irt_acct}" "${everyone_else}" | vipe)"
else
ap-create-note -r "${inReplyTo}" "$(printf '@%s\n%s\n\n' "${irt_acct}" "${everyone_else}" | vipe)"
fi
else
if [ "$summary" ];then
ap-create-note -s "$summary" "$(vipe)"
else
ap-create-note "$(vipe)"
fi
fi