Social reading and reviewing, decentralized with ActivityPub
Find a file
Hugh Rundle 32b041d10c
Fix imports creating duplicate Editions
This fixes bugs at both the sending and receiving instances:
As the primary fix is at the sending end, a full fix will need to be collaborative at the network level.

**Fixing at the sending end: don't send duplicate GeneratedNotes**

The primary fix is to `handle_reading_status`: it calls `create_generated_note` which saves and broadcasts the GeneratedNote.
Before this fix, `handle_reading_status` then saved and broadcast the note again, creating two incoming GeneratedNotes
for all federated BookWyrm servers, and thus triggering simultaneous or near-simultaneous imports of the associated book
within the `tag` reference. This is then dereferenced, creating two identical Works, the first of which ends up empty
and the second of which ends up with two identical Editions.

**Fixing at the sending end: delay BookStatus broadcasts**

My testing doesn't indicate one way or the other whether this happens, but there's a theoretical race condition for incoming
editions that are ListItem or ShelfBook items. The Add activity needs to create the Edition and Work if they are not already
on the receiving instance, and so does the Comment or GeneratedNote. The fix in `ActivitypubMixin::broadcast` sets a delay on
these statuses to ensure that the Add activity is processed first, and thus the book will already exist when the status is
processed.

**Fixing at the receiving end: prevent dereferencing the incoming Edition**

The book attached to a ListItem or ShelfBook is an Edition. This means that when a receiving instance dereferences it, we
end up with a recursion: The Edition dereferences the parent Work, which dereferences all the child editions in celery tasks.
This includes the Edition that triggered the whole process in the first place.

I couldn't create a reproducable test of this, but I've seen evidence that this can cause a race condition where the incoming
Edition ends up being duplicated - the task to create child Editions checks for existence before the original triggering
Edition has saved.

