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/0-release-notes/pr-2028
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The brig server config option `setDefaultLocale` has been replaced by `setDefaultUserLocale` and `setDefaultTemplateLocale` (see docs/reference/config-options.md for details)
1 change: 1 addition & 0 deletions changelog.d/2-features/pr-2028
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Specialize `setDefaultLocale` to distinguish between default user locale and default template locale if the user's locale is n/a.
3 changes: 2 additions & 1 deletion charts/brig/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ data:
suspendTimeout: {{ .setSuspendInactiveUsers.suspendTimeout }}
{{- end }}
setRichInfoLimit: {{ .setRichInfoLimit }}
setDefaultLocale: {{ .setDefaultLocale }}
setDefaultTemplateLocale: en
setDefaultUserLocale: {{ .setDefaultUserLocale }}
setMaxTeamSize: {{ .setMaxTeamSize }}
setMaxConvSize: {{ .setMaxConvSize }}
setEmailVisibility: {{ .setEmailVisibility }}
Expand Down
4 changes: 2 additions & 2 deletions charts/brig/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ config:
legalholdUserTokenTimeout: 4838400
legalholdAccessTokenTimeout: 900
optSettings:
setDefaultLocale: en
setActivationTimeout: 1209600
setTeamInvitationTimeout: 1814400
setUserMaxConnections: 1000
Expand All @@ -64,7 +63,8 @@ config:
stdDev: 3000
retryAfter: 86400
setRichInfoLimit: 5000
setDefaultLocale: en
setDefaultTemplateLocale: en
setDefaultUserLocale: en
setMaxTeamSize: 500
setMaxConvSize: 500
# Allowed values: https://github.com/wireapp/wire-server/blob/0126651a25aabc0c5589edc2b1988bb06550a03a/services/brig/src/Brig/Options.hs#L304-L306
Expand Down
3 changes: 2 additions & 1 deletion deploy/services-demo/conf/brig.demo-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ optSettings:
stdDev: 3000 # 50 minutes
retryAfter: 86400 # 1 day
setRichInfoLimit: 5000 # should be in sync with Spar
setDefaultLocale: en
setDefaultTemplateLocale: en
setDefaultUserLocale: en
setMaxTeamSize: 128
setMaxConvSize: 128
setEmailVisibility: visible_to_self
Expand Down
3 changes: 2 additions & 1 deletion deploy/services-demo/conf/brig.demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ optSettings:
stdDev: 3000 # 50 minutes
retryAfter: 86400 # 1 day
setRichInfoLimit: 5000 # should be in sync with Spar
setDefaultLocale: en
setDefaultTemplateLocale: en
setDefaultUserLocale: en
setMaxTeamSize: 128
setMaxConvSize: 128
setEmailVisibility: visible_to_self
Expand Down
27 changes: 27 additions & 0 deletions docs/reference/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,30 @@ When a `null` value is encountered, it is assumed to be
`defaultForNull`.

