One delivery a server; BookWyrm 0.9.3 in the pasture

An activity now goes once to each server, to its shared inbox when it has one, for the accounts a post names, answers
or quotes as for its followers, as Mastodon delivers (a circle post excepted: each member's copy names that member).
BookWyrm took the same post twice when one copy reached its shared inbox and another the named account's inbox at once.
SharedInboxTests checks a reply to a follower's post goes once.

BookWyrm joins the pasture (peers/bookwyrm.sh: its image on the shared Postgres and Redis, gunicorn and a Celery worker,
its user, book and statuses made in its Django shell). scenarios/bookwyrm.sh: follows both ways, a review, a comment and
a quotation reaching alice as BookWyrm's pure posts, her like, boost and reply landing there, her post naming bwuser and
bwuser's like and reply, a deletion, the unfollow and statistics: 20 checks. GoToSocial (64), Mastodon (57) and Misskey
(35) still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-06 01:56:06 +02:00
1 parent 12b51a211a
commit 53158b4cf4
9 files changed
+243 -21

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
# BookWyrm 0.9.3: follows both ways; a review, a comment and a quotation on a book reach alice as the "pure" posts
# BookWyrm sends everyone but other BookWyrms; alice's reply, like and boost land there; her post naming bwuser lands
# too (BookWyrm keeps nothing else of others'), and bwuser's like and reply reach her; a deletion; both unfollows;
# statistics. Driven through BookWyrm's Django shell (peers/bookwyrm.sh), as its own
# views make these.
. "$here/peers/bookwyrm.sh"
# bw <python>: in BookWyrm's shell, with bw (bwuser), book and remote(uri) at hand; prints what the code prints
bw() {
bookwyrm_shell "
from bookwyrm import models, activitypub
bw = models.User.objects.get(localname='bwuser')
book = models.Edition.objects.get(title='The Pasture Book')
def remote(uri, model=models.User):
return activitypub.resolve_remote_id(uri, model=model)
$1"
}
p_home_has() { curl -s -H "$PH" "$P/api/v1/timelines/home?limit=40" | j "print(next(((s.get('reblog') or s)['id'] for s in d if '$1' in ((s.get('reblog') or s)['content'] or '') or '$1' in (((s.get('reblog') or s).get('privapub') or {}).get('title') or '')), ''))"; }
p_status() { curl -s -H "$PH" "$P/api/v1/statuses/$1" | j "print(d.get('$2'))"; }
echo "bookwyrm"
[ "$(bw "print(bw.remote_id)")" = "https://bookwyrm.test/user/bwuser" ] && ok "BookWyrm's shell as bwuser" || { ko "BookWyrm's shell"; return 1; }
PT=$(privapub_token alice_bw)
PH="Authorization: Bearer $PT"
[ -n "$PT" ] && ok "PrivaPub token for alice_bw" || { ko "PrivaPub token for alice_bw"; return 1; }
alice_uri="$(curl -s -H "$PH" "$P/api/v1/accounts/verify_credentials" | j "print(d['url'])" | sed 's|/@|/peasants/|')"
run=$(date +%s)
echo " follows"
bw "
alice = remote('$alice_uri')
models.UserFollowRequest.objects.get_or_create(user_subject=bw, user_object=alice)" >/dev/null
until_true 45 '[ "$(bw "print(bw.following.filter(remote_id=\"$alice_uri\").exists())")" = "True" ]' \
&& ok "bwuser follows alice (Accept arrived)" || ko "alice's Accept never reached BookWyrm"
bw_on_p=$(curl -s -H "$PH" "$P/api/v2/search?q=bwuser@bookwyrm.test&resolve=true&type=accounts" | j "print(d['accounts'][0]['id'])")
[ -n "$bw_on_p" ] && ok "PrivaPub resolves bwuser" || ko "PrivaPub cannot resolve bwuser"
curl -s -o /dev/null -X POST -H "$PH" "$P/api/v1/accounts/$bw_on_p/follow"
until_true 45 '[ "$(curl -s -H "$PH" "$P/api/v1/accounts/relationships?id[]=$bw_on_p" | j "print(d[0][\"following\"])")" = "True" ]' \
&& ok "alice follows bwuser (Accept arrived)" || ko "BookWyrm's Accept never arrived"
echo " reading"
bw "models.Review.objects.create(user=bw, book=book, name='A pasture review $run', content='<p>Four stars for the meadow.</p>', rating=4, privacy='public')" >/dev/null
until_true 60 '[ -n "$(p_home_has "A pasture review $run")" ]' && ok "bwuser's review reaches alice" || ko "bwuser's review never reached alice"
bw "models.Comment.objects.create(user=bw, book=book, content='<p>A comment on the book $run</p>', privacy='public')" >/dev/null
until_true 60 '[ -n "$(p_home_has "A comment on the book $run")" ]' && ok "bwuser's comment reaches alice" || ko "bwuser's comment never reached alice"
comment_on_p=$(p_home_has "A comment on the book $run")
comment_uri=$(curl -s -H "$PH" "$P/api/v1/statuses/$comment_on_p" | j "print(d['uri'])")
bw "models.Quotation.objects.create(user=bw, book=book, quote='<p>The grass is greener $run</p>', content='<p>So true.</p>', privacy='public')" >/dev/null
until_true 60 '[ -n "$(p_home_has "The grass is greener $run")" ]' && ok "bwuser's quotation reaches alice" || ko "bwuser's quotation never reached alice"
echo " alice answers"
curl -s -o /dev/null -X POST -H "$PH" "$P/api/v1/statuses/$comment_on_p/favourite"
until_true 45 '[ "$(bw "print(models.Favorite.objects.filter(status__remote_id=\"$comment_uri\", user__remote_id=\"$alice_uri\").exists())")" = "True" ]' \
&& ok "alice's like lands on BookWyrm" || ko "alice's like never reached BookWyrm"
curl -s -o /dev/null -X POST -H "$PH" "$P/api/v1/statuses/$comment_on_p/reblog"
until_true 45 '[ "$(bw "print(models.Boost.objects.filter(boosted_status__remote_id=\"$comment_uri\", user__remote_id=\"$alice_uri\").exists())")" = "True" ]' \
&& ok "alice's boost lands on BookWyrm" || ko "alice's boost never reached BookWyrm"
reply_uri=$(curl -s -X POST -H "$PH" $P/api/v1/statuses -d "status=@bwuser@bookwyrm.test a PrivaPub reply $run&in_reply_to_id=$comment_on_p&visibility=public" | j "print(d['uri'])")
until_true 45 '[ "$(bw "print(models.Status.objects.filter(remote_id=\"$reply_uri\", reply_parent__remote_id=\"$comment_uri\").exists())")" = "True" ]' \
&& ok "alice's reply threads under bwuser's comment" || ko "alice's reply never reached BookWyrm"
echo " bwuser answers"
# (BookWyrm keeps only what concerns books or its own accounts: a post naming bwuser)
p_post=$(curl -s -X POST -H "$PH" $P/api/v1/statuses -d "status=@bwuser@bookwyrm.test a PrivaPub post for BookWyrm $run&visibility=public")
p_post_id=$(echo "$p_post" | j "print(d['id'])"); p_uri=$(echo "$p_post" | j "print(d['uri'])")
until_true 45 '[ "$(bw "print(models.Status.objects.filter(remote_id=\"$p_uri\").exists())")" = "True" ]' \
&& ok "alice's post naming bwuser reaches BookWyrm" || ko "alice's post never reached BookWyrm"
bw "models.Favorite.objects.create(user=bw, status=models.Status.objects.get(remote_id='$p_uri'))" >/dev/null
until_true 45 '[ "$(p_status $p_post_id favourites_count)" = "1" ]' && ok "bwuser's like counts on PrivaPub" || ko "bwuser's like never counted"
bw "models.Status.objects.create(user=bw, content='<p>a BookWyrm reply $run</p>', reply_parent=models.Status.objects.get(remote_id='$p_uri'), privacy='public')" >/dev/null
until_true 45 '[ "$(curl -s -H "$PH" "$P/api/v1/statuses/$p_post_id/context" | j "print(any(\"a BookWyrm reply $run\" in s[\"content\"] for s in d[\"descendants\"]))")" = "True" ]' \
&& ok "bwuser's reply threads under alice's post" || ko "bwuser's reply missing on PrivaPub"
echo " deletions"
bw "models.Comment.objects.get(remote_id='$comment_uri').delete()" >/dev/null
until_true 45 '[ "$(curl -s -o /dev/null -w "%{http_code}" -H "$PH" "$P/api/v1/statuses/$comment_on_p")" = "404" ]' \
&& ok "bwuser's deletion reaches PrivaPub" || ko "the deleted comment still shows on PrivaPub"
echo " unfollows"
curl -s -o /dev/null -X POST -H "$PH" "$P/api/v1/accounts/$bw_on_p/unfollow"
until_true 45 '[ "$(bw "print(bw.followers.filter(remote_id=\"$alice_uri\").exists())")" = "False" ]' \
&& ok "alice's unfollow reaches BookWyrm" || ko "BookWyrm still counts alice"
echo " statistics"
stats_check bookwyrm.test bookwyrm