mk_note_by_uri(){ mk users/notes "{\"userId\":\"$1\",\"limit\":50,\"withReplies\":true}"| j "print(json.dumps(next((n for n in d if n.get('uri')=='$2'), None)))";}
["$(code_of "$ADMIN" POST /clientapi/admin/emoji/insert -F "shortcode=$code" -F "image=@$work/emoji.png;type=image/png")"=409]\
&& ok "the same shortcode is refused (409)"|| ko "a second :$code: was taken"
["$(code_of "$AT" GET /clientapi/admin/emoji/list)" !=200]&& ok "a persona's token can't list them"|| ko "a persona read the administrator's list"
["$(curl -s "$P/api/v1/custom_emojis"| j "print(any(e['shortcode'] == '$code' and e['url'] == '$emoji_url' and e['category'] == 'Pasture' for e in d))")"= True ]\
&& ok "/api/v1/custom_emojis lists it"|| ko "custom_emojis misses it: $(curl -s "$P/api/v1/custom_emojis"| head -c 300)"
["$(echo"$document"| j "print(d['type'] == 'Emoji' and d['id'] == '$emoji_uri' and d['name'] == ':$code:' and d['icon']['url'] == '$emoji_url' and d['icon']['mediaType'] == 'image/png' and bool(d.get('updated')))")"= True ]\
["$(echo"$post"| has_code "$code")"= True ]&& ok "the status lists :$code: among its emojis here"|| ko "the status has no emoji here: $(echo"$post"| head -c 300)"
until_true 30'[ "$(mcurl -H "$MH" "$M/api/v1/accounts/$alice_on_m/statuses?limit=20" | j "s=next((s for s in d if s[\"uri\"]==\"$post_uri\"), None); print(json.dumps(s[\"emojis\"]) if s else \"null\")" | has_code "$code")" = True ]'\
&& ok "Mastodon shows the post with :$code:"|| ko "Mastodon's copy has no emoji: $(mcurl -H "$MH""$M/api/v1/accounts/$alice_on_m/statuses?limit=5"| head -c 300)"
&& ok "Misskey shows the note with :$code:"|| ko "Misskey's copy has no emoji: $(mk_note_by_uri "$alice_on_mk""$post_uri"| head -c 300)"
until_true 30'[ "$(acurl -H "$KH" "$AK/api/v1/accounts/$alice_on_a/statuses?limit=20" | j "s=next((s for s in d if s[\"uri\"]==\"$post_uri\"), None); print(json.dumps(s[\"emojis\"]) if s else \"null\")" | has_code "$code")" = True ]'\
&& ok "Akkoma shows the post with :$code:"|| ko "Akkoma's copy has no emoji"
&& ok "Mastodon shows the display name with :$code:"|| ko "Mastodon's account: $(mcurl -H "$MH""$M/api/v1/accounts/$alice_on_m"| j "print(d['display_name'], d['emojis'])")"
echo" reactions with it"
mk_post=$(mk notes/create "{\"text\":\"react to this, PrivaPub $run\",\"visibility\":\"public\"}"| j "print(d['createdNote']['id'])")
a_post=$(acurl -X POST -H "$KH""$AK/api/v1/statuses" --data-urlencode "status=react to this too, PrivaPub $run" -d visibility=public | j "print(d['id'])")
until_true 30'[ -n "$(p_home_id "react to this, PrivaPub $run")" ] && [ -n "$(p_home_id "react to this too, PrivaPub $run")" ]'\
&& ok "mkuser's and akuser's posts reach emoji_alice's home"|| ko "the posts to react to never arrived"
mk_on_home=$(p_home_id "react to this, PrivaPub $run");a_on_home=$(p_home_id "react to this too, PrivaPub $run")
["$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$AH""$P/api/v1/pleroma/statuses/$mk_on_home/reactions/%3A$code%3A")"=200]\
&&["$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H "$AH""$P/api/v1/pleroma/statuses/$a_on_home/reactions/%3A$code%3A")"=200]\
&& ok "emoji_alice reacts with :$code: to both"|| ko "the reaction with the local emoji was refused"
&& ok "the EmojiReact reaches Misskey as :$code:"|| ko "Misskey's reactions: $(mk notes/show "{\"noteId\":\"$mk_post\"}"| j "print(d.get('reactions'), d.get('reactionEmojis'))")"
until_true 30'[ "$(acurl -H "$KH" "$AK/api/v1/statuses/$a_post" | j "print(json.dumps((d.get(\"pleroma\") or {}).get(\"emoji_reactions\") or d.get(\"emoji_reactions\") or []))" | has_code "$code")" = True ]'\
&& ok "the EmojiReact reaches Akkoma as :$code:"|| ko "Akkoma's reactions: $(acurl -H "$KH""$AK/api/v1/statuses/$a_post"| j "print((d.get('pleroma') or {}).get('emoji_reactions'))")"
echo" deleted"
["$(code_of "$ADMIN" POST "/clientapi/admin/emoji/delete?shortcode=$code")"=200]&& ok "the administrator deletes it"|| ko "the emoji was not deleted"
["$(curl -s "$P/api/v1/custom_emojis"| j "print(any(e['shortcode'] == '$code' for e in d))")"= False ]&& ok "custom_emojis no longer lists it"|| ko "custom_emojis still lists it"
["$(echo"$log"| j "print(all(any(i['action'] == a and i['targetKind'] == 'emoji' and i.get('targetLabel') == ':$code:' for i in d['items']) for a in ('emoji.insert', 'emoji.delete')))")"= True ]\
&& ok "the staff's log keeps the insert and the delete"|| ko "the staff's log misses the emoji's acts"