Ensure owner is removed from community when leaving community

Prior to this commit, when a community owner leaves her community,
status-go would just set the `joined` flag to `false` without updating the
members list. This results in wrong data as the number of members doesn't
match the reality.

This commit removes the owner of the community from the members list
when she's leaving the community.
This commit is contained in:
Pascal Precht 2021-11-12 11:23:59 +01:00 committed by r4bbit.eth
parent 1b9bc4450c
commit 1ffcf23f9b
1 changed files with 7 additions and 0 deletions

View File

@ -726,8 +726,15 @@ func (m *Manager) LeaveCommunity(id types.HexBytes) (*Community, error) {
if community == nil {
return nil, ErrOrgNotFound
}
if community.IsAdmin() {
_, err = community.RemoveUserFromOrg(m.identity)
if err != nil {
return nil, err
}
}
community.Leave()
err = m.persistence.SaveCommunity(community)
if err != nil {
return nil, err
}