Delivery of activities for local objects causes race condition issues
This was spotted by @ariasuni
Steps to reproduce:
- Create a private library
- Ensure it has a follower on the same instance
- Try to change the library visibility level to "instance"
- Observes that it fails (visibility is stuck to "me")
Explanation of the behaviour
When we update the visibility of a library, we update it in our database, then notify followers of the change. All of this happen inside a transaction.
When we notify followers (including local followers), we send an activity, which end up being processed locally, causing a second update. Since the "instance" visibility level is not exposed in ActivityPub representations, we default to me
.
Possible solution
Do not deliver local activities by default (unless specified explicitely, e.g for Follow, and Follow accept)
Edited by Agate