[WPB-25136] Do not count apps as paying users.#5213
Conversation
d86787b to
6979bd7
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates how team size is represented and reported across the Wire backend to distinguish between regular users and apps, enabling billing/journaling logic to avoid counting apps as “paying users”.
Changes:
- Extend
TeamSizeto track(regulars, apps)and expose ateamSizeTotalhelper. - Update Galley/Brig code paths (member add/remove, legalhold checks, invitations, team-size endpoints) to use the new
TeamSizeshape. - Update journaling protobuf schema and API/golden/integration tests to include the new breakdown fields.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| services/galley/src/Galley/API/Teams.hs | Updates activation/member add/delete flows to use the new TeamSize and app-vs-regular adjustments. |
| services/galley/src/Galley/API/LegalHold/Team.hs | Switches LegalHold size-limit checks to use TeamSize (via teamSizeTotal). |
| services/brig/test/integration/API/Team.hs | Updates integration expectations for the new TeamSize JSON shape. |
| libs/wire-subsystems/test/unit/Wire/MockInterpreters/IndexedUserStore.hs | Adjusts mock indexed store team-size calculation to split regulars/apps. |
| libs/wire-subsystems/src/Wire/UserSubsystem/Interpreter.hs | Updates max-team-size enforcement to use teamSizeTotal. |
| libs/wire-subsystems/src/Wire/TeamJournal.hs | Changes journal API to accept TeamSize and attempts to emit new member-count fields. |
| libs/wire-subsystems/src/Wire/IndexedUserStore/ElasticSearch.hs | Updates ES counting logic to compute regular/app counts separately. |
| libs/wire-api/test/golden/testObject_TeamSize_1.json | Golden update for new JSON fields. |
| libs/wire-api/test/golden/testObject_TeamSize_2.json | Golden update for new JSON fields. |
| libs/wire-api/test/golden/testObject_TeamSize_3.json | Golden update for new JSON fields. |
| libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/TeamSize.hs | Updates golden test objects to construct TeamSize regulars apps. |
| libs/wire-api/src/Wire/API/User/Search.hs | Introduces UserTypeFilter used where bots are not relevant. |
| libs/wire-api/src/Wire/API/Team/Size.hs | Redefines TeamSize as a record with helpers and updated JSON schema. |
| libs/types-common-journal/proto/TeamEvents.proto | Adds separate journal fields for regular/app member counts. |
| integration/test/Test/Apps.hs | Adds integration test validating team size breakdown when apps exist. |
| integration/test/API/BrigInternal.hs | Adds an internal API helper for GET /i/teams/:tid/size. |
| integration/test/API/Brig.hs | Adds a public API helper for GET /teams/:tid/size. |
| changelog.d/3-bug-fixes/WPB-25136-do-not-count-apps-as-paying-users | Adds changelog entry for the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| getTeamSizeImpl cfg tid = do | ||
| let indexName = cfg.conn.indexName | ||
| countResEither <- embed $ ES.runBH cfg.conn.env $ ES.countByIndex indexName (ES.CountQuery query) | ||
| countRes <- either (liftIO . throwIO . IndexLookupError) pure countResEither | ||
| pure . TeamSize $ ES.crCount countRes | ||
| regulars <- countWith regularQuery | ||
| apps <- countWith appQuery | ||
| pure $ TeamSize regulars apps -- {regulars, apps} |
| (TeamSize sizeBeforeJoin) <- E.getSize tid | ||
| ensureNotTooLargeForLegalHold tid (fromIntegral sizeBeforeJoin + 1) |
There was a problem hiding this comment.
this has been moved to addTeamMemberInternal, which is always called right after.
| (TeamSize sizeBeforeJoin) <- E.getSize tid | ||
| ensureNotTooLargeForLegalHold tid (fromIntegral sizeBeforeJoin + 1) | ||
| (TeamSize sizeBeforeAdd) <- addTeamMemberInternal tid Nothing Nothing nmem |
There was a problem hiding this comment.
moved to addTeamMemberInternal.
| newTeamSize <- addTeamMemberInternal tid Nothing Nothing nmem | ||
| owners <- E.getBillingTeamMembers tid | ||
| Journal.teamUpdate tid (sizeBeforeAdd + 1) owners | ||
| Journal.teamUpdate tid newTeamSize owners |
There was a problem hiding this comment.
addTeamMemberInternal used to return the old size, but that was only ever used to compute the new size, so now it returns the latter instead.
This way it's clear that it may not work for related use cases.
6979bd7 to
a8e3bb9
Compare
https://wearezeta.atlassian.net/browse/WPB-25136
Checklist
changelog.d