cht-core
cht-core copied to clipboard
Add client-side transition for offline user replace
Description
Overview of logic flow:
- CLIENT (in
webapp)replace_userform submitted- Triggers client-side
user-replace.transitionto setreplacedproperties on user's current contactreplaced.by=_idof new contactreplaced.status= "PENDING"
- Any additional reports submitted after the user is replaced (but before the client syncs) will be automatically re-parented by the client-side transition
- Client syncs.
- When syncing completes successfully, the
syncStatusChangedfunction in theuser-replace.serviceis triggered- If the user has been replaced, and the status is set to "PENDING", then we know everything has now synced successfully (since that is what triggered
syncStatusChangedin the first place - Set the status on the original contact to "READY" and sync again
- When the next sync completes, automatically log out the user
- If the user has been replaced, and the status is set to "PENDING", then we know everything has now synced successfully (since that is what triggered
- When syncing completes successfully, the
- SERVER
- Server's
user_replacetransition is triggered by updated contact withreplaced.status=READY- Creates new user
- Deletes existing user
- Sets original contact
replaced.status=COMPLETE
- Server's
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.
If I understand correctly, any report submitted after the replace will automatically appear to be submitted by the new contact, that's neat! I love where this is going :star_struck:
Yes, the re-parenting would happen immediately on the client side and the user should see any subsequent reports be added by the new contact (which I think is a good thing, though I am afraid it will make it a little more confusing later when they are suddenly logged out...)
@jkuester I went ahead and added one more commit to simplify even more some return types, other than that it's looking very good!