From f1c57e780ee34c26893dcd059747ca69b84d7485 Mon Sep 17 00:00:00 2001 From: Igor Ranieri Elland <54423+elland@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:44:21 +0100 Subject: [PATCH 1/3] Added reason to bad gateway error for RPCs. (#3880) * Added reason to bad gateway error for RPCs. * Use displayException. --- services/brig/src/Brig/Provider/API.hs | 9 +++++---- services/brig/src/Brig/Provider/RPC.hs | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/services/brig/src/Brig/Provider/API.hs b/services/brig/src/Brig/Provider/API.hs index d6cb9698153..0bc3963beeb 100644 --- a/services/brig/src/Brig/Provider/API.hs +++ b/services/brig/src/Brig/Provider/API.hs @@ -76,6 +76,7 @@ import Data.Range import Data.Set qualified as Set import Data.Text.Ascii qualified as Ascii import Data.Text.Encoding qualified as Text +import Data.Text.Lazy qualified as Text import GHC.TypeNats import Imports import Network.HTTP.Types.Status @@ -705,7 +706,7 @@ addBot zuid zcon cid add = do -- implicitly in the next line. pure $ FutureWork @'UnprotectedBot undefined wrapClientE (User.addClient (botUserId bid) bcl newClt maxPermClients (Just $ Set.singleton Public.ClientSupportsLegalholdImplicitConsent)) - !>> const (StdError badGateway) -- MalformedPrekeys + !>> const (StdError $ badGatewayWith "MalformedPrekeys") -- Add the bot to the conversation ev <- lift $ RPC.addBotMember zuid zcon cid bid (clientId clt) pid sid @@ -917,8 +918,8 @@ maybeInvalidUser = maybe (throwStd (errorToWai @'E.InvalidUser)) pure rangeChecked :: (KnownNat n, KnownNat m, Within a n m, Monad monad) => a -> (ExceptT Error monad) (Range n m a) rangeChecked = either (throwStd . invalidRange . fromString) pure . checkedEither -badGateway :: Wai.Error -badGateway = Wai.mkError status502 "bad-gateway" "The upstream service returned an invalid response." +badGatewayWith :: String -> Wai.Error +badGatewayWith str = Wai.mkError status502 "bad-gateway" ("The upstream service returned an invalid response: " <> Text.pack str) tooManyBots :: Wai.Error tooManyBots = Wai.mkError status409 "too-many-bots" "Maximum number of bots for the service reached." @@ -927,7 +928,7 @@ serviceNotWhitelisted :: Wai.Error serviceNotWhitelisted = Wai.mkError status403 "service-not-whitelisted" "The desired service is not on the whitelist of allowed services for this team." serviceError :: RPC.ServiceError -> Wai.Error -serviceError RPC.ServiceUnavailable = badGateway +serviceError (RPC.ServiceUnavailableWith str) = badGatewayWith str serviceError RPC.ServiceBotConflict = tooManyBots randServiceToken :: MonadIO m => m Public.ServiceToken diff --git a/services/brig/src/Brig/Provider/RPC.hs b/services/brig/src/Brig/Provider/RPC.hs index bdb00994d4d..d11dc336a8c 100644 --- a/services/brig/src/Brig/Provider/RPC.hs +++ b/services/brig/src/Brig/Provider/RPC.hs @@ -63,7 +63,7 @@ import Wire.Rpc -- External RPC data ServiceError - = ServiceUnavailable + = ServiceUnavailableWith String | ServiceBotConflict -- | Request a new bot to be created by an external service. @@ -86,7 +86,7 @@ createBot scon new = do case Bilge.statusCode rs of 201 -> decodeBytes "External" (responseBody rs) 409 -> throwE ServiceBotConflict - _ -> lift (extLogError scon rs) >> throwE ServiceUnavailable + _ -> lift (extLogError scon rs) >> throwE (ServiceUnavailableWith $ show rs) where -- we can't use 'responseJsonEither' instead, because we have a @Response ByteString@ -- here, not a @Response (Maybe ByteString)@. @@ -97,7 +97,7 @@ createBot scon new = do extReq scon ["bots"] . method POST . Bilge.json new - onExc ex = lift (extLogError scon ex) >> throwE ServiceUnavailable + onExc ex = lift (extLogError scon ex) >> throwE (ServiceUnavailableWith $ displayException ex) extReq :: ServiceConn -> [ByteString] -> Request -> Request extReq scon ps = From 133a7409f152a60611eec9d97db11feb6551aa3a Mon Sep 17 00:00:00 2001 From: Akshay Mankar Date: Tue, 13 Feb 2024 10:28:23 +0100 Subject: [PATCH 2/3] Revert "WPB-5204 Remove unused APNS_VOIP code (#3695)" (#3883) This reverts commit 66b8c98a83d5a48e75accb3c65a2ff36e28eb5be. --- .../src/Gundeck/Types/Push/V2.hs | 3 ++ libs/wire-api/src/Wire/API/Push/V2/Token.hs | 8 ++++- .../golden/Test/Wire/API/Golden/Generated.hs | 6 ++++ .../Push_2eToken_2eTransport_user.hs | 8 ++++- .../golden/Test/Wire/API/Golden/Manual.hs | 4 +++ .../Test/Wire/API/Golden/Manual/Token.hs | 29 +++++++++++++++++++ ...bject_Push_2eToken_2eTransport_user_4.json | 1 + ...bject_Push_2eToken_2eTransport_user_5.json | 1 + .../test/golden/testObject_Token_1.json | 6 ++++ libs/wire-api/test/unit/Test/Wire/API/MLS.hs | 2 +- libs/wire-api/wire-api.cabal | 1 + services/brig/docs/swagger-v3.json | 4 ++- services/brig/docs/swagger-v4.json | 4 ++- services/gundeck/src/Gundeck/Aws.hs | 19 ++++++++---- services/gundeck/src/Gundeck/Aws/Arn.hs | 4 +++ services/gundeck/src/Gundeck/Instances.hs | 4 +++ services/gundeck/src/Gundeck/Push.hs | 23 ++++++++++++--- .../src/Gundeck/Push/Native/Serialise.hs | 9 ++++++ services/gundeck/test/integration/API.hs | 5 ++-- services/gundeck/test/unit/Native.hs | 2 ++ 20 files changed, 127 insertions(+), 16 deletions(-) create mode 100644 libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/Token.hs create mode 100644 libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_4.json create mode 100644 libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_5.json create mode 100644 libs/wire-api/test/golden/testObject_Token_1.json diff --git a/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs b/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs index aedfc7f0164..0dc12e508e8 100644 --- a/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs +++ b/libs/gundeck-types/src/Gundeck/Types/Push/V2.hs @@ -178,14 +178,17 @@ newtype ApsLocKey = ApsLocKey {fromLocKey :: Text} data ApsPreference = ApsStdPreference + | ApsVoIPPreference deriving (Eq, Show, Generic) deriving (Arbitrary) via GenericUniform ApsPreference instance ToJSON ApsPreference where + toJSON ApsVoIPPreference = "voip" toJSON ApsStdPreference = "std" instance FromJSON ApsPreference where parseJSON = withText "ApsPreference" $ \case + "voip" -> pure ApsVoIPPreference "std" -> pure ApsStdPreference x -> fail $ "Invalid preference: " ++ show x diff --git a/libs/wire-api/src/Wire/API/Push/V2/Token.hs b/libs/wire-api/src/Wire/API/Push/V2/Token.hs index 79f282b4d0f..0cf7b292af4 100644 --- a/libs/wire-api/src/Wire/API/Push/V2/Token.hs +++ b/libs/wire-api/src/Wire/API/Push/V2/Token.hs @@ -115,6 +115,8 @@ data Transport = GCM | APNS | APNSSandbox + | APNSVoIP + | APNSVoIPSandbox deriving stock (Eq, Ord, Show, Bounded, Enum, Generic) deriving (Arbitrary) via (GenericUniform Transport) deriving (A.ToJSON, A.FromJSON, S.ToSchema) via (Schema Transport) @@ -125,7 +127,9 @@ instance ToSchema Transport where mconcat [ element "GCM" GCM, element "APNS" APNS, - element "APNS_SANDBOX" APNSSandbox + element "APNS_SANDBOX" APNSSandbox, + element "APNS_VOIP" APNSVoIP, + element "APNS_VOIP_SANDBOX" APNSVoIPSandbox ] instance FromByteString Transport where @@ -134,6 +138,8 @@ instance FromByteString Transport where "GCM" -> pure GCM "APNS" -> pure APNS "APNS_SANDBOX" -> pure APNSSandbox + "APNS_VOIP" -> pure APNSVoIP + "APNS_VOIP_SANDBOX" -> pure APNSVoIPSandbox x -> fail $ "Invalid push transport: " <> show x newtype Token = Token diff --git a/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated.hs b/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated.hs index 52cde0922bd..a6003b36d81 100644 --- a/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated.hs +++ b/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated.hs @@ -791,6 +791,12 @@ tests = ), ( Test.Wire.API.Golden.Generated.Push_2eToken_2eTransport_user.testObject_Push_2eToken_2eTransport_user_3, "testObject_Push_2eToken_2eTransport_user_3.json" + ), + ( Test.Wire.API.Golden.Generated.Push_2eToken_2eTransport_user.testObject_Push_2eToken_2eTransport_user_4, + "testObject_Push_2eToken_2eTransport_user_4.json" + ), + ( Test.Wire.API.Golden.Generated.Push_2eToken_2eTransport_user.testObject_Push_2eToken_2eTransport_user_5, + "testObject_Push_2eToken_2eTransport_user_5.json" ) ], testGroup "Golden: Token_user" $ diff --git a/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/Push_2eToken_2eTransport_user.hs b/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/Push_2eToken_2eTransport_user.hs index fc7c1ed7f14..96739ba620c 100644 --- a/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/Push_2eToken_2eTransport_user.hs +++ b/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/Push_2eToken_2eTransport_user.hs @@ -17,7 +17,7 @@ module Test.Wire.API.Golden.Generated.Push_2eToken_2eTransport_user where -import Wire.API.Push.Token (Transport (APNS, APNSSandbox, GCM)) +import Wire.API.Push.Token (Transport (APNS, APNSSandbox, APNSVoIP, APNSVoIPSandbox, GCM)) import Wire.API.Push.Token qualified as Push.Token (Transport) testObject_Push_2eToken_2eTransport_user_1 :: Push.Token.Transport @@ -28,3 +28,9 @@ testObject_Push_2eToken_2eTransport_user_2 = APNS testObject_Push_2eToken_2eTransport_user_3 :: Push.Token.Transport testObject_Push_2eToken_2eTransport_user_3 = APNSSandbox + +testObject_Push_2eToken_2eTransport_user_4 :: Push.Token.Transport +testObject_Push_2eToken_2eTransport_user_4 = APNSVoIP + +testObject_Push_2eToken_2eTransport_user_5 :: Push.Token.Transport +testObject_Push_2eToken_2eTransport_user_5 = APNSVoIPSandbox diff --git a/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual.hs b/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual.hs index d0e892bf700..ed40d1157bd 100644 --- a/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual.hs +++ b/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual.hs @@ -42,6 +42,7 @@ import Test.Wire.API.Golden.Manual.QualifiedUserClientPrekeyMap import Test.Wire.API.Golden.Manual.SearchResultContact import Test.Wire.API.Golden.Manual.SubConversation import Test.Wire.API.Golden.Manual.TeamSize +import Test.Wire.API.Golden.Manual.Token import Test.Wire.API.Golden.Manual.UserClientPrekeyMap import Test.Wire.API.Golden.Manual.UserIdList import Test.Wire.API.Golden.Runner @@ -143,6 +144,9 @@ tests = testGroup "GroupId" $ testObjects [(testObject_GroupId_1, "testObject_GroupId_1.json")], + testGroup "PushToken" $ + testObjects + [(testObject_Token_1, "testObject_Token_1.json")], testGroup "TeamSize" $ testObjects [ (testObject_TeamSize_1, "testObject_TeamSize_1.json"), diff --git a/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/Token.hs b/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/Token.hs new file mode 100644 index 00000000000..2fa8207ddc9 --- /dev/null +++ b/libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/Token.hs @@ -0,0 +1,29 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2022 Wire Swiss GmbH +-- +-- This program is free software: you can redistribute it and/or modify it under +-- the terms of the GNU Affero General Public License as published by the Free +-- Software Foundation, either version 3 of the License, or (at your option) any +-- later version. +-- +-- This program is distributed in the hope that it will be useful, but WITHOUT +-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +-- details. +-- +-- You should have received a copy of the GNU Affero General Public License along +-- with this program. If not, see . + +module Test.Wire.API.Golden.Manual.Token where + +import Data.Id +import Wire.API.Push.V2.Token + +testObject_Token_1 :: PushToken +testObject_Token_1 = + pushToken + APNSVoIPSandbox + (AppName {appNameText = "j{\110746\SOH_\1084873M"}) + (Token {tokenText = "K"}) + (ClientId {clientToWord64 = 6}) diff --git a/libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_4.json b/libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_4.json new file mode 100644 index 00000000000..d177fe0e9d7 --- /dev/null +++ b/libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_4.json @@ -0,0 +1 @@ +"APNS_VOIP" diff --git a/libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_5.json b/libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_5.json new file mode 100644 index 00000000000..fd689b4ac10 --- /dev/null +++ b/libs/wire-api/test/golden/testObject_Push_2eToken_2eTransport_user_5.json @@ -0,0 +1 @@ +"APNS_VOIP_SANDBOX" diff --git a/libs/wire-api/test/golden/testObject_Token_1.json b/libs/wire-api/test/golden/testObject_Token_1.json new file mode 100644 index 00000000000..36f8ff69bd8 --- /dev/null +++ b/libs/wire-api/test/golden/testObject_Token_1.json @@ -0,0 +1,6 @@ +{ + "app": "j{𛂚\u0001_􈷉M", + "client": "6", + "token": "K", + "transport": "APNS_VOIP_SANDBOX" +} diff --git a/libs/wire-api/test/unit/Test/Wire/API/MLS.hs b/libs/wire-api/test/unit/Test/Wire/API/MLS.hs index b1f51f3b259..d0ff8a27a3b 100644 --- a/libs/wire-api/test/unit/Test/Wire/API/MLS.hs +++ b/libs/wire-api/test/unit/Test/Wire/API/MLS.hs @@ -308,7 +308,7 @@ spawn cp minput = do in snd <$> concurrently writeInput readOutput case (mout, ex) of (Just out, ExitSuccess) -> pure out - _ -> assertFailure $ "Failed spawning process\n" <> show mout <> "\n" <> show ex + _ -> assertFailure "Failed spawning process" cli :: String -> FilePath -> [String] -> CreateProcess cli store tmp args = diff --git a/libs/wire-api/wire-api.cabal b/libs/wire-api/wire-api.cabal index 91dc8a3af64..b191dbfbdec 100644 --- a/libs/wire-api/wire-api.cabal +++ b/libs/wire-api/wire-api.cabal @@ -585,6 +585,7 @@ test-suite wire-api-golden-tests Test.Wire.API.Golden.Manual.SearchResultContact Test.Wire.API.Golden.Manual.SubConversation Test.Wire.API.Golden.Manual.TeamSize + Test.Wire.API.Golden.Manual.Token Test.Wire.API.Golden.Manual.UserClientPrekeyMap Test.Wire.API.Golden.Manual.UserIdList Test.Wire.API.Golden.Protobuf diff --git a/services/brig/docs/swagger-v3.json b/services/brig/docs/swagger-v3.json index b844341e756..e252a739717 100644 --- a/services/brig/docs/swagger-v3.json +++ b/services/brig/docs/swagger-v3.json @@ -14,7 +14,9 @@ "enum": [ "GCM", "APNS", - "APNS_SANDBOX" + "APNS_SANDBOX", + "APNS_VOIP", + "APNS_VOIP_SANDBOX" ], "type": "string" }, diff --git a/services/brig/docs/swagger-v4.json b/services/brig/docs/swagger-v4.json index 7ff1394f344..937aafdefc9 100644 --- a/services/brig/docs/swagger-v4.json +++ b/services/brig/docs/swagger-v4.json @@ -4828,7 +4828,9 @@ "enum": [ "GCM", "APNS", - "APNS_SANDBOX" + "APNS_SANDBOX", + "APNS_VOIP", + "APNS_VOIP_SANDBOX" ], "type": "string" }, diff --git a/services/gundeck/src/Gundeck/Aws.hs b/services/gundeck/src/Gundeck/Aws.hs index b1636f33b7c..ea5fe968866 100644 --- a/services/gundeck/src/Gundeck/Aws.hs +++ b/services/gundeck/src/Gundeck/Aws.hs @@ -369,12 +369,17 @@ newtype Attributes = Attributes -- Note [VoIP TTLs] -- ~~~~~~~~~~~~~~~~ --- For GCM, APNS and APNS_SANDBOX, SNS treats the TTL "0" +-- The TTL message attributes for APNS_VOIP and APNS_VOIP_SANDBOX are not +-- documented but appear to work. The reason might be that TTLs were +-- introduced before support for VoIP notifications. There is a catch, +-- however. For GCM, APNS and APNS_SANDBOX, SNS treats the TTL "0" -- specially, i.e. it forwards it to the provider where it has a special --- meaning. Which means if the TTL is lower than the "dwell time" in SNS, --- the notification is never sent to the provider. So we must specify a --- reasonably large TTL for transient VoIP notifications, so that they are --- not discarded already by SNS. +-- meaning. That does not appear to be the case for APNS_VOIP and +-- APNS_VOIP_SANDBOX, for which the TTL is interpreted normally, which means +-- if the TTL is lower than the "dwell time" in SNS, the notification is +-- never sent to the provider. So we must specify a reasonably large TTL +-- for transient VoIP notifications, so that they are not discarded +-- already by SNS. -- -- cf. http://docs.aws.amazon.com/sns/latest/dg/sns-ttl.html @@ -390,9 +395,13 @@ timeToLive t s = Attributes (Endo (ttlAttr s)) ttlNow GCM = "0" ttlNow APNS = "0" ttlNow APNSSandbox = "0" + ttlNow APNSVoIP = "15" -- See note [VoIP TTLs] + ttlNow APNSVoIPSandbox = "15" -- See note [VoIP TTLs] ttlKey GCM = "AWS.SNS.MOBILE.GCM.TTL" ttlKey APNS = "AWS.SNS.MOBILE.APNS.TTL" ttlKey APNSSandbox = "AWS.SNS.MOBILE.APNS_SANDBOX.TTL" + ttlKey APNSVoIP = "AWS.SNS.MOBILE.APNS_VOIP.TTL" + ttlKey APNSVoIPSandbox = "AWS.SNS.MOBILE.APNS_VOIP_SANDBOX.TTL" publish :: EndpointArn -> LT.Text -> Attributes -> Amazon (Either PublishError ()) publish arn txt attrs = do diff --git a/services/gundeck/src/Gundeck/Aws/Arn.hs b/services/gundeck/src/Gundeck/Aws/Arn.hs index 7a559314f66..c0be6380d7d 100644 --- a/services/gundeck/src/Gundeck/Aws/Arn.hs +++ b/services/gundeck/src/Gundeck/Aws/Arn.hs @@ -134,6 +134,8 @@ arnTransportText :: Transport -> Text arnTransportText GCM = "GCM" arnTransportText APNS = "APNS" arnTransportText APNSSandbox = "APNS_SANDBOX" +arnTransportText APNSVoIP = "APNS_VOIP" +arnTransportText APNSVoIPSandbox = "APNS_VOIP_SANDBOX" -- Parsers -------------------------------------------------------------------- @@ -157,5 +159,7 @@ endpointTopicParser = do transportParser :: Parser Transport transportParser = string "GCM" $> GCM + <|> string "APNS_VOIP_SANDBOX" $> APNSVoIPSandbox + <|> string "APNS_VOIP" $> APNSVoIP <|> string "APNS_SANDBOX" $> APNSSandbox <|> string "APNS" $> APNS diff --git a/services/gundeck/src/Gundeck/Instances.hs b/services/gundeck/src/Gundeck/Instances.hs index ab70ccc440a..83ab2a692b4 100644 --- a/services/gundeck/src/Gundeck/Instances.hs +++ b/services/gundeck/src/Gundeck/Instances.hs @@ -40,11 +40,15 @@ instance Cql Transport where toCql GCM = CqlInt 0 toCql APNS = CqlInt 1 toCql APNSSandbox = CqlInt 2 + toCql APNSVoIP = CqlInt 3 + toCql APNSVoIPSandbox = CqlInt 4 fromCql (CqlInt i) = case i of 0 -> pure GCM 1 -> pure APNS 2 -> pure APNSSandbox + 3 -> pure APNSVoIP + 4 -> pure APNSVoIPSandbox n -> Left $ "unexpected transport: " ++ show n fromCql _ = Left "transport: int expected" diff --git a/services/gundeck/src/Gundeck/Push.hs b/services/gundeck/src/Gundeck/Push.hs index bc015b809af..02c6984873b 100644 --- a/services/gundeck/src/Gundeck/Push.hs +++ b/services/gundeck/src/Gundeck/Push.hs @@ -374,16 +374,31 @@ nativeTargets psh rcps' alreadySent = null (psh ^. pushConnections) || a ^. addrConn `elem` psh ^. pushConnections -- Apply transport preference in case of alternative transports for the - -- same client. If no explicit preference is given, the default preference depends on the priority. + -- same client (currently only APNS vs APNS VoIP). If no explicit + -- preference is given, the default preference depends on the priority. preference as = let pref = psh ^. pushNativeAps >>= view apsPreference in filter (pick (fromMaybe defPreference pref)) as where pick pr a = case a ^. addrTransport of GCM -> True - APNS -> pr == ApsStdPreference - APNSSandbox -> pr == ApsStdPreference - defPreference = ApsStdPreference + APNS -> pr == ApsStdPreference || notAny a APNSVoIP + APNSSandbox -> pr == ApsStdPreference || notAny a APNSVoIPSandbox + APNSVoIP -> pr == ApsVoIPPreference || notAny a APNS + APNSVoIPSandbox -> pr == ApsVoIPPreference || notAny a APNSSandbox + notAny a t = + not + ( any + ( \a' -> + addrEqualClient a a' + && a ^. addrApp == a' ^. addrApp + && a' ^. addrTransport == t + ) + as + ) + defPreference = case psh ^. pushNativePriority of + LowPriority -> ApsStdPreference + HighPriority -> ApsVoIPPreference check :: Either SomeException [a] -> m [a] check (Left e) = mntgtLogErr e >> pure [] check (Right r) = pure r diff --git a/services/gundeck/src/Gundeck/Push/Native/Serialise.hs b/services/gundeck/src/Gundeck/Push/Native/Serialise.hs index 07f783c36d9..bf9e0e491cc 100644 --- a/services/gundeck/src/Gundeck/Push/Native/Serialise.hs +++ b/services/gundeck/src/Gundeck/Push/Native/Serialise.hs @@ -54,6 +54,8 @@ renderText t prio x = case t of GCM -> trim "GCM" (jsonString gcmJson) APNS -> trim "APNS" (jsonString stdApnsJson) APNSSandbox -> trim "APNS_SANDBOX" (jsonString stdApnsJson) + APNSVoIP -> trim "APNS_VOIP" (jsonString voipApnsJson) + APNSVoIPSandbox -> trim "APNS_VOIP_SANDBOX" (jsonString voipApnsJson) where gcmJson = object @@ -65,6 +67,11 @@ renderText t prio x = case t of [ "aps" .= apsDict, "data" .= x ] + voipApnsJson = + object + [ "aps" .= object [], + "data" .= x + ] -- https://developer.apple.com/documentation/usernotifications/modifying_content_in_newly_delivered_notifications -- Must contain `mutable-content: 1` and include an alert dictionary with title, subtitle, or body information. -- Since we have no useful data here, we send a default payload that gets overridden by the client @@ -87,6 +94,8 @@ maxPayloadSize :: Transport -> Int64 maxPayloadSize GCM = 4096 maxPayloadSize APNS = 4096 maxPayloadSize APNSSandbox = 4096 +maxPayloadSize APNSVoIP = 5120 +maxPayloadSize APNSVoIPSandbox = 5120 gcmPriority :: Priority -> Text gcmPriority LowPriority = "normal" diff --git a/services/gundeck/test/integration/API.hs b/services/gundeck/test/integration/API.hs index 4ef4bd327b8..b0c3a63186f 100644 --- a/services/gundeck/test/integration/API.hs +++ b/services/gundeck/test/integration/API.hs @@ -838,8 +838,9 @@ testSharePushToken = do gcmTok <- Token . T.decodeUtf8 . toByteString' <$> randomId apsTok <- Token . T.decodeUtf8 . B16.encode <$> randomBytes 32 let tok1 = pushToken GCM "test" gcmTok - let tok2 = pushToken APNS "com.wire.int.ent" apsTok - forM_ [tok1, tok2] $ \tk -> do + let tok2 = pushToken APNSVoIP "com.wire.dev.ent" apsTok + let tok3 = pushToken APNS "com.wire.int.ent" apsTok + forM_ [tok1, tok2, tok3] $ \tk -> do u1 <- randomUser u2 <- randomUser c1 <- randomClientId diff --git a/services/gundeck/test/unit/Native.hs b/services/gundeck/test/unit/Native.hs index 500ec668ff6..2e525f7cf1f 100644 --- a/services/gundeck/test/unit/Native.hs +++ b/services/gundeck/test/unit/Native.hs @@ -73,6 +73,8 @@ instance FromJSON SnsNotification where [("GCM", String n)] -> parseGcm n [("APNS", String n)] -> parseApns APNS n [("APNS_SANDBOX", String n)] -> parseApns APNSSandbox n + [("APNS_VOIP", String n)] -> parseApns APNSVoIP n + [("APNS_VOIP_SANDBOX", String n)] -> parseApns APNSVoIPSandbox n _ -> mempty where parseApns t n = From 8c3af6a627189fa201b2d9adbf3c24056600bcfe Mon Sep 17 00:00:00 2001 From: Zebot Date: Tue, 13 Feb 2024 09:30:28 +0000 Subject: [PATCH 3/3] Add changelog for Release 2024-02-13 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc2dbb15ccb..c58915993f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# [2024-02-13] (Chart Release 4.41.0) + # [2024-02-12] (Chart Release 4.40.0) ## Release notes