-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[PM-36158] - Fix org cipher push notifications to fan out per authorized user #7522
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
5f50353
90b3453
4956715
5e43828
bb3d8b4
e7d235d
7b343e6
2f0aab4
c1e2ee9
ff7ebcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the place to add this kind of logic. You should likely create your own service that has methods like This new service is also the place where this needs to be feature flagged. This has the possibility of new load to the database when notifications are being sent, new amount of notifications being sent and new load to the server because clients are now reacting to notifications they did not get before by doing API calls.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great idea. Added a service as well as feature flag on/off handling. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| CREATE PROCEDURE [dbo].[CollectionCipher_ReadUserIdsByCollectionIds] | ||
| @CollectionIds AS [dbo].[GuidIdArray] READONLY | ||
| AS | ||
| BEGIN | ||
| SET NOCOUNT ON | ||
|
|
||
| -- Users with direct collection access | ||
| SELECT DISTINCT OU.[UserId] | ||
| FROM [dbo].[CollectionUser] CU | ||
| INNER JOIN [dbo].[OrganizationUser] OU ON OU.[Id] = CU.[OrganizationUserId] | ||
| WHERE CU.[CollectionId] IN (SELECT [Id] FROM @CollectionIds) | ||
| AND OU.[Status] = 2 -- Confirmed | ||
|
|
||
| UNION | ||
|
|
||
| -- Users with group-based collection access | ||
| SELECT DISTINCT OU.[UserId] | ||
| FROM [dbo].[CollectionGroup] CG | ||
| INNER JOIN [dbo].[GroupUser] GU ON GU.[GroupId] = CG.[GroupId] | ||
| INNER JOIN [dbo].[OrganizationUser] OU ON OU.[Id] = GU.[OrganizationUserId] | ||
| WHERE CG.[CollectionId] IN (SELECT [Id] FROM @CollectionIds) | ||
| AND OU.[Status] = 2 -- Confirmed | ||
| END | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This query covers direct CollectionUser and group-based access, but it misses users who have access to all org ciphers implicitly, (OrganizationUser.Type of Owner or Admin) and users with -- Users with org-level access (admins, owners, AccessAll)
UNION
SELECT DISTINCT OU.[UserId]
FROM [dbo].[OrganizationUser] OU
INNER JOIN [dbo].[CollectionCipher] CC ON CC.[CollectionId] IN (SELECT [Id] FROM @CollectionIds)
INNER JOIN [dbo].[Collection] COL ON COL.[Id] = CC.[CollectionId]
WHERE OU.[OrganizationId] = COL.[OrganizationId]
AND OU.[Status] = 2
AND (OU.[AccessAll] = 1 OR OU.[Type] IN (0, 1))
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same change would be needed on the EF side of things in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nick-livefront Good point.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch on AccessAll. Your current fix will allow any admin or owner to receive notifications, it still should be restricted to if they have access.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nick-livefront Ah yes ofc. Fixed. e7d235d
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The EF implementation needs the fix as well π
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π€¦ |
||
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.
If this is true, then
PushCipherAsynccan be deleted fromIPushEngine. It only exists because of the different behavior of the engines but since this PR is making it so there isn't a difference it shouldn't need to exist anymore.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.
@justindbaur Indeed. Removed.2f0aab4