{-# LANGUAGE TemplateHaskell #-}
module Galley.Effects.BrigAccess
(
BrigAccess (..),
getConnectionsUnqualified,
getConnectionsUnqualifiedBidi,
getConnections,
putConnectionInternal,
reauthUser,
lookupActivatedUsers,
getUser,
getUsers,
deleteUser,
getContactList,
getRichInfoMultiUser,
getUserExportData,
getSize,
lookupClients,
lookupClientsFull,
notifyClientsAboutLegalHoldRequest,
getLegalHoldAuthToken,
addLegalHoldClientToUser,
removeLegalHoldClientFromUser,
getLocalMLSClients,
getAccountConferenceCallingConfigClient,
updateSearchVisibilityInbound,
)
where
import Brig.Types.Connection
import Brig.Types.Intra
import Data.Id
import Data.Misc
import Data.Qualified
import Galley.External.LegalHoldService.Types
import Imports
import Network.HTTP.Types.Status
import Polysemy
import Polysemy.Error
import Wire.API.Connection
import Wire.API.Error.Galley
import Wire.API.MLS.CipherSuite
import Wire.API.Routes.Internal.Brig.Connection
import Wire.API.Routes.Internal.Galley.TeamFeatureNoConfigMulti qualified as Multi
import Wire.API.Team.Export
import Wire.API.Team.Feature
import Wire.API.Team.Size
import Wire.API.User.Auth.ReAuth
import Wire.API.User.Client
import Wire.API.User.Client.Prekey
import Wire.API.User.RichInfo
data BrigAccess m a where
GetConnectionsUnqualified ::
[UserId] ->
Maybe [UserId] ->
Maybe Relation ->
BrigAccess m [ConnectionStatus]
GetConnectionsUnqualifiedBidi ::
[UserId] ->
[UserId] ->
Maybe Relation ->
Maybe Relation ->
BrigAccess m ([ConnectionStatus], [ConnectionStatus])
GetConnections ::
[UserId] ->
Maybe [Qualified UserId] ->
Maybe Relation ->
BrigAccess m [ConnectionStatusV2]
PutConnectionInternal :: UpdateConnectionsInternal -> BrigAccess m Status
ReauthUser :: UserId -> ReAuthUser -> BrigAccess m (Either AuthenticationError ())
LookupActivatedUsers :: [UserId] -> BrigAccess m [User]
GetUsers :: [UserId] -> BrigAccess m [User]
DeleteUser :: UserId -> BrigAccess m ()
GetContactList :: UserId -> BrigAccess m [UserId]
GetRichInfoMultiUser :: [UserId] -> BrigAccess m [(UserId, RichInfo)]
GetSize :: TeamId -> BrigAccess m TeamSize
LookupClients :: [UserId] -> BrigAccess m UserClients
LookupClientsFull :: [UserId] -> BrigAccess m UserClientsFull
NotifyClientsAboutLegalHoldRequest ::
UserId ->
UserId ->
LastPrekey ->
BrigAccess m ()
GetLegalHoldAuthToken ::
UserId ->
Maybe PlainTextPassword6 ->
BrigAccess m OpaqueAuthToken
AddLegalHoldClientToUserEither ::
UserId ->
ConnId ->
[Prekey] ->
LastPrekey ->
BrigAccess m (Either AuthenticationError ClientId)
RemoveLegalHoldClientFromUser :: UserId -> BrigAccess m ()
GetAccountConferenceCallingConfigClient :: UserId -> BrigAccess m (Feature ConferenceCallingConfig)
GetLocalMLSClients :: Local UserId -> CipherSuiteTag -> BrigAccess m (Set ClientInfo)
UpdateSearchVisibilityInbound ::
Multi.TeamStatus SearchVisibilityInboundConfig ->
BrigAccess m ()
GetUserExportData :: UserId -> BrigAccess m (Maybe TeamExportUser)
makeSem ''BrigAccess
getUser :: (Member BrigAccess r) => UserId -> Sem r (Maybe User)
getUser :: forall (r :: EffectRow).
Member BrigAccess r =>
UserId -> Sem r (Maybe User)
getUser = ([User] -> Maybe User) -> Sem r [User] -> Sem r (Maybe User)
forall a b. (a -> b) -> Sem r a -> Sem r b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [User] -> Maybe User
forall a. [a] -> Maybe a
listToMaybe (Sem r [User] -> Sem r (Maybe User))
-> (UserId -> Sem r [User]) -> UserId -> Sem r (Maybe User)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UserId] -> Sem r [User]
forall (r :: EffectRow).
Member BrigAccess r =>
[UserId] -> Sem r [User]
getUsers ([UserId] -> Sem r [User])
-> (UserId -> [UserId]) -> UserId -> Sem r [User]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UserId -> [UserId]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure
addLegalHoldClientToUser ::
(Member BrigAccess r, Member (Error AuthenticationError) r) =>
UserId ->
ConnId ->
[Prekey] ->
LastPrekey ->
Sem r ClientId
addLegalHoldClientToUser :: forall (r :: EffectRow).
(Member BrigAccess r, Member (Error AuthenticationError) r) =>
UserId -> ConnId -> [Prekey] -> LastPrekey -> Sem r ClientId
addLegalHoldClientToUser UserId
uid ConnId
con [Prekey]
pks LastPrekey
lpk =
UserId
-> ConnId
-> [Prekey]
-> LastPrekey
-> Sem r (Either AuthenticationError ClientId)
forall (r :: EffectRow).
Member BrigAccess r =>
UserId
-> ConnId
-> [Prekey]
-> LastPrekey
-> Sem r (Either AuthenticationError ClientId)
addLegalHoldClientToUserEither UserId
uid ConnId
con [Prekey]
pks LastPrekey
lpk
Sem r (Either AuthenticationError ClientId)
-> (Either AuthenticationError ClientId -> Sem r ClientId)
-> Sem r ClientId
forall a b. Sem r a -> (a -> Sem r b) -> Sem r b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (AuthenticationError -> Sem r ClientId)
-> (ClientId -> Sem r ClientId)
-> Either AuthenticationError ClientId
-> Sem r ClientId
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either AuthenticationError -> Sem r ClientId
forall e (r :: EffectRow) a. Member (Error e) r => e -> Sem r a
throw ClientId -> Sem r ClientId
forall a. a -> Sem r a
forall (f :: * -> *) a. Applicative f => a -> f a
pure