Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/brig-redundant-constraints
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove some redudant constraints in brig
7 changes: 0 additions & 7 deletions services/brig/src/Brig/API/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ addClientWithReAuthPolicy policy u con ip new = do
( MonadReader Env m,
MonadMask m,
MonadHttp m,
MonadIO m,
HasRequestId m,
Log.MonadLogger m,
MonadClient m
Expand Down Expand Up @@ -228,7 +227,6 @@ rmClient u con clt pw =

claimPrekey ::
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand Down Expand Up @@ -267,10 +265,6 @@ claimLocalPrekey protectee user client = do

claimRemotePrekey ::
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Log.MonadLogger m,
MonadClient m
) =>
Expand Down Expand Up @@ -394,7 +388,6 @@ execDelete u con c = do
-- (and possibly duplicated) client data.
noPrekeys ::
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand Down
3 changes: 1 addition & 2 deletions services/brig/src/Brig/API/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
module Brig.API.Error where

import Brig.API.Types
import Brig.Options (DomainsBlockedForRegistration)
import Brig.Phone (PhoneException (..))
import Brig.Types.Common (PhoneBudgetTimeout (..))
import Control.Monad.Error.Class hiding (Error)
Expand Down Expand Up @@ -414,7 +413,7 @@ legalHoldNotEnabled = Wai.mkError status403 "legalhold-not-enabled" "LegalHold m

