repo: actpub action: blob revision: path_from: ap-actor2acct revision_from: refs/heads/master: path_to: revision_to:
blob of:
/ ap-actor2acct
refs/heads/master:/ap-actor2acct
#!/usr/bin/env bash
uri="$1"
if [ ! "${uri}" ];then
printf "usage: \n" >&2
exit 1
fi
mkdir -p ~/.cache/ap/actor
cache_file=~/.cache/ap/actor/"$(sha256sum <<< "$uri" | cut '-d ' -f1)"
if [ ! -e "$cache_file" ];then
ap-signed-get "$uri" > "${cache_file}"
fi
domain="$(uricut -d <<< "$uri")"
username="$(jq -r '.preferredUsername//""' < "$cache_file")"
acct="${username}@${domain}"
cache_file2=~/.cache/ap/actor/"$acct"
if [ "$username" == "" ];then
printf "preferredUsername was not found\n" >&2
exit 2
fi
if [ ! -e "$cache_file2" ];then
ln -s "$cache_file" "$cache_file2"
fi
printf "acct:%s\n" "$acct"