Skip to content

Commit 5f4aab3

Browse files
authored
feat(community)_: send signals about member reevaluation in progress (#5120)
Needed for status-im/status-desktop#14378
1 parent a97f1bb commit 5f4aab3

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

protocol/communities/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,15 @@ func (m *Manager) DeleteCommunityTokenPermission(request *requests.DeleteCommuni
12271227
}
12281228

12291229
func (m *Manager) reevaluateCommunityMembersPermissions(communityID types.HexBytes) error {
1230+
// Publish when the reevluation started since it can take a while
1231+
signal.SendCommunityMemberReevaluationStarted(types.EncodeHex(communityID))
1232+
12301233
community, newPrivilegedMembers, err := m.ReevaluateMembers(communityID)
1234+
1235+
// Publish the reevaluation ending, even if it errored
1236+
// A possible improvement would be to pass the error here
1237+
signal.SendCommunityMemberReevaluationEnded(types.EncodeHex(communityID))
1238+
12311239
if err != nil {
12321240
return err
12331241
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package signal
2+
3+
const (
4+
MemberReevaluationStatus = "community.memberReevaluationStatus"
5+
)
6+
7+
type ReevaluationStatus uint
8+
9+
const (
10+
None ReevaluationStatus = iota
11+
InProgress
12+
Done
13+
)
14+
15+
type CommunityMemberReevaluationSignal struct {
16+
CommunityID string `json:"communityId"`
17+
Status ReevaluationStatus `json:"status"`
18+
}
19+
20+
func SendCommunityMemberReevaluationStarted(communityID string) {
21+
send(MemberReevaluationStatus, CommunityMemberReevaluationSignal{CommunityID: communityID, Status: InProgress})
22+
}
23+
24+
func SendCommunityMemberReevaluationEnded(communityID string) {
25+
send(MemberReevaluationStatus, CommunityMemberReevaluationSignal{CommunityID: communityID, Status: Done})
26+
}

0 commit comments

Comments
 (0)