The changes to Note, Fields, and `ActivityObject::to_model` are aimed at preventing this by allowing us to compare related
field ids to the original triggering remote_id before running `set_related_field` and excluding them if there is a match.
2024-11-17 09:24:49 +11:00
.github Merge branch 'main' into pr-template 2024-07-27 11:48:48 -07:00
bookwyrm Fix imports creating duplicate Editions 2024-11-17 09:24:49 +11:00
celerywyrm celerywyrm: allow broker and result backend from the environment 2024-07-28 06:42:11 -03:00
contrib Add sandboxing to systemd examples 2023-08-28 07:29:42 +02:00
dev-tools dev-tools: relax black version constraint 2024-03-21 16:25:29 +01:00
exports Add exports_volume to docker-compose.yml 2024-03-24 12:08:29 +01:00
images Make sure /images/ and /static/ exist now that the bind mount is read only 2024-03-18 21:35:12 +01:00
locale Updates locales and adds missing trimmed on blocktrans 2024-03-25 16:13:00 -07:00
nginx Make nginx config safer 2024-03-29 15:04:38 +01:00
static Make sure /images/ and /static/ exist now that the bind mount is read only 2024-03-18 21:35:12 +01:00
updates Adds celerybeat update script 2022-03-16 12:53:27 -07:00
.coveragerc [lint] Fix missing new lines. 2021-03-04 18:44:36 +01:00
.dockerignore Enable Azure BlobStorage as an alternative to AWS S3 2023-03-05 12:08:16 -05:00
.editorconfig Add specific vendor file 2021-08-23 13:59:23 -07:00
.env.example Allow serving BookWyrm on a non-standard port 2024-04-24 15:30:47 +02:00
.eslintignore [assets] Move some frontend assets to _vendor_ directories: 2021-04-05 16:17:11 +02:00
.eslintrc.js [assets] Document functions and variables: 2021-04-06 16:17:20 +02:00
.gitignore Add docker-compose.override.yml to .gitignore 2024-04-15 13:17:00 +02:00
.prettierignore .prettierignore to vendor 2022-02-28 21:23:44 -08:00
.prettierrc Update .prettierrc 2023-10-17 19:49:32 +02:00
.pylintrc pylint: enable useless-suppression lint and perform cleanup 2024-07-27 03:47:35 -03:00
bump-version.sh Bumped version number to 0.7.0 (#3052) 2023-10-21 18:29:45 +02:00
bw-dev Add Korean (ko-kr) to LANGUAGES and locale 2024-02-10 16:17:25 +09:00
CODE_OF_CONDUCT.md [lint] Fix indentation in .md files. 2021-03-04 19:05:01 +01:00
complete_bwdev.fish Added mypy to scripts and workflow, and some first annotations for celerywyrm 2023-07-22 13:27:43 +02:00
complete_bwdev.sh Added mypy to scripts and workflow, and some first annotations for celerywyrm 2023-07-22 13:27:43 +02:00
complete_bwdev.zsh Added mypy to scripts and workflow, and some first annotations for celerywyrm 2023-07-22 13:27:43 +02:00
crowdin.yml Update Crowdin configuration file 2021-10-06 21:50:47 -07:00
docker-compose.yml docker-compose 'version' has been deprecated 2024-09-09 10:04:16 +10:00
Dockerfile Upgrade Python Version from 3.9 to 3.11 2024-03-02 15:57:06 -08:00
FEDERATION.md undo moves 2023-09-25 22:05:43 +10:00
LICENSE.md Rename License with a .md extension. 2021-04-28 16:05:12 +02:00
manage.py Updates migrations 2020-09-21 08:10:37 -07:00
mypy.ini Merge branch 'main' into mypy-utils 2023-09-08 08:53:38 +02:00
pyproject.toml black: specify required-version 2024-03-20 12:26:21 +01:00
pytest.ini Use in-memory backends for Celery in tests and workflows 2024-07-28 06:42:11 -03:00
README.md Remove twitter from README.md 2024-03-26 17:14:09 +00:00
redis.conf Add redis automatic rewrite configuration. 2024-01-23 18:19:31 -05:00
requirements.txt Merge branch 'main' into dependabot/pip/aiohttp-3.10.2 2024-08-11 17:12:21 -07:00
SECURITY.md Create SECURITY.md 2022-06-30 05:46:41 +01:00
VERSION Bump version to 0.7.3. 2024-03-25 16:15:02 -07:00

BookWyrm

Run Python Tests Pylint

BookWyrm is a social network for tracking your reading, talking about books, writing reviews, and discovering what to read next. Federation allows BookWyrm users to join small, trusted communities that can connect with one another, and with other ActivityPub services like Mastodon and Pleroma.

Mastodon Follow

About BookWyrm

BookWyrm is a platform for social reading. You can use it to track what you're reading, review books, and follow your friends. It isn't primarily meant for cataloguing or as a data-source for books, but it does do both of those things to some degree.

Federation

BookWyrm is built on ActivityPub. With ActivityPub, it inter-operates with different instances of BookWyrm, and other ActivityPub compliant services, like Mastodon. This means you can run an instance for your book club, and still follow your friend who posts on a server devoted to 20th century Russian speculative fiction. It also means that your friend on mastodon can read and comment on a book review that you post on your BookWyrm instance.

Federation makes it possible to have small, self-determining communities, in contrast to the monolithic service you find on GoodReads or Twitter. An instance can be focused on a particular interest, be just for a group of friends, or anything else that brings people together. Each community can choose which other instances they want to federate with, and moderate and run their community autonomously. Check out https://runyourown.social/ to get a sense of the philosophy and logistics behind small, high-trust social networks.

Features

Post about books

Compose reviews, comment on what you're reading, and post quotes from books. You can converse with other BookWyrm users across the network about what they're reading.

Track reading activity

Keep track of what books you've read, and what books you'd like to read in the future.

Federation with ActivityPub

Federation allows you to interact with users on other instances and services, and also shares metadata about books and authors, which collaboratively builds a decentralized database of books.

Privacy and moderation

Users and administrators can control who can see their posts and what other instances to federate with.

Tech Stack

Web backend

Front end

  • Django templates
  • Bulma.io css framework
  • Vanilla JavaScript, in moderation

Deployment

Set up BookWyrm

The documentation website has instruction on how to set up BookWyrm in a developer environment or production.