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
5 changes: 5 additions & 0 deletions .ormolu
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
infixr 10 .=
infix 4 ===
infix 4 =/=
infixr 3 !!!
infixr 3 <!!
1 change: 1 addition & 0 deletions libs/api-bot/.ormolu
3 changes: 2 additions & 1 deletion libs/api-bot/src/Network/Wire/Bot/Crypto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ instance Serialize SymmetricKeys where

randomSymmetricKeys :: MonadIO m => BotClient -> m SymmetricKeys
randomSymmetricKeys clt =
SymmetricKeys <$> randomBytes (botClientBox clt) 32
SymmetricKeys
<$> randomBytes (botClientBox clt) 32
<*> randomBytes (botClientBox clt) 32

encryptSymmetric :: MonadIO m => BotClient -> SymmetricKeys -> Plaintext -> m Ciphertext
Expand Down
3 changes: 2 additions & 1 deletion libs/api-bot/src/Network/Wire/Bot/Email.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ data MailboxSettings = MailboxSettings

instance FromJSON MailboxSettings where
parseJSON = withObject "mailbox-settings" $ \o ->
MailboxSettings <$> o .: "host"
MailboxSettings
<$> o .: "host"
<*> o .: "user"
<*> o .: "pass"
<*> o .: "conn"
Expand Down
31 changes: 17 additions & 14 deletions libs/api-bot/src/Network/Wire/Bot/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ newBotNetEnv manager logger o = do
serverSSL = setBotNetApiSSL o,
serverManager = manager
}
pure
$! BotNetEnv
pure $!
BotNetEnv
{ botNetGen = gen,
botNetMailboxes = mbx,
botNetSender = setBotNetSender o,
Expand All @@ -195,16 +195,16 @@ initMetrics = do
pure m
where
counters =
Metrics.assertionsTotal :
Metrics.assertionsFailed :
Metrics.exceptionsTotal :
Metrics.botsCreatedNew :
Metrics.botsCreatedCached :
Metrics.eventsTotalRcvd :
Metrics.eventsTotalAckd :
Metrics.eventsTotalIgnd :
Metrics.eventsTotalMssd :
concatMap etc [(minBound :: EventType) ..]
Metrics.assertionsTotal
: Metrics.assertionsFailed
: Metrics.exceptionsTotal
: Metrics.botsCreatedNew
: Metrics.botsCreatedCached
: Metrics.eventsTotalRcvd
: Metrics.eventsTotalAckd
: Metrics.eventsTotalIgnd
: Metrics.eventsTotalMssd
: concatMap etc [(minBound :: EventType) ..]
etc t =
[ Metrics.eventTypeRcvd t,
Metrics.eventTypeAckd t,
Expand Down Expand Up @@ -592,7 +592,9 @@ assertFailure :: (HasCallStack, MonadBotNet m) => Text -> m ()
assertFailure m = whenAsserts $ do
incrAssertFailed
log Error . msg $
val "Assertion failed: " +++ m +++ val "\n"
val "Assertion failed: "
+++ m
+++ val "\n"
+++ prettyCallStack callStack

-- | Place an assertion on a 'Bot', expecting a matching 'Event' to arrive
Expand Down Expand Up @@ -771,7 +773,8 @@ heartbeat bot e = forever $ do
for_ out $ liftIO . atomically . flip tryPutTMVar Nothing
botLog l bot Warn $
msg $
"Assertion Timeout: " <> eventTypeText typ
"Assertion Timeout: "
<> eventTypeText typ
<> "\nAssertion was created at: "
<> pack (prettyCallStack stack)
-- Re-establish the push connection, if it died
Expand Down
12 changes: 9 additions & 3 deletions libs/api-bot/src/Network/Wire/Bot/Report/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ formatReport ::
Lazy.Text
formatReport pretty r =
toLazyText $
"\n" <> title <> "\n"
"\n"
<> title
<> "\n"
<> foldMap section (reportSections r)
where
pp x = if pretty then x else mempty
title =
pp underline <> pp bold
pp underline
<> pp bold
<> fromText (reportTitle r)
<> " Report\n\n"
<> pp clear
Expand All @@ -57,7 +60,10 @@ formatReport pretty r =
<> pp clear
<> "\n"
section s =
pp bold <> fromText (sectionName s) <> "\n" <> pp clear
pp bold
<> fromText (sectionName s)
<> "\n"
<> pp clear
<> foldMap metric (sectionMetrics s)
<> "\n"
metric (Counter l p) = single l . fromString . show $ reportCounter r p
Expand Down
1 change: 1 addition & 0 deletions libs/api-client/.ormolu
3 changes: 2 additions & 1 deletion libs/api-client/src/Network/Wire/Client/API/Push.hs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ instance FromJSON Notification where

instance FromJSON a => FromJSON (ConvEvent a) where
parseJSON = withObject "conversation-event" $ \o ->
ConvEvent <$> o .: "conversation"
ConvEvent
<$> o .: "conversation"
<*> o .: "from"
<*> o .: "time"
<*> o .: "data"
Expand Down
6 changes: 4 additions & 2 deletions libs/api-client/src/Network/Wire/Client/HTTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ data Error = Error

instance FromJSON Error where
parseJSON = withObject "error" $ \o ->
Error <$> o .: "code"
Error
<$> o .: "code"
<*> o .: "label"
<*> o .: "message"

Expand Down Expand Up @@ -89,7 +90,8 @@ clientRequest rq expected f = do
exec = do
s <- getServer
let rq' =
rq & setServer s
rq
& setServer s
& header hUserAgent "api-client"
Log.debug $ Log.msg (show rq')
runInIO <- askRunInIO
Expand Down
1 change: 1 addition & 0 deletions libs/bilge/.ormolu
4 changes: 2 additions & 2 deletions libs/bilge/src/Bilge/Assert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ io <!! aa = do
let failures = filter (isJust . snd) $ zip [1 ..] results
unless (null failures) $
error . concat $
title "Assertions failed:\n" :
intersperse "\n" (map msg failures)
title "Assertions failed:\n"
: intersperse "\n" (map msg failures)
++ ["\n\nResponse was:\n\n" ++ show r]
pure r
where
Expand Down
4 changes: 2 additions & 2 deletions libs/bilge/src/Bilge/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ expectStatus property r = r {Rq.checkResponse = check}
check _ res
| property (HTTP.statusCode (Rq.responseStatus res)) = pure ()
| otherwise = do
some <- Lazy.toStrict <$> brReadSome (Rq.responseBody res) 1024
throwHttp $ Rq.StatusCodeException (void res) some
some <- Lazy.toStrict <$> brReadSome (Rq.responseBody res) 1024
throwHttp $ Rq.StatusCodeException (void res) some

checkStatus :: (Status -> ResponseHeaders -> CookieJar -> Maybe SomeException) -> Request -> Request
checkStatus f r = r {Rq.checkResponse = check}
Expand Down
1 change: 1 addition & 0 deletions libs/brig-types/.ormolu
3 changes: 2 additions & 1 deletion libs/brig-types/src/Brig/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ instance FromJSON PhonePrefix where
Just p -> pure p
Nothing ->
fail $
"Invalid phone number prefix: [" ++ show s
"Invalid phone number prefix: ["
++ show s
++ "]. Expected format similar to E.164 (with 1-15 digits after the +)."

instance FromByteString PhonePrefix where
Expand Down
22 changes: 11 additions & 11 deletions libs/brig-types/src/Brig/Types/Team/LegalHold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ data LegalHoldService = LegalHoldService

instance ToJSON LegalHoldService where
toJSON s =
object $
"team_id" .= legalHoldServiceTeam s
# "base_url" .= legalHoldServiceUrl s
# "fingerprint" .= legalHoldServiceFingerprint s
# "auth_token" .= legalHoldServiceToken s
# "public_key" .= legalHoldServiceKey s
# []
object
$ "team_id" .= legalHoldServiceTeam s
# "base_url" .= legalHoldServiceUrl s
# "fingerprint" .= legalHoldServiceFingerprint s
# "auth_token" .= legalHoldServiceToken s
# "public_key" .= legalHoldServiceKey s
# []

instance FromJSON LegalHoldService where
parseJSON = withObject "LegalHoldService" $ \o ->
Expand Down Expand Up @@ -85,7 +85,7 @@ instance FromJSON LegalHoldClientRequest where

instance ToJSON LegalHoldClientRequest where
toJSON (LegalHoldClientRequest requester lastPrekey') =
object $
"requester" .= requester
# "last_prekey" .= lastPrekey'
# []
object
$ "requester" .= requester
# "last_prekey" .= lastPrekey'
# []
66 changes: 66 additions & 0 deletions libs/brig-types/src/Brig/Types/User/Auth.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{-# LANGUAGE OverloadedStrings #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Brig.Types.User.Auth
( SsoLogin (..),
LegalHoldLogin (..),
)
where

import Data.Aeson
import Data.Id (UserId)
import Data.Misc (PlainTextPassword (..))
import Imports
import Wire.API.User.Auth

-- | A special kind of login that is only used for an internal endpoint.
data SsoLogin
= SsoLogin !UserId !(Maybe CookieLabel)

-- | A special kind of login that is only used for an internal endpoint.
-- This kind of login returns restricted 'LegalHoldUserToken's instead of regular
-- tokens.
data LegalHoldLogin
= LegalHoldLogin !UserId !(Maybe PlainTextPassword) !(Maybe CookieLabel)

instance FromJSON SsoLogin where
parseJSON = withObject "SsoLogin" $ \o ->
SsoLogin <$> o .: "user" <*> o .:? "label"

instance ToJSON SsoLogin where
toJSON (SsoLogin uid label) =
object ["user" .= uid, "label" .= label]

instance FromJSON LegalHoldLogin where
parseJSON = withObject "LegalHoldLogin" $ \o ->
LegalHoldLogin
<$> o
.: "user"
<*> o
.:? "password"
<*> o
.:? "label"

instance ToJSON LegalHoldLogin where
toJSON (LegalHoldLogin uid password label) =
object
[ "user" .= uid,
"password" .= password,
"label" .= label
]
1 change: 1 addition & 0 deletions libs/cargohold-types/.ormolu
1 change: 1 addition & 0 deletions libs/cassandra-util/.ormolu
12 changes: 7 additions & 5 deletions libs/cassandra-util/src/Cassandra/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ createKeyspace (Keyspace k) rs = void $ schema (cql rs) (params All ())
where
cql (SimpleStrategy (ReplicationFactor n)) =
QueryString . toLazyText $
fromText "create keyspace if not exists " <> fromText k
fromText "create keyspace if not exists "
<> fromText k
<> fromText " with replication = { "
<> fromText " 'class': 'SimpleStrategy' "
<> fromText " , 'replication_factor': '"
Expand All @@ -146,7 +147,8 @@ createKeyspace (Keyspace k) rs = void $ schema (cql rs) (params All ())
<> fromText "};"
cql (NetworkTopologyStrategy (ReplicationMap dcs)) =
QueryString . toLazyText $
fromText "create keyspace if not exists " <> fromText k
fromText "create keyspace if not exists "
<> fromText k
<> fromText " with replication = { "
<> fromText " 'class': 'NetworkTopologyStrategy' "
<> fromText " , "
Expand All @@ -165,8 +167,8 @@ migrateSchema :: Log.Logger -> MigrationOpts -> [Migration] -> IO ()
migrateSchema l o ms = do
hosts <- initialContactsPlain $ pack (migHost o)
p <-
CQL.init $
setLogger (CT.mkLogger l)
CQL.init
$ setLogger (CT.mkLogger l)
. setContacts (NonEmpty.head hosts) (NonEmpty.tail hosts)
. setPortNumber (fromIntegral $ migPort o)
. setMaxConnections 1
Expand All @@ -183,7 +185,7 @@ migrateSchema l o ms = do
. setSendTimeout 20
. setResponseTimeout 50
. setProtocolVersion V4
$ defSettings
$ defSettings
runClient p $ do
let keyspace = Keyspace . migKeyspace $ o
when (migReset o) $ do
Expand Down
6 changes: 3 additions & 3 deletions libs/cassandra-util/src/Cassandra/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ writeTimeToUTC = posixSecondsToUTCTime . fromIntegral . (`div` 1000000)

defInitCassandra :: Text -> Text -> Word16 -> Log.Logger -> IO ClientState
defInitCassandra ks h p lg =
init $
setLogger (CT.mkLogger lg)
init
$ setLogger (CT.mkLogger lg)
. setPortNumber (fromIntegral p)
. setContacts (unpack h) []
. setKeyspace (Keyspace ks)
$ defSettings
$ defSettings
1 change: 1 addition & 0 deletions libs/deriving-swagger2/.ormolu
1 change: 1 addition & 0 deletions libs/dns-util/.ormolu
1 change: 1 addition & 0 deletions libs/extended/.ormolu
1 change: 1 addition & 0 deletions libs/galley-types/.ormolu
6 changes: 4 additions & 2 deletions libs/galley-types/src/Galley/Types/Bot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ addBot = AddBot

instance FromJSON AddBot where
parseJSON = withObject "AddBot" $ \o ->
AddBot <$> o .: "service"
AddBot
<$> o .: "service"
<*> o .: "conversation"
<*> o .: "bot"
<*> o .: "client"
Expand Down Expand Up @@ -82,7 +83,8 @@ removeBot = RemoveBot

instance FromJSON RemoveBot where
parseJSON = withObject "RemoveBot" $ \o ->
RemoveBot <$> o .: "conversation"
RemoveBot
<$> o .: "conversation"
<*> o .: "bot"

instance ToJSON RemoveBot where
Expand Down
3 changes: 2 additions & 1 deletion libs/galley-types/src/Galley/Types/Bot/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ newService ref url tok fps = Service ref url tok fps True

instance FromJSON Service where
parseJSON = withObject "Service" $ \o ->
Service <$> o .: "ref"
Service
<$> o .: "ref"
<*> o .: "base_url"
<*> o .: "auth_token"
<*> o .: "fingerprints"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ one2OneConvId a b = case compareDomains a b of
]
x = hash c
result =
U.toUUID . U.mk @U.V5
U.toUUID
. U.mk @U.V5
. fromMaybe UUID.nil
-- fromByteString only returns 'Nothing' when the input is not
-- exactly 16 bytes long, here this should not be a case since
Expand Down
Loading