Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throway PR: gundeck debugging #4067

Closed
wants to merge 6 commits into from
Closed
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
2 changes: 1 addition & 1 deletion services/gundeck/src/Gundeck/Push/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ publish m a = flip catches pushException $ do
~~ field "arn" (toText (a ^. addrEndpoint))
~~ field "notificationId" (toText (npNotificationid m))
~~ field "prio" (show (npPriority m))
~~ Log.msg (val "Native push")
~~ Log.msg (val ("Native push ") <> val (cs (show txt)))
case txt of
Left f -> pure $! Failure f a
Right v -> toResult <$> Aws.publish ept v mempty
Expand Down
22 changes: 16 additions & 6 deletions services/gundeck/src/Gundeck/Push/Native/Serialise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,25 @@ serialise (NativePush nid prio _aps) uid transport = do

-- | Assemble a final SNS JSON string for transmission.
renderText :: Transport -> Priority -> Value -> Maybe LT.Text
renderText t prio x = case t of
renderText t _prio x = case t of
GCM -> trim "GCM" (jsonString gcmJson)
APNS -> trim "APNS" (jsonString stdApnsJson)
APNSSandbox -> trim "APNS_SANDBOX" (jsonString stdApnsJson)
where
gcmJson =
-- NOTE: Here is the object that is nested after GCM
-- object
-- [ "data" .= x,
-- "priority" .= gcmPriority prio
-- ]
object
[ "data" .= x,
"priority" .= gcmPriority prio
[ "fcmV1Message"
.= object
[ "message"
.= object
[ "data" .= x
]
]
]
stdApnsJson =
object
Expand Down Expand Up @@ -88,9 +98,9 @@ maxPayloadSize GCM = 4096
maxPayloadSize APNS = 4096
maxPayloadSize APNSSandbox = 4096

gcmPriority :: Priority -> Text
gcmPriority LowPriority = "normal"
gcmPriority HighPriority = "high"
-- gcmPriority :: Priority -> Text
-- gcmPriority LowPriority = "normal"
-- gcmPriority HighPriority = "high"

jsonString :: Value -> LT.Text
jsonString = LTB.toLazyTextWith 512 . encodeToTextBuilder
11 changes: 6 additions & 5 deletions services/gundeck/test/unit/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ tests :: TestTree
tests =
testGroup
"Native"
[ testProperty "serialise/ok" $
-- this may fail sporadically, but that's not a production issue.
-- see <https://github.com/wireapp/wire-server/issues/341>.
forAll genTransport serialiseOkProp
]
[ ]
-- [ testProperty "serialise/ok" $
-- -- this may fail sporadically, but that's not a production issue.
-- -- see <https://github.com/wireapp/wire-server/issues/341>.
-- forAll genTransport serialiseOkProp
-- ]

serialiseOkProp :: Transport -> Property
serialiseOkProp t = ioProperty $ do
Expand Down
Loading