Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lepsa authored and supersven committed Nov 8, 2023
1 parent fcfd498 commit 45246e1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
3 changes: 0 additions & 3 deletions libs/gundeck-types/src/Gundeck/Types/Push/V2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,13 @@ newtype ApsLocKey = ApsLocKey {fromLocKey :: Text}

data ApsPreference
= ApsStdPreference
| ApsVoIPPreference
deriving (Eq, Show)

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

Expand Down
2 changes: 0 additions & 2 deletions libs/ropes/src/Ropes/Twilio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ data CarrierInfo = CarrierInfo
data PhoneType
= Landline
| Mobile
| VoIp
deriving (Eq, Show)

instance FromJSON LookupResult where
Expand All @@ -148,7 +147,6 @@ instance FromJSON PhoneType where
parseJSON = withText "PhoneType" $ \case
"mobile" -> pure Mobile
"landline" -> pure Landline
"voip" -> pure VoIp
x -> fail $ "Unexpected phone type: " ++ show x

-- * Functions
Expand Down
6 changes: 3 additions & 3 deletions libs/wire-api/test/unit/Test/Wire/API/MLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ testParseApplication :: IO ()
testParseApplication = do
qcid <- B8.unpack . encodeMLS' <$> randomIdentity
msgData <- withSystemTempDirectory "mls" $ \tmp -> do
void $ spawn (cli qcid tmp ["init", qcid]) Nothing
groupJSON <- spawn (T.traceShowId (cli qcid tmp ["group", "create", "Zm9v"])) Nothing
spawn (cli qcid tmp ["message", "--group-in", "-", "hello"]) (Just groupJSON)
void $ spawn (T.traceShowId $ cli qcid tmp ["init", qcid]) Nothing
groupJSON <- spawn (T.traceShowId $ cli qcid tmp ["group", "create", "Zm9v"]) Nothing
spawn (T.traceShowId $ cli qcid tmp ["message", "--group", "-", "hello"]) (Just groupJSON)

msg <- case decodeMLS' @Message msgData of
Left err -> assertFailure (T.unpack err)
Expand Down
7 changes: 2 additions & 5 deletions services/gundeck/src/Gundeck/Push.hs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,7 @@ nativeTargets psh rcps' alreadySent =
null (psh ^. pushConnections)
|| a ^. addrConn `elem` psh ^. pushConnections
-- Apply transport preference in case of alternative transports for the
-- same client (currently only APNS vs APNS VoIP). If no explicit
-- preference is given, the default preference depends on the priority.
-- same client. 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
Expand All @@ -384,9 +383,7 @@ nativeTargets psh rcps' alreadySent =
GCM -> True
APNS -> pr == ApsStdPreference
APNSSandbox -> pr == ApsStdPreference
defPreference = case psh ^. pushNativePriority of
LowPriority -> ApsStdPreference
HighPriority -> ApsVoIPPreference
defPreference = ApsStdPreference
check :: Either SomeException [a] -> m [a]
check (Left e) = mntgtLogErr e >> pure []
check (Right r) = pure r
Expand Down

0 comments on commit 45246e1

Please sign in to comment.