Skip to content

Commit

Permalink
Drop 'cs' from galley
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Apr 16, 2024
1 parent c5b7d25 commit 25315d6
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 19 deletions.
4 changes: 4 additions & 0 deletions services/galley/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
, ssl-util
, stm
, streaming-commons
, string-conversions
, tagged
, tasty
, tasty-ant-xml
Expand All @@ -109,6 +110,7 @@
, unliftio
, unordered-containers
, uri-bytestring
, utf8-string
, uuid
, uuid-types
, vector
Expand Down Expand Up @@ -206,6 +208,7 @@ mkDerivation {
types-common-journal
unliftio
uri-bytestring
utf8-string
uuid
wai
wai-extra
Expand Down Expand Up @@ -281,6 +284,7 @@ mkDerivation {
sop-core
ssl-util
streaming-commons
string-conversions
tagged
tasty
tasty-ant-xml
Expand Down
2 changes: 2 additions & 0 deletions services/galley/galley.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ library
, types-common-journal >=0.1
, unliftio >=0.2
, uri-bytestring >=0.2
, utf8-string
, uuid >=1.3
, wai >=3.0
, wai-extra >=3.0
Expand Down Expand Up @@ -527,6 +528,7 @@ executable galley-integration
, sop-core
, ssl-util
, streaming-commons
, string-conversions
, tagged
, tasty >=0.8
, tasty-ant-xml
Expand Down
3 changes: 2 additions & 1 deletion services/galley/src/Galley/API/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ where

import Control.Exception.Safe (catchAny)
import Control.Lens hiding (Getter, Setter, (.=))
import Data.ByteString.UTF8 qualified as UTF8
import Data.Id as Id
import Data.Json.Util (ToJSONObject (toJSONObject))
import Data.Map qualified as Map
Expand Down Expand Up @@ -453,7 +454,7 @@ safeForever :: String -> App () -> App ()
safeForever funName action =
forever $
action `catchAny` \exc -> do
err $ "error" .= show exc ~~ msg (val $ cs funName <> " failed")
err $ "error" .= show exc ~~ msg (val $ UTF8.fromString funName <> " failed")
threadDelay 60000000 -- pause to keep worst-case noise in logs manageable

guardLegalholdPolicyConflictsH ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Galley.API.MLS.Types
import Galley.API.MLS.Util
import Galley.Effects
import Galley.Effects.MemberStore
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Error
import Polysemy.Resource (Resource)
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/MLS/One2One.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Galley.API.MLS.Types
import Galley.Data.Conversation.Types qualified as Data
import Galley.Effects.ConversationStore
import Galley.Types.UserList
import Imports hiding (cs)
import Imports
import Polysemy
import Wire.API.Conversation hiding (Member)
import Wire.API.Conversation.Protocol
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/MLS/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Galley.Effects.BrigAccess
import Galley.Effects.ProposalStore
import Galley.Env
import Galley.Options
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Error
import Polysemy.Input
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/MLS/Removal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import Galley.Effects.ProposalStore
import Galley.Effects.SubConversationStore
import Galley.Env
import Galley.Types.Conversations.Members
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Error
import Polysemy.Input
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/MLS/SubConversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import Galley.Effects
import Galley.Effects.FederatorAccess
import Galley.Effects.MemberStore qualified as Eff
import Galley.Effects.SubConversationStore qualified as Eff
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Error
import Polysemy.Input
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/MLS/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Data.Qualified
import GHC.Records (HasField (..))
import Galley.Data.Conversation.Types
import Galley.Types.Conversations.Members
import Imports hiding (cs)
import Imports
import Wire.API.Conversation
import Wire.API.Conversation.Protocol
import Wire.API.MLS.CipherSuite
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/MLS/Welcome.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Galley.API.Push
import Galley.Effects.ExternalAccess
import Galley.Effects.FederatorAccess
import Gundeck.Types.Push.V2 (RecipientClients (..))
import Imports hiding (cs)
import Imports
import Network.Wai.Utilities.JSONResponse
import Polysemy
import Polysemy.Input
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/API/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import Galley.Env
import Galley.Options
import Galley.Types.Conversations.Members
import Galley.Types.Teams
import Imports hiding (cs)
import Imports
import Network.Wai
import Network.Wai.Predicate hiding (Error, result, setStatus)
import Network.Wai.Utilities hiding (Error)
Expand Down
3 changes: 2 additions & 1 deletion services/galley/src/Galley/API/Teams/Features.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ where

import Control.Lens
import Data.ByteString.Conversion (toByteString')
import Data.ByteString.UTF8 qualified as UTF8
import Data.Id
import Data.Json.Util
import Data.Kind
Expand Down Expand Up @@ -204,7 +205,7 @@ pushFeatureConfigEvent tid event = do
P.warn $
Log.field "action" (Log.val "Features.pushFeatureConfigEvent")
. Log.field "feature" (Log.val (toByteString' . Event._eventFeatureName $ event))
. Log.field "team" (Log.val (cs . show $ tid))
. Log.field "team" (Log.val (UTF8.fromString . show $ tid))
. Log.msg @Text "Fanout limit exceeded. Events will not be sent."
else do
let recipients = membersToRecipients Nothing (memList ^. teamMembers)
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/Cassandra/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Galley.Effects.ConversationStore (ConversationStore (..))
import Galley.Types.Conversations.Members
import Galley.Types.ToUserRole
import Galley.Types.UserList
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Input
import Polysemy.TinyLog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Galley.Effects.MemberStore (MemberStore (..))
import Galley.Types.Conversations.Members
import Galley.Types.ToUserRole
import Galley.Types.UserList
import Imports hiding (Set, cs)
import Imports hiding (Set)
import Polysemy
import Polysemy.Input
import Polysemy.TinyLog
Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/Cassandra/Store.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Galley.Cassandra.Store
where

import Cassandra
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Input

Expand Down
2 changes: 1 addition & 1 deletion services/galley/src/Galley/Cassandra/SubConversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Galley.Cassandra.Queries qualified as Cql
import Galley.Cassandra.Store (embedClient)
import Galley.Cassandra.Util
import Galley.Effects.SubConversationStore (SubConversationStore (..))
import Imports hiding (cs)
import Imports
import Polysemy
import Polysemy.Input
import Polysemy.TinyLog
Expand Down
5 changes: 3 additions & 2 deletions services/galley/src/Galley/Intra/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import Data.ByteString.Char8 qualified as BSC
import Data.ByteString.Conversion
import Data.Id
import Data.Qualified
import Data.Text qualified as Text
import Data.Text.Lazy qualified as Lazy
import Galley.API.Error
import Galley.Env
Expand Down Expand Up @@ -253,11 +254,11 @@ runHereClientM action = do
mgr <- view manager
brigep <- view brig
let env = Client.mkClientEnv mgr baseurl
baseurl = Client.BaseUrl Client.Http (cs $ brigep ^. host) (fromIntegral $ brigep ^. port) ""
baseurl = Client.BaseUrl Client.Http (Text.unpack $ brigep ^. host) (fromIntegral $ brigep ^. port) ""
liftIO $ Client.runClientM action env

handleServantResp ::
Either Client.ClientError a ->
App a
handleServantResp (Right cfg) = pure cfg
handleServantResp (Left errmsg) = throwM . internalErrorWithDescription . cs . show $ errmsg
handleServantResp (Left errmsg) = throwM . internalErrorWithDescription . Lazy.pack . show $ errmsg
2 changes: 1 addition & 1 deletion services/galley/src/Galley/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Control.Lens
import Control.Monad.Catch
import Control.Monad.Except
import Galley.Env
import Imports hiding (cs, log)
import Imports hiding (log)
import Polysemy
import Polysemy.Input
import System.Logger
Expand Down
5 changes: 3 additions & 2 deletions services/galley/src/Galley/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Control.Exception (finally)
import Control.Lens (view, (.~), (^.))
import Control.Monad.Codensity
import Data.Aeson qualified as Aeson
import Data.ByteString.UTF8 qualified as UTF8
import Data.Id
import Data.Metrics (Metrics)
import Data.Metrics.AWS (gaugeTokenRemaing)
Expand Down Expand Up @@ -133,7 +134,7 @@ mkApp opts =
lookupReqId l r = case lookup requestIdName $ requestHeaders r of
Just rid -> pure $ RequestId rid
Nothing -> do
localRid <- RequestId . cs . UUID.toText <$> UUID.nextRandom
localRid <- RequestId . UUID.toASCIIBytes <$> UUID.nextRandom
Log.info l $
"request-id" .= localRid
~~ "method" .= requestMethod r
Expand All @@ -155,7 +156,7 @@ bodyParserErrorFormatter' :: Servant.ErrorFormatter
bodyParserErrorFormatter' _ _ errMsg =
Servant.ServerError
{ Servant.errHTTPCode = HTTP.statusCode HTTP.status400,
Servant.errReasonPhrase = cs $ HTTP.statusMessage HTTP.status400,
Servant.errReasonPhrase = UTF8.toString $ HTTP.statusMessage HTTP.status400,
Servant.errBody =
Aeson.encode $
Aeson.object
Expand Down
1 change: 1 addition & 0 deletions services/galley/test/integration/API/Federation/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ where
import Data.Kind
import Data.Qualified
import Data.SOP
import Data.String.Conversions
import GHC.TypeLits
import Imports
import Servant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import Data.List1 qualified as List1
import Data.Misc (PlainTextPassword6)
import Data.PEM
import Data.Streaming.Network (bindRandomPortTCP)
import Data.String.Conversions
import Data.Tagged
import Data.Text.Encoding (encodeUtf8)
import Galley.Options
Expand Down
1 change: 1 addition & 0 deletions services/galley/test/integration/API/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import Data.Range
import Data.Serialize (runPut)
import Data.Set qualified as Set
import Data.Singletons
import Data.String.Conversions
import Data.Text qualified as Text
import Data.Text.Encoding qualified as T
import Data.Text.Encoding qualified as Text
Expand Down

0 comments on commit 25315d6

Please sign in to comment.