-- (the tautological constraint in the type signature is added so that once we remove the
-- feature, ghc will guide us here.)
customerExtensionBlockedDomain :: (DomainsBlockedForRegistration ~ DomainsBlockedForRegistration) => Domain -> Wai.Error
customerExtensionBlockedDomain :: Domain -> Wai.Error
customerExtensionBlockedDomain domain = Wai.mkError (mkStatus 451 "Unavailable For Legal Reasons") "domain-blocked-for-registration" msg
where
msg =
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/API/Public.hs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ sendActivationCode Public.SendActivationCode {..} = do
--
-- The tautological constraint in the type signature is added so that once we remove the
-- feature, ghc will guide us here.
customerExtensionCheckBlockedDomains :: (DomainsBlockedForRegistration ~ DomainsBlockedForRegistration) => Public.Email -> (Handler r) ()
customerExtensionCheckBlockedDomains :: Public.Email -> (Handler r) ()
customerExtensionCheckBlockedDomains email = do
mBlockedDomains <- asks (fmap domainsBlockedForRegistration . setCustomerExtensions . view settings)
for_ mBlockedDomains $ \(DomainsBlockedForRegistration blockedDomains) -> do
Expand Down
3 changes: 0 additions & 3 deletions services/brig/src/Brig/API/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,8 @@ verifyDeleteUser d = do
-- other owner left.
deleteAccount ::
( MonadLogger m,
MonadCatch m,
MonadThrow m,
MonadIndexIO m,
MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand Down
4 changes: 2 additions & 2 deletions services/brig/src/Brig/AWS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ throwA :: Either AWS.Error a -> Amazon a
throwA = either (throwM . GeneralError) pure

execCatch ::
(AWSRequest a, MonadUnliftIO m, MonadCatch m, MonadThrow m, MonadIO m) =>
(AWSRequest a, MonadUnliftIO m, MonadCatch m) =>
AWS.Env ->
a ->
m (Either AWS.Error (AWSResponse a))
Expand All @@ -255,7 +255,7 @@ execCatch e cmd =
AWS.send e cmd

exec ::
(AWSRequest a, MonadCatch m, MonadThrow m, MonadIO m) =>
(AWSRequest a, MonadCatch m, MonadIO m) =>
AWS.Env ->
a ->
m (AWSResponse a)
Expand Down
4 changes: 2 additions & 2 deletions services/brig/src/Brig/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ instance MonadLogger (AppT r) where
instance MonadLogger (ExceptT err (AppT r)) where
log l m = lift (LC.log l m)

instance MonadIO m => MonadHttp (AppT r) where
instance MonadHttp (AppT r) where
handleRequestWithCont req handler = do
manager <- view httpManager
liftIO $ withResponse req manager handler
Expand Down Expand Up @@ -577,7 +577,7 @@ instance MonadIndexIO (AppT r) where
instance MonadIndexIO (AppT r) => MonadIndexIO (ExceptT err (AppT r)) where
liftIndexIO m = view indexEnv >>= \e -> runIndexIO e m

instance Monad m => HasRequestId (AppT r) where
instance HasRequestId (AppT r) where
getRequestId = view requestId

locationOf :: (MonadIO m, MonadReader Env m) => IP -> m (Maybe Location)
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/Data/Activation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ activateKey k c u = verifyCode k c >>= pickUser >>= activate
for_ oldKey $ lift . deleteKey
pure . Just $ foldKey (EmailActivated uid) (PhoneActivated uid) key
where
updateEmailAndDeleteEmailUnvalidated :: MonadClient m => UserId -> Email -> m ()
updateEmailAndDeleteEmailUnvalidated :: UserId -> Email -> m ()
updateEmailAndDeleteEmailUnvalidated u' email =
updateEmail u' email <* deleteEmailUnvalidated u'
claim key uid = do
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/Data/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ lookupUserTeam u =
(runIdentity =<<)
<$> retry x1 (query1 teamSelect (params LocalQuorum (Identity u)))

lookupAuth :: MonadClient m => (MonadClient m) => UserId -> m (Maybe (Maybe Password, AccountStatus))
lookupAuth :: MonadClient m => UserId -> m (Maybe (Maybe Password, AccountStatus))
lookupAuth u = fmap f <$> retry x1 (query1 authSelect (params LocalQuorum (Identity u)))
where
f (pw, st) = (pw, fromMaybe Active st)
Expand Down
1 change: 0 additions & 1 deletion services/brig/src/Brig/Federation/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ notifyUserDeleted ::
( MonadReader Env m,
MonadIO m,
HasFedEndpoint 'Brig api "on-user-deleted-connections",
HasClient ClientM api,
HasClient (FederatorClient 'Brig) api
) =>
Local UserId ->
Expand Down
24 changes: 4 additions & 20 deletions services/brig/src/Brig/IO/Intra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ import Wire.API.User.Client

onUserEvent ::
( MonadLogger m,
MonadCatch m,
MonadThrow m,
MonadIndexIO m,
MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand Down Expand Up @@ -215,11 +212,8 @@ onClientEvent orig conn e = do

updateSearchIndex ::
( MonadClient m,
MonadLogger m,
MonadCatch m,
MonadLogger m,
MonadCatch m,
MonadThrow m,
MonadIndexIO m
) =>
UserId ->
Expand Down Expand Up @@ -277,7 +271,6 @@ dispatchNotifications ::
Log.MonadLogger m,
MonadReader Env m,
MonadMask m,
MonadCatch m,
MonadHttp m,
HasRequestId m,
MonadUnliftIO m,
Expand Down Expand Up @@ -314,7 +307,6 @@ notifyUserDeletionLocals ::
Log.MonadLogger m,
MonadReader Env m,
MonadMask m,
MonadCatch m,
MonadHttp m,
HasRequestId m,
MonadUnliftIO m,
Expand All @@ -331,7 +323,6 @@ notifyUserDeletionLocals deleted conn event = do
notifyUserDeletionRemotes ::
forall m.
( MonadReader Env m,
MonadIO m,
MonadClient m,
MonadLogger m
) =>
Expand All @@ -358,7 +349,7 @@ notifyUserDeletionRemotes deleted = do
whenLeft eitherFErr $
logFederationError (tDomain uids)

logFederationError :: Log.MonadLogger m => Domain -> FederationError -> m ()
logFederationError :: Domain -> FederationError -> m ()
logFederationError domain fErr =
Log.err $
Log.msg ("Federation error while notifying remote backends of a user deletion." :: ByteString)
Expand All @@ -372,7 +363,6 @@ push ::
Log.MonadLogger m,
MonadReader Env m,
MonadMask m,
MonadCatch m,
MonadHttp m,
HasRequestId m
) =>
Expand Down Expand Up @@ -404,7 +394,6 @@ rawPush ::
Log.MonadLogger m,
MonadReader Env m,
MonadMask m,
MonadCatch m,
MonadHttp m,
HasRequestId m
) =>
Expand Down Expand Up @@ -458,7 +447,6 @@ notify ::
Log.MonadLogger m,
MonadReader Env m,
MonadMask m,
MonadCatch m,
MonadHttp m,
HasRequestId m,
MonadUnliftIO m
Expand Down Expand Up @@ -499,7 +487,6 @@ notifySelf ::
Log.MonadLogger m,
MonadReader Env m,
MonadMask m,
MonadCatch m,
MonadHttp m,
HasRequestId m,
MonadUnliftIO m
Expand All @@ -518,7 +505,6 @@ notifySelf events orig route conn =
notifyContacts ::
forall m.
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand All @@ -538,7 +524,7 @@ notifyContacts events orig route conn = do
notify events orig route conn $
list1 orig <$> liftA2 (++) contacts teamContacts
where
contacts :: MonadClient m => m [UserId]
contacts :: m [UserId]
contacts = lookupContactList orig

teamContacts :: m [UserId]
Expand Down Expand Up @@ -929,8 +915,7 @@ upsertOne2OneConversation ::
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
MonadLogger m
HasRequestId m
) =>
UpsertOne2OneConversationRequest ->
m UpsertOne2OneConversationResponse
Expand Down Expand Up @@ -1079,8 +1064,7 @@ lookupPushToken ::
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
MonadLogger m
HasRequestId m
) =>
UserId ->
m [Push.PushToken]
Expand Down
4 changes: 2 additions & 2 deletions services/brig/src/Brig/Index/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ runCommand l = \case
. C.setProtocolVersion C.V4
$ C.defSettings

