Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove ourselves from members when leaving community #2862

Merged
merged 1 commit into from
Sep 21, 2022

Conversation

osmaczko
Copy link
Contributor

Otherwise clients see invalid members count in invitation bubbles.

Otherwise clients see invalid members count in invitation bubbles.
@status-github-bot
Copy link

status-github-bot bot commented Sep 15, 2022

Pull Request Checklist

  • Have you updated the documentation, if impacted (e.g. docs.status.im)?
  • Have you tested changes with mobile?
  • Have you tested changes with desktop?

@status-im-auto
Copy link
Member

status-im-auto commented Sep 15, 2022

Jenkins Builds

Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ e3c0dea #1 2022-09-15 12:43:25 ~2 min linux 📦zip
✔️ e3c0dea #1 2022-09-15 12:44:58 ~4 min ios 📦zip
✔️ e3c0dea #1 2022-09-15 12:46:53 ~5 min android 📦aar

o.mutex.Lock()
defer o.mutex.Unlock()
o.removeMemberFromOrg(pk)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly is this called RemoveOurselvesFromOrg ?
This seems a pretty generic function. In fact it seems to be just an exposed API for removeMemberFromOrg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you compare RemoveOurselvesFromOrg with RemoveUserFromOrg you will see they only differ with one check. If we remove ourselves from org we don't need to check if we are admins.

The other option was to have one function with an additional boolean parameter:
RemoveUserFromOrg(pk *ecdsa.PublicKey, requireAdmin bool)

Since boolean arguments are bad for code readability (see example below), I decided to go with the first one.

func (a *Api) LeaveCommunity() {
    community.RemoveOurselvesFromOrg(m.identity.pubKey)
}
func (a *Api) RemoveUserFromOrg(pubKey *PubKey) {
    community.RemoveUserFromOrg(pubKey)
}

vs

func (a *Api) LeaveCommunity() {
    community.RemoveUserFromOrg(m.identity.pubKey, false)
}
func (a *Api) RemoveUserFromOrg(pubKey *PubKey) {
    community.RemoveUserFromOrg(pubKey, true)
}

@osmaczko osmaczko merged commit e4ca8a2 into develop Sep 21, 2022
@osmaczko osmaczko deleted the fix/leave-community branch September 21, 2022 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants