repo: actpub
action: blob
revision: 
path_from: ap-actor2acct
revision_from: refs/heads/master:
path_to: 
revision_to: 
git.thebackupbox.net
actpub
git clone git://git.thebackupbox.net/actpub

blob of:

actpub

/ ap-actor2acct

blob_plain of this file

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"