Skip to content

Commit

Permalink
Merge pull request #1101 from wireapp/release_2020_05_15
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaymankar authored May 15, 2020
2 parents eede068 + 2925854 commit 31bf2f6
Show file tree
Hide file tree
Showing 130 changed files with 13,318 additions and 8,919 deletions.
1 change: 1 addition & 0 deletions .headroom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ source-paths:
- tools
excluded-paths:
- '\.stack-work'
- '\.stack-docker'
template-paths:
- tools/headroom-templates
variables:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 2020-05-15

## New Features

* Add tool to migrate data for galley (#1096)
This can be used in a more automated way than the backfill-billing-team-member.
It should be done as a step after deployment.

## Internal Changes

* More tests for OTR messages using protobuf (#1095)
* Set brig's logLevel to Warn while running integration-tests (#1099)
* Refactor: Create wire-api package for types used in the public API (#1090)

# 2020-05-07

## Upgrade steps (IMPORTANT)
Expand Down
7 changes: 4 additions & 3 deletions libs/brig-types/brig-types.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 67eab80b4b772b485785e77f0ba45811541ed4ac1eac935cf47bfaee4837ec55
-- hash: 7708c6030d7990cd7a7a608b49f061bb4e8bbc8e367b3dd33884c75143841366

name: brig-types
version: 1.35.0
Expand Down Expand Up @@ -39,7 +39,6 @@ library
Brig.Types.Team.LegalHold
Brig.Types.Test.Arbitrary
Brig.Types.TURN
Brig.Types.TURN.Internal
Brig.Types.User
Brig.Types.User.Auth
other-modules:
Expand Down Expand Up @@ -78,13 +77,15 @@ library
, safe >=0.3
, scientific >=0.3.4
, singletons >=2.0
, string-conversions
, swagger >=0.1
, text >=0.11
, time >=1.1
, types-common >=0.16
, unordered-containers >=0.2
, uri-bytestring
, uuid >=1.3
, wire-api
default-language: Haskell2010

test-suite brig-types-tests
Expand All @@ -94,7 +95,6 @@ test-suite brig-types-tests
Test.Brig.Roundtrip
Test.Brig.Types.Common
Test.Brig.Types.Team
Test.Brig.Types.TURN
Test.Brig.Types.User
Paths_brig_types
hs-source-dirs:
Expand Down Expand Up @@ -131,4 +131,5 @@ test-suite brig-types-tests
, uri-bytestring
, uuid
, vector
, wire-api
default-language: Haskell2010
2 changes: 2 additions & 0 deletions libs/brig-types/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- hostname-validate
- lens
- imports
- wire-api
library:
source-dirs: src
ghc-options:
Expand Down Expand Up @@ -43,6 +44,7 @@ library:
- safe >=0.3
- scientific >=0.3.4
- singletons >=2.0
- string-conversions
- swagger >=0.1
- text >=0.11
- time >=1.1
Expand Down
116 changes: 10 additions & 106 deletions libs/brig-types/src/Brig/Types/Activation.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2020 Wire Swiss GmbH <[email protected]>
Expand All @@ -19,114 +16,21 @@
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Brig.Types.Activation
( module Brig.Types.Activation,
( ActivationPair,

-- * re-exports
module C,
ActivationKey (..),
ActivationCode (..),
Activate (..),
ActivationTarget (..),
ActivationResponse (..),
SendActivationCode (..),
)
where

import Brig.Types.Common as C
import Data.Aeson
import Data.ByteString.Conversion
import Data.Json.Util ((#))
import Data.Text.Ascii
import Imports

-- | An opaque identifier of a 'UserKey' awaiting activation.
newtype ActivationKey = ActivationKey
{fromActivationKey :: AsciiBase64Url}
deriving (Eq, Show, FromByteString, ToByteString, FromJSON, ToJSON, Generic)

-- | A random code for use with an 'ActivationKey' that is usually transmitted
-- out-of-band, e.g. via email or sms.
newtype ActivationCode = ActivationCode
{fromActivationCode :: AsciiBase64Url}
deriving (Eq, Show, FromByteString, ToByteString, FromJSON, ToJSON, Generic)
import Wire.API.User.Activation

-- | A pair of 'ActivationKey' and 'ActivationCode' as required for activation.
type ActivationPair = (ActivationKey, ActivationCode)

-- | Data for an activation request.
data Activate = Activate
{ activateTarget :: !ActivationTarget,
activateCode :: !ActivationCode,
activateDryrun :: !Bool
}

-- | The target of an activation request.
data ActivationTarget
= -- | An opaque key for some email or phone number awaiting activation.
ActivateKey !ActivationKey
| -- | A known phone number awaiting activation.
ActivatePhone !Phone
| -- | A known email address awaiting activation.
ActivateEmail !Email

instance ToByteString ActivationTarget where
builder (ActivateKey k) = builder k
builder (ActivateEmail e) = builder e
builder (ActivatePhone p) = builder p

-- | Information returned as part of a successful activation.
data ActivationResponse = ActivationResponse
{ -- | The activated / verified user identity.
activatedIdentity :: !UserIdentity,
-- | Whether this is the first verified identity of the account.
activatedFirst :: !Bool
}

-- | Payload for a request to (re-)send an activation code
-- for a phone number or e-mail address. If a phone is used,
-- one can also request a call instead of SMS.
data SendActivationCode = SendActivationCode
{ saUserKey :: !(Either Email Phone),
saLocale :: !(Maybe Locale),
saCall :: !Bool
}

-- * JSON Instances:

instance FromJSON SendActivationCode where
parseJSON = withObject "SendActivationCode" $ \o -> do
e <- o .:? "email"
p <- o .:? "phone"
SendActivationCode <$> key e p
<*> o .:? "locale"
<*> o .:? "voice_call" .!= False
where
key (Just _) (Just _) = fail "Only one of 'email' or 'phone' allowed."
key Nothing Nothing = fail "One of 'email' or 'phone' required."
key (Just e) Nothing = return $ Left e
key Nothing (Just p) = return $ Right p

instance ToJSON ActivationResponse where
toJSON (ActivationResponse ident first) =
object $
"email" .= emailIdentity ident
# "phone" .= phoneIdentity ident
# "first" .= first
# []

instance FromJSON ActivationResponse where
parseJSON = withObject "ActivationResponse" $ \o ->
ActivationResponse <$> parseJSON (Object o)
<*> o .:? "first" .!= False

instance FromJSON Activate where
parseJSON = withObject "Activation" $ \o ->
Activate <$> key o
<*> o .: "code"
<*> o .:? "dryrun" .!= False
where
key o =
(ActivateKey <$> o .: "key")
<|> (ActivateEmail <$> o .: "email")
<|> (ActivatePhone <$> o .: "phone")

instance ToJSON Activate where
toJSON (Activate k c d) =
object
[key k, "code" .= c, "dryrun" .= d]
where
key (ActivateKey ak) = "key" .= ak
key (ActivateEmail e) = "email" .= e
key (ActivatePhone p) = "phone" .= p
Loading

0 comments on commit 31bf2f6

Please sign in to comment.