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. |
||
---|---|---|
.github | ||
bookwyrm | ||
celerywyrm | ||
contrib | ||
dev-tools | ||
exports | ||
images | ||
locale | ||
nginx | ||
static | ||
updates | ||
.coveragerc | ||
.dockerignore | ||
.editorconfig | ||
.env.example | ||
.eslintignore | ||
.eslintrc.js | ||
.gitignore | ||
.prettierignore | ||
.prettierrc | ||
.pylintrc | ||
bump-version.sh | ||
bw-dev | ||
CODE_OF_CONDUCT.md | ||
complete_bwdev.fish | ||
complete_bwdev.sh | ||
complete_bwdev.zsh | ||
crowdin.yml | ||
docker-compose.yml | ||
Dockerfile | ||
FEDERATION.md | ||
LICENSE.md | ||
manage.py | ||
mypy.ini | ||
pyproject.toml | ||
pytest.ini | ||
README.md | ||
redis.conf | ||
requirements.txt | ||
SECURITY.md | ||
VERSION |
BookWyrm
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.
Links
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
- Django web server
- PostgreSQL database
- ActivityPub federation
- Celery task queuing
- Redis task backend
- Redis (again) activity stream manager
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.