[ -n "$gts_on_pp"]&& ok "PrivaPub resolves @gtsuser@gts.test"|| ko "PrivaPub cannot resolve gtsuser"
echo"follows"
gcurl -s -o /dev/null -X POST -H "$GH"$G/api/v1/accounts/$alice_on_gts/follow
until_true 20'[ "$(gcurl -s -H "$GH" "$G/api/v1/accounts/relationships?id[]=$alice_on_gts" | j "print(d[0][\"following\"])")" = "True" ]'&& ok "gtsuser follows alice (Accept arrived)"|| ko "gtsuser's follow of alice not accepted"
curl -s -o /dev/null -X POST -H "$PH"$P/api/v1/accounts/$gts_on_pp/follow
until_true 10'[ "$(curl -s -H "$PH" "$P/api/v1/accounts/relationships?id[]=$gts_on_pp" | j "print(d[0][\"requested\"])")" = "True" ]'&& ok "alice's follow of locked gtsuser waits as a request"|| ko "alice's follow is not shown as requested"
until_true 20'gcurl -s -H "$GH" "$G/api/v1/follow_requests" | j "print(any(a[\"id\"]==\"$alice_on_gts\" for a in d))" | grep -q True'&& ok "the request reaches gtsuser's follow requests"|| ko "follow request missing on GoToSocial"
gcurl -s -o /dev/null -X POST -H "$GH"$G/api/v1/follow_requests/$alice_on_gts/authorize
until_true 20'[ "$(curl -s -H "$PH" "$P/api/v1/accounts/relationships?id[]=$gts_on_pp" | j "print(d[0][\"following\"])")" = "True" ]'&& ok "alice follows gtsuser (Accept arrived)"|| ko "alice's follow of gtsuser not accepted"
echo"posts"
pp_status=$(curl -s -X POST -H "$PH"$P/api/v1/statuses -d 'status=Hello from PrivaPub #pasture&visibility=public')
until_true 20'on_gts "$pp_uri" | j "print(len(d[\"statuses\"]))" | grep -q 1'&& ok "alice's post reaches GoToSocial"|| ko "alice's post missing on GoToSocial"
gts_post=$(gcurl -s -X POST -H "$GH"$G/api/v1/statuses -d 'status=Hello from GoToSocial&visibility=public'| j "print(d['id'])")
until_true 20'curl -s -H "$PH" "$P/api/v1/timelines/home" | grep -q "Hello from GoToSocial"'&& ok "gtsuser's post reaches alice's home"|| ko "gtsuser's post missing on PrivaPub"
["$(curl -s -H "$PH""$P/api/v1/timelines/home"| j "print(next(s['edited_at'] for s in d if 'Hello from GoToSocial' in s['content']))")"="None"]&& ok "an unedited remote post carries no edited_at"|| ko "unedited remote post reports an edit"
cw_status=$(curl -s -X POST -H "$PH"$P/api/v1/statuses -d 'status=behind a warning&spoiler_text=spoilers&visibility=public')
until_true 20'on_gts "$cw_uri" | j "print(any(s[\"spoiler_text\"]==\"spoilers\" and s[\"sensitive\"] for s in d[\"statuses\"]))" | grep -q True'&& ok "content warning survives to GoToSocial"|| ko "content warning lost"
gcurl -s -o /dev/null -X POST -H "$GH"$G/api/v1/statuses -d "status=@alice@privapub.test nice to meet you&in_reply_to_id=$pp_on_gts&visibility=public"
until_true 20'curl -s -H "$PH" "$P/api/v1/notifications" | j "print(any(n[\"type\"]==\"mention\" for n in d))" | grep -q True'&& ok "gtsuser's reply notifies alice"|| ko "reply did not notify alice"
until_true 10'[ "$(curl -s -H "$PH" "$P/api/v1/statuses/$pp_post/context" | j "print(len(d[\"descendants\"]))")" -ge 1 ]'&& ok "the reply threads under alice's post"|| ko "reply not threaded"
echo"likes and boosts"
gts_on_pp_post=$(curl -s -H "$PH""$P/api/v1/timelines/home"| j "print(next(s['id'] for s in d if 'Hello from GoToSocial' in s['content']))")
curl -s -o /dev/null -X POST -H "$PH"$P/api/v1/statuses/$gts_on_pp_post/favourite
curl -s -o /dev/null -X POST -H "$PH"$P/api/v1/statuses/$gts_on_pp_post/reblog
until_true 20'gcurl -s -H "$GH" "$G/api/v1/notifications" | j "print(any(n[\"type\"]==\"favourite\" for n in d))" | grep -q True'&& ok "alice's like reaches GoToSocial"|| ko "like not received"
until_true 20'gcurl -s -H "$GH" "$G/api/v1/notifications" | j "print(any(n[\"type\"]==\"reblog\" for n in d))" | grep -q True'&& ok "alice's boost reaches GoToSocial"|| ko "boost not received"
gcurl -s -o /dev/null -X POST -H "$GH"$G/api/v1/statuses/$pp_on_gts/favourite
gcurl -s -o /dev/null -X POST -H "$GH"$G/api/v1/statuses/$pp_on_gts/reblog
until_true 20'[ "$(curl -s -H "$PH" "$P/api/v1/statuses/$pp_post" | j "print(d[\"favourites_count\"])")" = "1" ]'&& ok "gtsuser's like counts on PrivaPub"|| ko "like not counted"
until_true 20'curl -s -H "$PH" "$P/api/v1/notifications" | j "print(any(n[\"type\"]==\"reblog\" for n in d))" | grep -q True'&& ok "gtsuser's boost notifies alice"|| ko "boost not notified"
echo"direct messages"
curl -s -o /dev/null -X POST -H "$PH"$P/api/v1/statuses -d 'status=@gtsuser@gts.test a secret&visibility=direct'
until_true 20'gcurl -s -H "$GH" "$G/api/v1/conversations" | grep -q "a secret"'&& ok "alice's DM reaches gtsuser"|| ko "DM missing on GoToSocial"
gcurl -s -o /dev/null -X POST -H "$GH"$G/api/v1/statuses -d 'status=@alice@privapub.test a secret back&visibility=direct'
until_true 20'curl -s -H "$PH" "$P/api/v1/conversations" | grep -q "a secret back"'&& ok "gtsuser's DM reaches alice"|| ko "DM missing on PrivaPub"
until_true 5'! gcurl -s -H "$GH" "$G/api/v1/timelines/public?local=false" | grep -q "a secret"'&& ok "the DM is not public on GoToSocial"|| ko "DM leaked to a public timeline"
echo"edits and deletes"
curl -s -o /dev/null -X PUT -H "$PH"$P/api/v1/statuses/$pp_post -d 'status=Hello from PrivaPub, edited'
until_true 20'gcurl -s -H "$GH" "$G/api/v1/statuses/$pp_on_gts" | grep -q "edited"'&& ok "alice's edit reaches GoToSocial"|| ko "edit not applied"