I am building a web app that users can edit and share notes. Users should be connected to notes with roles (owner, read, read-write). This is an occasionally connected system so I chose to do the syncing using CQRS and event sourcing. Following Greg Young's presentation [36:20 - 38:40], the flow would be as follows:
- Client does changes while offline.
- Client connects to the Internet.
- The "store and forward" sends the events that occurred while the client was offline.
- Client compares the local events with the received events and does a merge, deciding what commands to keep. Then updates local view model.
- Client sends the stored commands (created offline) to the server.
- Server executes the commands and generates events that are stored in event store.
- "store and forward" holds the events each user is interested in, until the users come back online.
The question is: How does the "store and foreword" decide what events should be sent to each user?
Obviously sending all events would compromise the security of other users.