(Introduced in https://github.com/wireapp/wire-server/pull/1811.)

### Locale


#### setDefaultLocale (deprecated / ignored)

The brig server config option `setDefaultLocale` has been replaced by `setDefaultUserLocale` and `setDefaultTemplateLocale`. Both settings are optional and `setDefaultTemplateLocale` defaults to `EN` and `setDefaultLocale` defaults to `setDefaultTemplateLocale`. If `setDefaultLocale` was not set or set to `EN` before this change, nothing needs to be done. If `setDefaultLocale` was set to any other language other than `EN` the name of the setting should be changed to `setDefaultTemplateLocale`.

#### `setDefaultTemplateLocale`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which templates are actually complete in wire-server other than EN? i.e. this settings can't be set to anything other than EN at this point in time unless more templates are provided inside wire-server's brig/deb/templates folder, right? Perhaps the description here should make that clearer.


This option determines the default locale for email templates. The language of the email communication is determined by the user locale (see above). Only if templates of the the locale of the user do not exist or if user locale is not set the `setDefaultTemplateLocale` is used as a fallback. If not set the default is `EN`. This setting should not be changed unless a complete set of templates is available for the given language.

```
# [brig.yaml]
optSettings:
setDefaultTemplateLocale: en
```

#### `setDefaultUserLocale`

This option is the default user locale to be used if it is not set in the user profile. This can be the case if the users are provisioned by SCIM e.g. This option determines which language to use for email communication. If not set the default is the value that is configured for `setDefaultTemplateLocale`.

```
# [brig.yaml]
optSettings:
setDefaultUserLocale: en
```
3 changes: 2 additions & 1 deletion hack/helm_vars/wire-server/values.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ brig:
retryLimit: 5 # how many times can you have a failed login in that timeframe.
setSuspendInactiveUsers:
suspendTimeout: 10
setDefaultLocale: en
setDefaultTemplateLocale: en
setDefaultUserLocale: en
setMaxConvAndTeamSize: 16
setMaxTeamSize: 32
setMaxConvSize: 16
Expand Down
3 changes: 2 additions & 1 deletion services/brig/brig.integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ optSettings:
setSuspendInactiveUsers: # if this is omitted: never suspend inactive users.
suspendTimeout: 10
setRichInfoLimit: 5000 # should be in sync with Spar
setDefaultLocale: en
setDefaultTemplateLocale: en
setDefaultUserLocale: en
setMaxTeamSize: 32
setMaxConvSize: 16
setEmailVisibility: visible_to_self
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/API/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ deleteAccount account@(accountUser -> user) = do
revokeAllCookies uid
where
mkTombstone = do
defLoc <- setDefaultLocale <$> view settings
defLoc <- setDefaultUserLocale <$> view settings
return $
account
{ accountStatus = Deleted,
Expand Down
12 changes: 6 additions & 6 deletions services/brig/src/Brig/Data/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ data ReAuthError
-- there, it was claimed properly.
newAccount :: NewUser -> Maybe InvitationId -> Maybe TeamId -> Maybe Handle -> AppIO (UserAccount, Maybe Password)
newAccount u inv tid mbHandle = do
defLoc <- setDefaultLocale <$> view settings
defLoc <- setDefaultUserLocale <$> view settings
domain <- viewFederationDomain
uid <-
Id <$> do
Expand All @@ -132,7 +132,7 @@ newAccount u inv tid mbHandle = do
-- Ephemeral users' expiry time is in expires_in (default sessionTokenTimeout) seconds
e <- view zauthEnv
let ZAuth.SessionTokenTimeout defTTL = e ^. ZAuth.settings . ZAuth.sessionTokenTimeout
ttl = fromMaybe defTTL (fromRange <$> newUserExpiresIn u)
ttl = maybe defTTL fromRange (newUserExpiresIn u)
now <- liftIO =<< view currentTime
return . Just . toUTCTimeMillis $ addUTCTime (fromIntegral ttl) now
_ -> return Nothing
Expand All @@ -154,7 +154,7 @@ newAccount u inv tid mbHandle = do

newAccountInviteViaScim :: UserId -> TeamId -> Maybe Locale -> Name -> Email -> AppIO UserAccount
newAccountInviteViaScim uid tid locale name email = do
defLoc <- setDefaultLocale <$> view settings
defLoc <- setDefaultUserLocale <$> view settings
domain <- viewFederationDomain
return (UserAccount (user domain (fromMaybe defLoc locale)) PendingInvitation)
where
Expand Down Expand Up @@ -370,7 +370,7 @@ deactivateUser u =

lookupLocale :: UserId -> AppIO (Maybe Locale)
lookupLocale u = do
defLoc <- setDefaultLocale <$> view settings
defLoc <- setDefaultUserLocale <$> view settings
fmap (toLocale defLoc) <$> retry x1 (query1 localeSelect (params LocalQuorum (Identity u)))

lookupName :: UserId -> AppIO (Maybe Name)
Expand Down Expand Up @@ -417,7 +417,7 @@ lookupAuth u = fmap f <$> retry x1 (query1 authSelect (params LocalQuorum (Ident
-- Skips nonexistent users. /Does not/ skip users who have been deleted.
lookupUsers :: HavePendingInvitations -> [UserId] -> AppIO [User]
lookupUsers hpi usrs = do
loc <- setDefaultLocale <$> view settings
loc <- setDefaultUserLocale <$> view settings
domain <- viewFederationDomain
toUsers domain loc hpi <$> retry x1 (query usersSelect (params LocalQuorum (Identity usrs)))

Expand All @@ -426,7 +426,7 @@ lookupAccount u = listToMaybe <$> lookupAccounts [u]

lookupAccounts :: [UserId] -> AppIO [UserAccount]
lookupAccounts usrs = do
loc <- setDefaultLocale <$> view settings
loc <- setDefaultUserLocale <$> view settings
domain <- viewFederationDomain
fmap (toUserAccount domain loc) <$> retry x1 (query accountsSelect (params LocalQuorum (Identity usrs)))

Expand Down
38 changes: 32 additions & 6 deletions services/brig/src/Brig/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import Brig.Types
import Brig.User.Auth.Cookie.Limit
import Brig.Whitelist (Whitelist (..))
import qualified Brig.ZAuth as ZAuth
import Control.Applicative
import qualified Control.Lens as Lens
import Data.Aeson (withText)
import Data.Aeson (defaultOptions, fieldLabelModifier, genericParseJSON, withText)
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (typeMismatch)
import qualified Data.Char as Char
import Data.Domain (Domain (..))
import Data.Id
import Data.LanguageCodes (ISO639_1 (EN))
import Data.Misc (HttpsUrl)
import Data.Range
import Data.Scientific (toBoundedInteger)
Expand Down Expand Up @@ -439,9 +441,12 @@ data Settings = Settings
-- field names and values), should be in sync
-- with Spar
setRichInfoLimit :: !Int,
-- | Default locale to use
-- (e.g. when selecting templates)
setDefaultLocale :: !Locale,
-- | Default locale to use when selecting templates
-- use `setDefaultTemplateLocale` as the getter function which always provides a default value
setDefaultTemplateLocaleInternal :: !(Maybe Locale),
-- | Default locale to use for users
-- use `setDefaultUserLocale` as the getter function which always provides a default value
setDefaultUserLocaleInternal :: !(Maybe Locale),
-- | Max. # of members in a team.
-- NOTE: This must be in sync with galley
setMaxTeamSize :: !Word32,
Expand Down Expand Up @@ -474,7 +479,7 @@ data Settings = Settings
-- setFederationAllowedDomains:
-- - wire.com
-- - example.com
setFederationDomain :: !(Domain),
setFederationDomain :: !Domain,
-- | The amount of time in milliseconds to wait after reading from an SQS queue
-- returns no message, before asking for messages from SQS again.
-- defaults to 'defSqsThrottleMillis'.
Expand All @@ -499,6 +504,18 @@ data Settings = Settings
}
deriving (Show, Generic)

defaultTemplateLocale :: Locale
defaultTemplateLocale = Locale (Language EN) Nothing

defaultUserLocale :: Locale
defaultUserLocale = defaultTemplateLocale

setDefaultUserLocale :: Settings -> Locale
setDefaultUserLocale = fromMaybe defaultUserLocale . setDefaultUserLocaleInternal

setDefaultTemplateLocale :: Settings -> Locale
setDefaultTemplateLocale = fromMaybe defaultTemplateLocale . setDefaultTemplateLocaleInternal

-- | The analog to `GT.FeatureFlags`. This type tracks only the things that we need to
-- express our current cloud business logic.
--
Expand Down Expand Up @@ -664,7 +681,16 @@ instance FromJSON Timeout where
maybe defaultV fromIntegral bounded
parseJSON v = typeMismatch "activationTimeout" v

instance FromJSON Settings
instance FromJSON Settings where
parseJSON = genericParseJSON customOptions
where
customOptions =
defaultOptions
{ fieldLabelModifier = \case
"setDefaultUserLocaleInternal" -> "setDefaultUserLocale"
"setDefaultTemplateLocaleInternal" -> "setDefaultTemplateLocale"
other -> other
}

instance FromJSON Opts

Expand Down
4 changes: 2 additions & 2 deletions services/brig/src/Brig/Provider/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ addBot zuid zcon cid add = do
let botReq = Ext.NewBotRequest bid bcl busr bcnv btk bloc
rs <- RPC.createBot scon botReq !>> StdError . serviceError
-- Insert the bot user and client
locale <- setDefaultLocale <$> view settings
locale <- Opt.setDefaultUserLocale <$> view settings
let name = fromMaybe (serviceProfileName svp) (Ext.rsNewBotName rs)
let assets = fromMaybe (serviceProfileAssets svp) (Ext.rsNewBotAssets rs)
let colour = fromMaybe defaultAccentId (Ext.rsNewBotColour rs)
Expand All @@ -858,7 +858,7 @@ addBot zuid zcon cid add = do
{ newClientPrekeys = Ext.rsNewBotPrekeys rs
}
lift $ User.insertAccount (UserAccount usr Active) (Just (cid, cnvTeam cnv)) Nothing True
maxPermClients <- fromMaybe Opt.defUserMaxPermClients <$> Opt.setUserMaxPermClients <$> view settings
maxPermClients <- fromMaybe Opt.defUserMaxPermClients . Opt.setUserMaxPermClients <$> view settings
(clt, _, _) <- do
_ <- do
-- if we want to protect bots against lh, 'addClient' cannot just send lh capability
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/Provider/Template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ loadProviderTemplates o = readLocalesDir defLocale (templateDir gOptions) "provi
maybeUrl = fromByteString $ encodeUtf8 $ homeUrl pOptions
gOptions = general $ emailSMS o
pOptions = provider $ emailSMS o
defLocale = setDefaultLocale (optSettings o)
defLocale = setDefaultTemplateLocale (optSettings o)
readTemplate = readTemplateWithDefault (templateDir gOptions) defLocale "provider"
readText = readTextWithDefault (templateDir gOptions) defLocale "provider"
-- URL templates
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/Team/Template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ loadTeamTemplates o = readLocalesDir defLocale (templateDir gOptions) "team" $ \
gOptions = general (emailSMS o)
tOptions = team (emailSMS o)
tUrl = template $ tInvitationUrl tOptions
defLocale = setDefaultLocale (optSettings o)
defLocale = setDefaultTemplateLocale (optSettings o)
readTemplate = readTemplateWithDefault (templateDir gOptions) defLocale "team"
readText = readTextWithDefault (templateDir gOptions) defLocale "team"
2 changes: 1 addition & 1 deletion services/brig/src/Brig/User/Template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ loadUserTemplates o = readLocalesDir defLocale templateDir "user" $ \fp ->
teamActivationUrl = template $ Opt.tActivationUrl tOptions
passwordResetUrl = template $ Opt.passwordResetUrl uOptions
deletionUserUrl = template $ Opt.deletionUrl uOptions
defLocale = Opt.setDefaultLocale (Opt.optSettings o)
defLocale = Opt.setDefaultTemplateLocale (Opt.optSettings o)
templateDir = Opt.templateDir gOptions
readTemplate = readTemplateWithDefault templateDir defLocale "user"
readText = readTextWithDefault templateDir defLocale "user"