-
Notifications
You must be signed in to change notification settings - Fork 333
[WPB-23806] (Un-)suspend apps if en-/disabled in the team. #5177
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
Open
fisx
wants to merge
8
commits into
develop
Choose a base branch
from
WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
84c28d1
Changelog.
fisx 111026b
Integration test.
fisx 67e1718
Implementation.
fisx 0e0868f
Add note of caution for future me.
fisx 3b1044b
Minimize redundant DB access.
fisx 82eb5b3
Better haddocks.
fisx acd4457
Revert "Better haddocks."
fisx 58cb4ae
Fix imports.
fisx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog.d/3-bug-fixes/WPB-23806-_un-_suspend-apps-if-en-_disabled-in-the-team
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| (Un-)suspend apps if en-/disabled in the team. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,7 +71,10 @@ import Wire.API.User as User | |
| import Wire.API.User.RichInfo | ||
| import Wire.API.User.Search | ||
| import Wire.API.UserEvent | ||
| import Wire.AppStore (AppStore) | ||
| import Wire.AppStore qualified as AppStore | ||
| import Wire.AppSubsystem | ||
| import Wire.AppSubsystem.Interpreter | ||
| import Wire.AuthenticationSubsystem | ||
| import Wire.BlockListStore as BlockList | ||
| import Wire.ClientSubsystem (ClientSubsystem) | ||
|
|
@@ -107,7 +110,8 @@ import Wire.UserSubsystem.UserSubsystemConfig | |
| import Witherable (wither) | ||
|
|
||
| runUserSubsystem :: | ||
| ( Member UserStore r, | ||
| ( Member AppStore r, | ||
| Member UserStore r, | ||
| Member UserKeyStore r, | ||
| Member GalleyAPIAccess r, | ||
| Member BlockListStore r, | ||
|
|
@@ -142,8 +146,10 @@ runUserSubsystem authInterpreter appInterpreter clientInterpreter = | |
| clientInterpreter . appInterpreter . authInterpreter . \case | ||
| GetUserProfiles self others -> | ||
| getUserProfilesImpl self others | ||
| GetLocalUserProfilesFiltered upf others -> | ||
| getLocalUserProfilesFilteredImpl upf others | ||
| GetLocalUserProfiles others -> | ||
| getLocalUserProfilesImpl others | ||
| GetLocalAppProfilesOnly ltid -> | ||
| getLocalAppProfilesOnlyImpl ltid | ||
| GetAccountsBy getBy -> | ||
| getAccountsByImpl getBy | ||
| GetAccountsByEmailNoFilter emails -> | ||
|
|
@@ -345,7 +351,7 @@ getUserProfilesImpl self others = | |
| (getUserProfilesFromDomain self) | ||
| (bucketQualified others) | ||
|
|
||
| getLocalUserProfilesFilteredImpl :: | ||
| getLocalUserProfilesImpl :: | ||
| forall r any. | ||
| ( Member UserStore r, | ||
| Member (Input UserSubsystemConfig) r, | ||
|
|
@@ -356,10 +362,31 @@ getLocalUserProfilesFilteredImpl :: | |
| Member TeamSubsystem r, | ||
| Member AppSubsystem r | ||
| ) => | ||
| UserProfileFilter -> | ||
| Local [UserId] -> | ||
| Sem r [UserProfile] | ||
| getLocalUserProfilesFilteredImpl upf = getUserProfilesLocalPart upf Nothing | ||
| getLocalUserProfilesImpl = getUserProfilesLocalPart Nothing | ||
|
|
||
| getLocalAppProfilesOnlyImpl :: | ||
| forall r any. | ||
| ( Member AppStore r, | ||
| Member UserStore r, | ||
| Member (Input UserSubsystemConfig) r, | ||
| Member DeleteQueue r, | ||
| Member Now r, | ||
| Member (Concurrency Unsafe) r, | ||
| Member (Input (Local any)) r, | ||
| Member AppSubsystem r, | ||
| Member TeamSubsystem r | ||
| ) => | ||
| Local TeamId -> | ||
| Sem r [UserProfile] | ||
| getLocalAppProfilesOnlyImpl ltid = do | ||
| apps <- AppStore.getApps (tUnqualified ltid) | ||
| profiles <- getUserProfilesLocalPart Nothing (ltid $> map (.id) apps) | ||
| pure (zipWith injectPreloadedApp profiles apps) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this ( |
||
| where | ||
| injectPreloadedApp profile app = | ||
| profile {profileApp = Just (storedAppToAppInfo app)} | ||
|
|
||
| getUserProfilesFromDomain :: | ||
| ( Member (Error FederationError) r, | ||
|
|
@@ -382,7 +409,7 @@ getUserProfilesFromDomain :: | |
| getUserProfilesFromDomain self uids = do | ||
| foldQualified | ||
| self | ||
| (getUserProfilesLocalPart RegularPlusAllApps (Just self)) | ||
| (getUserProfilesLocalPart (Just self)) | ||
| getUserProfilesRemotePart | ||
| uids | ||
|
|
||
|
|
@@ -409,11 +436,10 @@ getUserProfilesLocalPart :: | |
| Member AppSubsystem r, | ||
| Member TeamSubsystem r | ||
| ) => | ||
| UserProfileFilter -> | ||
| Maybe (Local UserId) -> | ||
| Local [UserId] -> | ||
| Sem r [UserProfile] | ||
| getUserProfilesLocalPart upf requestingUser luids = do | ||
| getUserProfilesLocalPart requestingUser luids = do | ||
| emailVisibilityConfig <- inputs emailVisibilityConfig | ||
| requestingUserInfo <- join <$> traverse getRequestingUserInfo requestingUser | ||
| let canSeeEmails = maybe False (isAdminOrOwner . view (newTeamMember . nPermissions) . snd) requestingUserInfo | ||
|
|
@@ -422,14 +448,11 @@ getUserProfilesLocalPart upf requestingUser luids = do | |
| EmailVisibleToSelf -> EmailVisibleToSelf | ||
| EmailVisibleIfOnTeam -> EmailVisibleIfOnTeam | ||
| EmailVisibleIfOnSameTeam () -> EmailVisibleIfOnSameTeam requestingUserInfo | ||
| fmap filterAppsFromOtherTeams . injectAppsIntoUserProfiles . catMaybes | ||
| injectAppsIntoUserProfiles . catMaybes | ||
| -- FUTUREWORK: (in the interpreters where it makes sense) pull paginated lists from the DB, | ||
| -- not just single rows. | ||
| =<< unsafePooledForConcurrentlyN 8 (sequence luids) (getLocalUserProfileInternal emailVisibilityConfigWithViewer) | ||
| where | ||
| filterAppsFromOtherTeams :: [UserProfile] -> [UserProfile] | ||
| filterAppsFromOtherTeams = filter (runUserProfileFilter upf) | ||
|
|
||
| getRequestingUserInfo :: Local UserId -> Sem r (Maybe (TeamId, TeamMember)) | ||
| getRequestingUserInfo self = do | ||
| -- FUTUREWORK: it is an internal error for the two lookups (for 'User' and 'TeamMember') | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the "Only" suffix. But that is a super opinionated nit-pick.