[WPB-27169] Do not count apps and collaborators as members in get-team-size. - #5445
[WPB-27169] Do not count apps and collaborators as members in get-team-size.#5445fisx wants to merge 13 commits into
Conversation
9bbc19f to
5f5d7d0
Compare
5f5d7d0 to
7c986b7
Compare
There was a problem hiding this comment.
Pull request overview
This PR (WPB-27169) changes the meaning/shape of “team size” so that API-visible teamSize represents paid seats (regular users) while apps and collaborators are reported separately, and propagates that change through Galley/Brig, the indexed user store, journaling, and tests.
Changes:
- Redefines
TeamSizeto{teamSize, apps, collaborators}and updates JSON/OpenAPI schema plus golden fixtures. - Updates Galley/Brig logic and integration tests to treat apps/collaborators as non-members for
get-team-size. - Extends indexed user store implementations and team journaling/protobuf definitions to carry separate app/collaborator counts.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| services/galley/src/Galley/API/Teams.hs | Adjusts team-size bookkeeping and LegalHold-related checks to the new TeamSize shape. |
| services/galley/src/Galley/API/LegalHold/Team.hs | Updates LegalHold activation size check to use the new TeamSize representation. |
| services/brig/test/integration/API/Team.hs | Updates expected TeamSize JSON payload in Brig integration tests. |
| libs/wire-subsystems/test/unit/Wire/MockInterpreters/IndexedUserStore.hs | Updates mock team-size computation and adds collaborator counting. |
| libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs | Updates max-team-size checks to use teamSize (paid seats) only. |
| libs/wire-subsystems/src/Wire/TeamJournal.hs | Updates journal event payload generation for new app/collaborator fields. |
| libs/wire-subsystems/src/Wire/IndexedUserStore/ElasticSearch.hs | Updates ES-based team-size result mapping to the new TeamSize fields. |
| libs/wire-api/test/golden/testObject_TeamSize_1.json | Refreshes golden JSON to new TeamSize schema. |
| libs/wire-api/test/golden/testObject_TeamSize_2.json | Refreshes golden JSON to new TeamSize schema. |
| libs/wire-api/test/golden/testObject_TeamSize_3.json | Refreshes golden JSON to new TeamSize schema (large-number case). |
| libs/wire-api/test/golden/testObject_Event_meeting_update_manual_1.json | Golden fixture update (field ordering/structure adjustment). |
| libs/wire-api/test/golden/testObject_Event_meeting_member_add_manual_2.json | Golden fixture update (field ordering/structure adjustment). |
| libs/wire-api/test/golden/testObject_Event_meeting_member_add_manual_1.json | Golden fixture update (field ordering/structure adjustment). |
| libs/wire-api/test/golden/testObject_Event_meeting_delete_manual_1.json | Golden fixture update (field ordering/structure adjustment). |
| libs/wire-api/test/golden/testObject_Event_meeting_create_manual_1.json | Golden fixture update (field ordering/structure adjustment). |
| libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/TeamSize.hs | Updates manual golden Haskell objects for TeamSize. |
| libs/wire-api/src/Wire/API/Team/Size.hs | Redefines TeamSize and updates its schema/Arbitrary instance. |
| libs/types-common-journal/proto/TeamEvents.proto | Changes TeamEvents event-data fields for app/collaborator counts. |
| integration/test/Test/TeamCollaborators.hs | Adds integration assertion that collaborators are counted separately in team size. |
| integration/test/Test/Apps.hs | Adds integration assertion that apps are counted separately in team size. |
| changelog.d/1-api-changes/WPB-27169-do-not-count-apps-and-collaborators-as-members-in-get-team-size | Documents the API schema change for get-team-size and TeamEvents protobuf. |
Suppressed comments (1)
services/galley/src/Galley/API/Teams.hs:1082
- The LegalHold size check now sums
teamSize + apps + collaboratorshere, butensureNotTooLargeToActivateLegalHold(and the PR intent of “do not count apps/collaborators as members”) suggests onlyteamSizeshould be relevant. This inconsistency will make activation vs. later member/app changes apply different limits; please align the definition of what counts toward the LegalHold fanout size across all call sites.
pure case uType of
UserTypeFilterRegular -> n {teamSize = n.teamSize + 1}
UserTypeFilterApp -> n {apps = n.apps + 1}
ensureNotTooLargeForLegalHold tid (sizeAfterAdd.teamSize + sizeAfterAdd.apps + sizeAfterAdd.collaborators)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -1,5 +1,5 @@ | |||
| { | |||
| "teamSize": 0, | |||
There was a problem hiding this comment.
Is it an intended breaking change?
There was a problem hiding this comment.
it just moved to the end of the object, shouldn't be breaking.
c9c245d to
7a33606
Compare
7a33606 to
b61404d
Compare
battermann
left a comment
There was a problem hiding this comment.
I could not find a guard so far that prevents an app/collaborator to be added to it's own team. In this case it would be counted twice, right? But I guess that is ok?
| // they are missing. | ||
| required int32 member_count_regular = 4; | ||
| required int32 member_count_app = 5; | ||
| // fields optional, and assume '0' if missing. |
There was a problem hiding this comment.
why does it say optional in the comment while the fields are tagged with required?
| ( \zuid tid (NewTeamCollaborator uid perms) -> do | ||
| n <- getSize tid | ||
| TeamSubsystem.ensureNotTooLargeForLegalHold tid (n.teamSize + n.apps + n.collaborators + 1) | ||
| createTeamCollaborator zuid uid tid perms | ||
| ) |
There was a problem hiding this comment.
[nit-pick] This would be candidate to extract
There was a problem hiding this comment.
I thought so, too, but turns out this caused a bit of a mess... :-)
I think it's still an improvement, but I am wondering if there isn't a way to throw around fewer constaints (or constraint sets)?
| -- lower-bounding the fields before the substraction. | ||
| -- | ||
| -- We apply (2). | ||
| E.getSize tid <&> \s -> s {teamSize = min 1 s.teamSize, apps = min 1 s.apps} |
There was a problem hiding this comment.
what if teamSize or apps is 0? shouldn't we actually max 1 s.teamSize ... ?
| (\zuid tid (NewTeamCollaborator uid perms) -> createTeamCollaborator zuid uid tid perms) | ||
| ( \zuid tid (NewTeamCollaborator uid perms) -> do | ||
| n <- getSize tid | ||
| TeamSubsystem.ensureNotTooLargeForLegalHold tid (n.teamSize + n.apps + n.collaborators + 1) |
There was a problem hiding this comment.
I would do the permission check before the size check somehow.
fb319cb to
565a5bb
Compare
New schema: `{"teamSize": num, "apps": num, "collaborators": num}` (non-overlapping).
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
565a5bb to
a8de0ac
Compare
This is a follow-up to #5173, #5213, #5452, where we added data about number of apps and collaborators to the
get-team-sizeresponse.Changes:
teamSizefield works again as it did in the olden days, only counting team members, which are regular users by definition.apps,collaborators, which contain the resp. counts.https://wearezeta.atlassian.net/browse/WPB-27169
Checklist
changelog.d