waitForTaskToComplete :: forall a m. (ES.MonadBH m, MonadIO m, MonadThrow m, FromJSON a) => Int -> ES.TaskNodeId -> m ()
waitForTaskToComplete :: forall a m. (ES.MonadBH m, MonadThrow m, FromJSON a) => Int -> ES.TaskNodeId -> m ()
waitForTaskToComplete timeoutSeconds taskNodeId = do
-- Delay is 0.1 seconds, so retries are limited to timeoutSeconds * 10
let policy = constantDelay 100000 <> limitRetries (timeoutSeconds * 10)
Expand All @@ -130,7 +130,7 @@ waitForTaskToComplete timeoutSeconds taskNodeId = do
isTaskComplete (Left e) = throwM $ ReindexFromAnotherIndexError $ "Error response while getting task: " <> show e
isTaskComplete (Right taskRes) = pure $ ES.taskResponseCompleted taskRes

errTaskGet :: MonadThrow m => ES.EsError -> m x
errTaskGet :: ES.EsError -> m x
errTaskGet e = throwM $ ReindexFromAnotherIndexError $ "Error response while getting task: " <> show e

newtype ReindexFromAnotherIndexError = ReindexFromAnotherIndexError String
Expand Down
6 changes: 3 additions & 3 deletions services/brig/src/Brig/Index/Migrations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mkEnv l es cas galleyEndpoint = do
$ C.defSettings
initLogger = pure l

createMigrationsIndexIfNotPresent :: (MonadThrow m, MonadIO m, ES.MonadBH m, Log.MonadLogger m) => m ()
createMigrationsIndexIfNotPresent :: (MonadThrow m, ES.MonadBH m, Log.MonadLogger m) => m ()
createMigrationsIndexIfNotPresent =
do
unlessM (ES.indexExists indexName) $ do
Expand All @@ -111,7 +111,7 @@ createMigrationsIndexIfNotPresent =
throwM $
err (show response)

failIfIndexAbsent :: (MonadThrow m, MonadIO m, ES.MonadBH m) => ES.IndexName -> m ()
failIfIndexAbsent :: (MonadThrow m, ES.MonadBH m) => ES.IndexName -> m ()
failIfIndexAbsent targetIndex =
unlessM
(ES.indexExists targetIndex)
Expand All @@ -135,7 +135,7 @@ runMigration ver = do
. Log.field "expectedVersion" vmax
. Log.field "foundVersion" ver

persistVersion :: (Monad m, MonadThrow m, MonadIO m) => MigrationVersion -> MigrationActionT m ()
persistVersion :: (MonadThrow m, MonadIO m) => MigrationVersion -> MigrationActionT m ()
persistVersion v =
let docId = ES.DocId . Text.pack . show $ migrationVersion v
in do
Expand Down
2 changes: 0 additions & 2 deletions services/brig/src/Brig/InternalEvent/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ import UnliftIO (timeout)
onEvent ::
( Log.MonadLogger m,
MonadCatch m,
MonadThrow m,
MonadIndexIO m,
MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand Down
4 changes: 0 additions & 4 deletions services/brig/src/Brig/Provider/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@ deleteService pid sid del = do

finishDeleteService ::
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
HasRequestId m,
Expand All @@ -715,7 +714,6 @@ finishDeleteService pid sid = do

deleteAccountH ::
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
MonadClient m,
Expand All @@ -730,7 +728,6 @@ deleteAccountH (pid ::: req) = do

deleteAccount ::
( MonadReader Env m,
MonadIO m,
MonadMask m,
MonadHttp m,
MonadClient m,
Expand Down Expand Up @@ -1109,7 +1106,6 @@ activate pid old new = do
deleteBot ::
( MonadHttp m,
MonadReader Env m,
MonadIO m,
MonadMask m,
HasRequestId m,
MonadLogger m,
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/Team/DB.hs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ deleteInvitation t i = do
cqlInvitationEmail :: PrepQuery W (Email, TeamId) ()
cqlInvitationEmail = "DELETE FROM team_invitation_email WHERE email = ? AND team = ?"

deleteInvitations :: (MonadClient m, MonadUnliftIO m) => TeamId -> m ()
deleteInvitations :: (MonadClient m) => TeamId -> m ()
deleteInvitations t =
liftClient $
runConduit $
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/User/API/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ tokenRequest = opt (userToken ||| legalHoldUserToken) .&. opt (accessToken ||| l
tokenQuery :: r -> Result P.Error ByteString
tokenQuery = query "access_token"

cookieErr :: ZAuth.UserTokenLike u => Result P.Error (List1 (ZAuth.Token u)) -> Result P.Error (List1 (ZAuth.Token u))
cookieErr :: Result P.Error (List1 (ZAuth.Token u)) -> Result P.Error (List1 (ZAuth.Token u))
cookieErr x@Okay {} = x
cookieErr (Fail x) = Fail (setMessage "Invalid user token" (P.setStatus status403 x))

Expand Down
Loading