-
Notifications
You must be signed in to change notification settings - Fork 326
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
mock gundeck #554
mock gundeck #554
Conversation
c0f586b
to
b717a7d
Compare
2016223
to
c9e4a09
Compare
updated the description. this is ready for review, but i will improve haddocks soon, feel free to wait! |
a5650cf
to
18edeaf
Compare
all tests passed locally. ready for review! |
I've attempted to review the actual logic here, but failed miserably – probably because I don't know well what the original Gundeck does either. I will take another stab at it later and ask more questions. |
thanks for your feedback! i processed everything but commented only where it wasn't obvious what i'm supposed to do. new commit coming up! |
there is still an error uncovered by the last test coverage expansion:
hypothesis: something about "empty list means all devices" again. maybe |
device is this a bug in production? |
@@ -222,7 +256,7 @@ data Push = Push | |||
-- REFACTOR: this make no sense any more since native push notifications have no more payload. | |||
-- https://github.com/wireapp/wire-server/pull/546 | |||
, _pushNativeAps :: !(Maybe ApsData) | |||
-- ^ APNs-specific metadata. | |||
-- ^ APNs-specific metadata. REFACTOR: can this be removed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it can!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I will remove that sentence.
natives <- mpaNativeTargets psh alreadySent | ||
mpaPushNative notif psh natives | ||
forM_ resp $ \((notif, psh), alreadySent) -> unless (psh ^. pushTransient) $ | ||
mpaPushNative notif psh =<< nativeTargets psh alreadySent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this call mpaNativeTargets
instead of nativeTargets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that doesn't exist any more. instead, pushAll
has a constraint that allows mocking this.
Discussed this with @tiago-loureiro, and agreed it's a bug in the production code. I will revert aa0d53c and fix the behavior of |
…e)." This reverts commit aa0d53c.
@neongreen wanna have a "last" look? check that 469c78a makes sense and that i didn't break thanks for your work on this, that was quite necessary! |
services/gundeck/src/Gundeck/Push.hs
Outdated
@@ -290,6 +292,9 @@ nativeTargets p pres = | |||
eligibleClient _ RecipientClientsAll = True | |||
eligibleClient a (RecipientClientsSome cs) = (a^.addrClient) `elem` cs | |||
|
|||
whitelistedOrNoWhitelist a = p^.pushConnections == mempty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
should work too, since both elem
and null
come from Foldable
.
@@ -494,7 +493,9 @@ handlePushNative Push{..} = do | |||
isOriginDevice = origin == (uid, Just cid) | |||
isAllowedPerOriginRules = | |||
not isOriginUser || (_pushNativeIncludeOrigin && not isOriginDevice) | |||
when (isNative && isReachable && isAllowedPerOriginRules) $ | |||
-- Condition 5: push to cid iff (a) listed in pushConnections or (b) pushConnections is empty. | |||
let isWhitelisted = Set.null _pushConnections || fakeConnId cid `elem` _pushConnections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems better to have either null+elem
or Set.null+Set.member
, but not a mix of those.
services/gundeck/src/Gundeck/Push.hs
Outdated
& targetClients .~ case r^.recipientClients of | ||
RecipientClientsAll -> [] | ||
-- clients are stored in cassandra as a list with a notification. empty list | ||
-- is intepreted as "all clients" by 'Gundeck.Notification.Data.toNotif'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- is intepreted as "all clients" by 'Gundeck.Notification.Data.toNotif'. | |
-- is interpreted as "all clients" by 'Gundeck.Notification.Data.toNotif'. |
I haven't looked at bulk push and old web push closely, but I hope that Tiago has. If so, I'm in favor of merging this PR. |
Notes for the reviewer:
MockGundeck
,Push
in the gundeck unit tests. then the overall changes in those two modules.Related: #518, #531, #546, #549