status-go
status-go copied to clipboard
Only rerun the member-re-evaluation on a particular permission when one is created/edited/removed
Problem
Currently, when a permissions is modified (created, edited or removed), we schedule a full re-evaluation of the members.
However, most of the time, that permission will only affect a few channels, so it makes no sense to re-evaluate all the channels and all the permissions.
Implementation
When we schedule a re-evaluation after a permission, we should pass the permission ID to the function. Then, we can re-evaluate more precisely and faster.
Acceptance Criteria
- member re-evaluation is faster when it's done in response to a permission change
- new integration test(s) are written to validate the new behavior.
Notes
The catch is that some channels have multiple permissions to them and they act like logical ORs, so we need to be careful about how we handle this.
I guess the logic for adding a permission should be something like:
- if the channel was not permissioned, just evaluate the new permission and if the user doesn't fit, exclude the user
- if user was a member of a permissioned channel already, that means they already fit the first permission, so it's useless to check the new one (continue/return)
- if the user was not a member of the permissioned channel, then run the check on the new permission. If they fit it, then include the user
We need to do some similar logic for removals and edits.
Parking this issue for now, as it requires significant changes to the member reevaluation logic and is considered high risk with low reward. In typical community management workflows, permission adjustments are infrequent after the initial setup phase, so in the long run, it shouldn't result in excessive infura calls.
Some progress has been made, but substantial work and testing still need to be completed.