{-# LANGUAGE TemplateHaskell #-}
module Galley.Options
( Settings (..),
httpPoolSize,
maxTeamSize,
maxFanoutSize,
exposeInvitationURLsTeamAllowlist,
maxConvSize,
intraListing,
disabledAPIVersions,
conversationCodeURI,
multiIngress,
concurrentDeletionEvents,
deleteConvThrottleMillis,
federationDomain,
mlsPrivateKeyPaths,
featureFlags,
defConcurrentDeletionEvents,
JournalOpts (JournalOpts),
queueName,
endpoint,
Opts (..),
galley,
cassandra,
brig,
gundeck,
spar,
federator,
rabbitmq,
discoUrl,
settings,
journal,
logLevel,
logNetStrings,
logFormat,
guestLinkTTLSeconds,
defGuestLinkTTLSeconds,
passwordHashingOptions,
GuestLinkTTLSeconds (..),
)
where
import Control.Lens hiding (Level, (.=))
import Data.Aeson (FromJSON (..))
import Data.Aeson.TH (deriveFromJSON)
import Data.Domain (Domain)
import Data.Id (TeamId)
import Data.Misc
import Data.Range
import Galley.Keys
import Galley.Types.Teams
import Imports
import Network.AMQP.Extended
import System.Logger.Extended (Level, LogFormat)
import Util.Options hiding (endpoint)
import Util.Options.Common
import Wire.API.Routes.Version
import Wire.API.Team.Member
newtype GuestLinkTTLSeconds = GuestLinkTTLSeconds
{ GuestLinkTTLSeconds -> Int
unGuestLinkTTLSeconds :: Int
}
deriving (Int -> GuestLinkTTLSeconds -> ShowS
[GuestLinkTTLSeconds] -> ShowS
GuestLinkTTLSeconds -> String
(Int -> GuestLinkTTLSeconds -> ShowS)
-> (GuestLinkTTLSeconds -> String)
-> ([GuestLinkTTLSeconds] -> ShowS)
-> Show GuestLinkTTLSeconds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuestLinkTTLSeconds -> ShowS
showsPrec :: Int -> GuestLinkTTLSeconds -> ShowS
$cshow :: GuestLinkTTLSeconds -> String
show :: GuestLinkTTLSeconds -> String
$cshowList :: [GuestLinkTTLSeconds] -> ShowS
showList :: [GuestLinkTTLSeconds] -> ShowS
Show, (forall x. GuestLinkTTLSeconds -> Rep GuestLinkTTLSeconds x)
-> (forall x. Rep GuestLinkTTLSeconds x -> GuestLinkTTLSeconds)
-> Generic GuestLinkTTLSeconds
forall x. Rep GuestLinkTTLSeconds x -> GuestLinkTTLSeconds
forall x. GuestLinkTTLSeconds -> Rep GuestLinkTTLSeconds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. GuestLinkTTLSeconds -> Rep GuestLinkTTLSeconds x
from :: forall x. GuestLinkTTLSeconds -> Rep GuestLinkTTLSeconds x
$cto :: forall x. Rep GuestLinkTTLSeconds x -> GuestLinkTTLSeconds
to :: forall x. Rep GuestLinkTTLSeconds x -> GuestLinkTTLSeconds
Generic)
instance FromJSON GuestLinkTTLSeconds where
parseJSON :: Value -> Parser GuestLinkTTLSeconds
parseJSON Value
x = do
Int
n <- Value -> Parser Int
forall a. FromJSON a => Value -> Parser a
parseJSON Value
x
if Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
0 Bool -> Bool -> Bool
&& Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
31536000
then GuestLinkTTLSeconds -> Parser GuestLinkTTLSeconds
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GuestLinkTTLSeconds -> Parser GuestLinkTTLSeconds)
-> GuestLinkTTLSeconds -> Parser GuestLinkTTLSeconds
forall a b. (a -> b) -> a -> b
$ Int -> GuestLinkTTLSeconds
GuestLinkTTLSeconds Int
n
else String -> Parser GuestLinkTTLSeconds
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"GuestLinkTTLSeconds must be in (0, 31536000]"
data Settings = Settings
{
Settings -> Int
_httpPoolSize :: !Int,
Settings -> Word32
_maxTeamSize :: !Word32,
Settings -> Maybe (Range 1 HardTruncationLimit Int32)
_maxFanoutSize :: !(Maybe (Range 1 HardTruncationLimit Int32)),
Settings -> Maybe [TeamId]
_exposeInvitationURLsTeamAllowlist :: !(Maybe [TeamId]),
Settings -> Word16
_maxConvSize :: !Word16,
Settings -> Bool
_intraListing :: !Bool,
Settings -> Maybe HttpsUrl
_conversationCodeURI :: !(Maybe HttpsUrl),
Settings -> Maybe (Map Text HttpsUrl)
_multiIngress :: Maybe (Map Text HttpsUrl),
Settings -> Maybe Int
_concurrentDeletionEvents :: !(Maybe Int),
Settings -> Maybe Int
_deleteConvThrottleMillis :: !(Maybe Int),
Settings -> Domain
_federationDomain :: !Domain,
Settings -> Maybe MLSPrivateKeyPaths
_mlsPrivateKeyPaths :: !(Maybe MLSPrivateKeyPaths),
Settings -> FeatureFlags
_featureFlags :: !FeatureFlags,
Settings -> Set VersionExp
_disabledAPIVersions :: !(Set VersionExp),
Settings -> Maybe GuestLinkTTLSeconds
_guestLinkTTLSeconds :: !(Maybe GuestLinkTTLSeconds),
Settings -> PasswordHashingOptions
_passwordHashingOptions :: !(PasswordHashingOptions)
}
deriving (Int -> Settings -> ShowS
[Settings] -> ShowS
Settings -> String
(Int -> Settings -> ShowS)
-> (Settings -> String) -> ([Settings] -> ShowS) -> Show Settings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Settings -> ShowS
showsPrec :: Int -> Settings -> ShowS
$cshow :: Settings -> String
show :: Settings -> String
$cshowList :: [Settings] -> ShowS
showList :: [Settings] -> ShowS
Show, (forall x. Settings -> Rep Settings x)
-> (forall x. Rep Settings x -> Settings) -> Generic Settings
forall x. Rep Settings x -> Settings
forall x. Settings -> Rep Settings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Settings -> Rep Settings x
from :: forall x. Settings -> Rep Settings x
$cto :: forall x. Rep Settings x -> Settings
to :: forall x. Rep Settings x -> Settings
Generic)
deriveFromJSON toOptionFieldName ''Settings
makeLenses ''Settings
defConcurrentDeletionEvents :: Int
defConcurrentDeletionEvents :: Int
defConcurrentDeletionEvents = Int
128
defGuestLinkTTLSeconds :: GuestLinkTTLSeconds
defGuestLinkTTLSeconds :: GuestLinkTTLSeconds
defGuestLinkTTLSeconds = Int -> GuestLinkTTLSeconds
GuestLinkTTLSeconds (Int -> GuestLinkTTLSeconds) -> Int -> GuestLinkTTLSeconds
forall a b. (a -> b) -> a -> b
$ Int
60 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
60 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
365
data JournalOpts = JournalOpts
{
JournalOpts -> Text
_queueName :: !Text,
JournalOpts -> AWSEndpoint
_endpoint :: !AWSEndpoint
}
deriving (Int -> JournalOpts -> ShowS
[JournalOpts] -> ShowS
JournalOpts -> String
(Int -> JournalOpts -> ShowS)
-> (JournalOpts -> String)
-> ([JournalOpts] -> ShowS)
-> Show JournalOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> JournalOpts -> ShowS
showsPrec :: Int -> JournalOpts -> ShowS
$cshow :: JournalOpts -> String
show :: JournalOpts -> String
$cshowList :: [JournalOpts] -> ShowS
showList :: [JournalOpts] -> ShowS
Show, (forall x. JournalOpts -> Rep JournalOpts x)
-> (forall x. Rep JournalOpts x -> JournalOpts)
-> Generic JournalOpts
forall x. Rep JournalOpts x -> JournalOpts
forall x. JournalOpts -> Rep JournalOpts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. JournalOpts -> Rep JournalOpts x
from :: forall x. JournalOpts -> Rep JournalOpts x
$cto :: forall x. Rep JournalOpts x -> JournalOpts
to :: forall x. Rep JournalOpts x -> JournalOpts
Generic)
deriveFromJSON toOptionFieldName ''JournalOpts
makeLenses ''JournalOpts
data Opts = Opts
{
Opts -> Endpoint
_galley :: !Endpoint,
Opts -> CassandraOpts
_cassandra :: !CassandraOpts,
Opts -> Endpoint
_brig :: !Endpoint,
Opts -> Endpoint
_gundeck :: !Endpoint,
Opts -> Endpoint
_spar :: !Endpoint,
Opts -> Maybe Endpoint
_federator :: !(Maybe Endpoint),
Opts -> Maybe AmqpEndpoint
_rabbitmq :: !(Maybe AmqpEndpoint),
Opts -> Maybe Text
_discoUrl :: !(Maybe Text),
Opts -> Settings
_settings :: !Settings,
Opts -> Maybe JournalOpts
_journal :: !(Maybe JournalOpts),
Opts -> Level
_logLevel :: !Level,
Opts -> Maybe (Last Bool)
_logNetStrings :: !(Maybe (Last Bool)),
Opts -> Maybe (Last LogFormat)
_logFormat :: !(Maybe (Last LogFormat))
}
deriveFromJSON toOptionFieldName ''Opts
makeLenses ''Opts