Skip to content

Commit 7e76125

Browse files
authored
Conference call initiation flag for personal accounts (#1811)
* New behavior of `GET /feature-configs*`. * Cassandra migration: personal account feature "conf call init". * Clean up after ormolu. * Add optSettings.featureFlags.conferenceCalling to brig.yaml. With default for NULL and default for new records. * Internal brig PUT/GET/DELETE end-points for account features. * Move brig's internal servant api to wire-api. * Integration tests. * Hard-wired default for all account features should be "enabled".
1 parent 428a9e5 commit 7e76125

File tree

37 files changed

+728
-222
lines changed

37 files changed

+728
-222
lines changed

changelog.d/2-features/pr-1811

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Per-account configuration of conference call initiation (details: /docs/reference/config-options.md#conference-calling-1)

docs/reference/cassandra-schema.cql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ CREATE TABLE brig_test.user (
10581058
country ascii,
10591059
email text,
10601060
expires timestamp,
1061+
feature_conference_calling int,
10611062
handle text,
10621063
language ascii,
10631064
managed_by int,

docs/reference/config-options.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Fragment.
55
This page is about the yaml files that determine the configuration of
66
the Wire backend services.
77

8-
## Settings
8+
## Settings in galley
99

1010
```
1111
# [galley.yaml]
@@ -141,6 +141,8 @@ conferenceCalling:
141141

142142
The `conferenceCalling` section is optional in `featureFlags`. If it is omitted then it is assumed to be `enabled`.
143143

144+
See also: conference falling for personal accounts (below).
145+
144146
### File Sharing
145147

146148
File sharing is enabled by default. If you want to disable it for all teams, add this to your feature config settings:
@@ -270,3 +272,40 @@ federator:
270272
clientCertificate: client.pem
271273
clientPrivateKey: client-key.pem
272274
```
275+
276+
## Settings in brig
277+
278+
Some features (as of the time of writing this: only
279+
`conferenceCalling`) allow to set defaults for personal accounts in
280+
brig. Those are taken into account in galley's end-points `GET
281+
/feature-configs*`.
282+
283+
To be specific:
284+
285+
### Conference Calling
286+
287+
Two values can be configured for personal accounts: a default for when
288+
the user record contains `null` as feature config, and default that
289+
should be inserted into the user record when creating new users:
290+
291+
```
292+
# [brig.yaml]
293+
settings:
294+
setFeatureFlags:
295+
conferenceCalling:
296+
defaultForNew:
297+
status: disabled
298+
defaultForNull:
299+
status: enabled
300+
```
301+
302+
You can omit the entire `conferenceCalling` block, but not parts of
303+
it. Built-in defaults are as above.
304+
305+
When new users are created, their config will be initialized with
306+
what's in `defaultForNew`.
307+
308+
When a `null` value is encountered, it is assumed to be
309+
`defaultForNull`.
310+
311+
(Introduced in https://github.com/wireapp/wire-server/pull/1811.)

libs/brig-types/brig-types.cabal

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: 2b3c91a37e09e61ca32cf32ab80c46e8f019926c78165bec82d9c84a5b8d20a6
7+
-- hash: 42d648b07cd5a5d45e2ca36fd4631c37047fc74aea88fce77073a3efa99327a2
88

99
name: brig-types
1010
version: 1.35.0
@@ -40,7 +40,6 @@ library
4040
Brig.Types.Test.Arbitrary
4141
Brig.Types.User
4242
Brig.Types.User.Auth
43-
Brig.Types.User.EJPD
4443
Brig.Types.User.Event
4544
other-modules:
4645
Paths_brig_types

libs/brig-types/test/unit/Test/Brig/Types/User.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ module Test.Brig.Types.User where
3030
import Brig.Types.Connection (UpdateConnectionsInternal (..))
3131
import Brig.Types.Intra (NewUserScimInvitation (..), ReAuthUser (..))
3232
import Brig.Types.User (ManagedByUpdate (..), RichInfoUpdate (..))
33-
import Brig.Types.User.EJPD (EJPDRequestBody (..), EJPDResponseBody (..))
3433
import Imports
3534
import Test.Brig.Roundtrip (testRoundTrip, testRoundTripWithSwagger)
3635
import Test.QuickCheck (Arbitrary (arbitrary))
3736
import Test.Tasty
37+
import Wire.API.Routes.Internal.Brig.EJPD (EJPDRequestBody (..), EJPDResponseBody (..))
3838

3939
tests :: TestTree
4040
tests = testGroup "User (types vs. aeson)" $ roundtripTests

libs/wire-api/package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies:
1313
- containers >=0.5
1414
- imports
1515
- types-common >=0.16
16+
- servant-swagger-ui
1617
- case-insensitive
1718
- hscim
1819
library:
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
-- This file is part of the Wire Server implementation.
2+
--
3+
-- Copyright (C) 2020 Wire Swiss GmbH <[email protected]>
4+
--
5+
-- This program is free software: you can redistribute it and/or modify it under
6+
-- the terms of the GNU Affero General Public License as published by the Free
7+
-- Software Foundation, either version 3 of the License, or (at your option) any
8+
-- later version.
9+
--
10+
-- This program is distributed in the hope that it will be useful, but WITHOUT
11+
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12+
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13+
-- details.
14+
--
15+
-- You should have received a copy of the GNU Affero General Public License along
16+
-- with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
module Wire.API.Routes.Internal.Brig
19+
( API,
20+
SwaggerDocsAPI,
21+
swaggerDoc,
22+
module Wire.API.Routes.Internal.Brig.EJPD,
23+
)
24+
where
25+
26+
import Control.Lens ((.~))
27+
import Data.Id as Id
28+
import Data.Swagger (HasInfo (info), HasTitle (title), Swagger)
29+
import Imports hiding (head)
30+
import Servant hiding (Handler, JSON, addHeader, respond)
31+
import qualified Servant
32+
import Servant.Swagger (HasSwagger (toSwagger))
33+
import Servant.Swagger.Internal.Orphans ()
34+
import Servant.Swagger.UI
35+
import Wire.API.Routes.Internal.Brig.EJPD
36+
import qualified Wire.API.Team.Feature as ApiFt
37+
38+
type EJPDRequest =
39+
Summary
40+
"Identify users for law enforcement. Wire has legal requirements to cooperate \
41+
\with the authorities. The wire backend operations team uses this to answer \
42+
\identification requests manually. It is our best-effort representation of the \
43+
\minimum required information we need to hand over about targets and (in some \
44+
\cases) their communication peers. For more information, consult ejpd.admin.ch."
45+
:> "ejpd-request"
46+
:> QueryParam'
47+
[ Optional,
48+
Strict,
49+
Description "Also provide information about all contacts of the identified users"
50+
]
51+
"include_contacts"
52+
Bool
53+
:> Servant.ReqBody '[Servant.JSON] EJPDRequestBody
54+
:> Post '[Servant.JSON] EJPDResponseBody
55+
56+
type GetAccountFeatureConfig =
57+
Summary
58+
"Read cassandra field 'brig.user.feature_conference_calling'"
59+
:> "users"
60+
:> Capture "uid" UserId
61+
:> "features"
62+
:> "conferenceCalling"
63+
:> Get '[Servant.JSON] (ApiFt.TeamFeatureStatus 'ApiFt.TeamFeatureConferenceCalling)
64+
65+
type PutAccountFeatureConfig =
66+
Summary
67+
"Write to cassandra field 'brig.user.feature_conference_calling'"
68+
:> "users"
69+
:> Capture "uid" UserId
70+
:> "features"
71+
:> "conferenceCalling"
72+
:> Servant.ReqBody '[Servant.JSON] (ApiFt.TeamFeatureStatus 'ApiFt.TeamFeatureConferenceCalling)
73+
:> Put '[Servant.JSON] NoContent
74+
75+
type DeleteAccountFeatureConfig =
76+
Summary
77+
"Reset cassandra field 'brig.user.feature_conference_calling' to 'null'"
78+
:> "users"
79+
:> Capture "uid" UserId
80+
:> "features"
81+
:> "conferenceCalling"
82+
:> Delete '[Servant.JSON] NoContent
83+
84+
type API =
85+
"i"
86+
:> ( EJPDRequest
87+
:<|> GetAccountFeatureConfig
88+
:<|> PutAccountFeatureConfig
89+
:<|> DeleteAccountFeatureConfig
90+
)
91+
92+
type SwaggerDocsAPI = "api" :> "internal" :> SwaggerSchemaUI "swagger-ui" "swagger.json"
93+
94+
swaggerDoc :: Swagger
95+
swaggerDoc =
96+
toSwagger (Proxy @API)
97+
& info . title .~ "Wire-Server API as Swagger 2.0 (internal end-points; incomplete) "

libs/brig-types/src/Brig/Types/User/EJPD.hs renamed to libs/wire-api/src/Wire/API/Routes/Internal/Brig/EJPD.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
-- | Identify users for law enforcement. (Wire has legal requirements to cooperate with the
1919
-- authorities. The wire backend operations team uses this to answer identification requests
2020
-- manually.)
21-
module Brig.Types.User.EJPD
21+
module Wire.API.Routes.Internal.Brig.EJPD
2222
( EJPDRequestBody (EJPDRequestBody, ejpdRequestBody),
2323
EJPDResponseBody (EJPDResponseBody, ejpdResponseBody),
2424
EJPDResponseItem (EJPDResponseItem, ejpdResponseHandle, ejpdResponsePushTokens, ejpdResponseContacts),

libs/wire-api/src/Wire/API/Team/Feature.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module Wire.API.Team.Feature
4545
)
4646
where
4747

48+
import qualified Cassandra.CQL as Cass
4849
import Control.Lens.Combinators (dimap)
4950
import qualified Data.Aeson as Aeson
5051
import qualified Data.Attoparsec.ByteString as Parser
@@ -254,6 +255,18 @@ instance FromByteString TeamFeatureStatusValue where
254255
Right t -> fail $ "Invalid TeamFeatureStatusValue: " <> T.unpack t
255256
Left e -> fail $ "Invalid TeamFeatureStatusValue: " <> show e
256257

258+
instance Cass.Cql TeamFeatureStatusValue where
259+
ctype = Cass.Tagged Cass.IntColumn
260+
261+
fromCql (Cass.CqlInt n) = case n of
262+
0 -> pure $ TeamFeatureDisabled
263+
1 -> pure $ TeamFeatureEnabled
264+
_ -> Left "fromCql: Invalid TeamFeatureStatusValue"
265+
fromCql _ = Left "fromCql: TeamFeatureStatusValue: CqlInt expected"
266+
267+
toCql TeamFeatureDisabled = Cass.CqlInt 0
268+
toCql TeamFeatureEnabled = Cass.CqlInt 1
269+
257270
----------------------------------------------------------------------
258271
-- TeamFeatureStatus
259272

libs/wire-api/wire-api.cabal

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: ec0f1e0e3e31d5771b93db6b6ee37ad444f98c3213696e98bbedbb4b1bb56c8c
7+
-- hash: 9d49a92f6ad563b050a6e3e6ae7f68b8abda7fa71e1986573cd81edf97d7b508
88

99
name: wire-api
1010
version: 0.1.0
@@ -49,6 +49,8 @@ library
4949
Wire.API.Provider.Service.Tag
5050
Wire.API.Push.Token
5151
Wire.API.Push.V2.Token
52+
Wire.API.Routes.Internal.Brig
53+
Wire.API.Routes.Internal.Brig.EJPD
5254
Wire.API.Routes.MultiTablePaging
5355
Wire.API.Routes.MultiTablePaging.State
5456
Wire.API.Routes.MultiVerb
@@ -152,6 +154,7 @@ library
152154
, servant-multipart
153155
, servant-server
154156
, servant-swagger
157+
, servant-swagger-ui
155158
, singletons
156159
, sop-core
157160
, string-conversions
@@ -450,6 +453,7 @@ test-suite wire-api-tests
450453
, pem
451454
, pretty
452455
, proto-lens
456+
, servant-swagger-ui
453457
, string-conversions
454458
, swagger2
455459
, tasty

0 commit comments

Comments
 (0)