-
Notifications
You must be signed in to change notification settings - Fork 325
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
Block and kick users in case of LH no_consent conflict (1:1 convs). #1507
Conversation
b743a45
to
a45d554
Compare
3150fa3
to
4641849
Compare
c6fda81
to
1794cdd
Compare
53c48f8
to
203de03
Compare
729234a
to
d3bfc33
Compare
- for i in $(echo Relation Accepted Blocked Pending Ignored Sent Cancelled MissingLegalholdConsent); do find ./tools/ ./libs/ ./services/ -type f -name '*.hs' -exec perl -i -pe 's/\b'$i'_'\''/'$i'/g' {} \;; done - drop the `StripSuffix` in the schema generation
d3bfc33
to
6b5b8ed
Compare
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.
I just found a button for showing changes since last review, so here is an empty review. :)
there is a benchmark that's quite reassuring. I don't think we need to worry about http response times here.
Ready to merge IMO (given ci agrees), but I can't approve, it's my PR. :) |
@@ -309,6 +310,11 @@ userTeams u = | |||
map runIdentity | |||
<$> retry x1 (query Cql.selectUserTeams (params Quorum (Identity u))) | |||
|
|||
usersTeams :: MonadClient m => [UserId] -> m (Map UserId TeamId) | |||
usersTeams uids = do | |||
pairs <- retry x1 (query Cql.selectUsersTeams (params Quorum (Identity uids))) |
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.
Larger IN queries (I know there's currently chunks of 32 in use; but still it's not ideal even at 32) lead to performance problems. See https://lostechies.com/ryansvihla/2014/09/22/cassandra-query-patterns-not-using-the-in-query-for-multiple-partitions/
Preferred way to do this lookup here is to use pooledMapConcurrentlyN
(https://hoogle.zinfra.io/file/root/.stack/snapshots/x86_64-linux/e2cc9ab01ac828ffb6fe45a45d38d7ca6e672fb9fe95528498b990da673c5071/8.8.4/doc/unliftio-0.2.13/UnliftIO-Async.html#v:pooledMapConcurrentlyN) (e.g. with 8 threads). Then you can re-use the existing selectOneUserTeam
.
Okay to do this in a follow-up PR if you prefer (but please do this change before this all goes live).
@@ -135,6 +135,9 @@ selectUserTeamsIn = "select team from user_team where user = ? and team in ? ord | |||
selectUserTeamsFrom :: PrepQuery R (UserId, TeamId) (Identity TeamId) | |||
selectUserTeamsFrom = "select team from user_team where user = ? and team > ? order by team" | |||
|
|||
selectUsersTeams :: PrepQuery R (Identity [UserId]) (UserId, TeamId) | |||
selectUsersTeams = "select user, team from user_team where user in ?" |
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.
As stated in the other comment, this query should be removed if possible.
-- tracked here: https://wearezeta.atlassian.net/browse/SQSERVICES-429 | ||
pure () | ||
-- If LH is activated for other user in 1:1 conv, 1:1 conv is blocked | ||
testNoConsentBlockOne2OneConv :: HasCallStack => Bool -> Bool -> Bool -> Bool -> TestM () |
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.
I admit it's a little hard to read this helper function as there are too many boolean branches here to figure out in one's head if this makes sense or not. I would personally prefer a bit more code duplication and less if/else branching on booleans. I can't properly review this helper function and the associated tests. Glancing at it, it looks okay, but there might be a glaring reverted condition here that I missed. Perhaps someone else could review this particular function and the associated tests? Maybe @smatting ?
This is a nitpick though and this can (or not) be done also as a follow-up cleanup.
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.
Stefan has paired excessively with me on this test, but I'll fix the boolean blindness in a separate PR anyway.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: jschaul <jschaul@users.noreply.github.com>
I hope I fixed all the errors here: 4aef9e9 |
* Import removeTeam to Galley.API.LegalHold without import cycles. (will be needed shortly.) * iterateConversations. (Copied from #1507, which has meanwhile been reverted in #1549.) * Make removeMember device id argument optional. * handleGroupConvPolicyConflicts [wip] * test stub * mapcon * fix bug in handleGroupConvPolicyConflicts * add 2 test cases: who is admin? who gets removed? * Add group conv logic [wip] * move lh helpers to utils * fixup add members * fixup tests * use Conversation from galley to include self * implement anyLHConsentMissing * Move check*Event funs from Teams to Utils * update first * adjust test to new setting & adjust case when peer is admin * hi ci * Add checks for leave events * add testNoConsentCannotBeInvited * add failing test case * Add guards (test succeeds) * refactor: rename guard functions * comment wording * anyLegalholdActivated: make true to the name * adjust testNoConsentRemoveFromGroupConv * inviting conflicting users: adjust and rename test * remove futurework (wont do) and add comments * remove test marker * spell out the tests * add FUTUREWORKs for test structure * comment wording * add test for v2 endpoint * add additional safeguard * Cleanup. * Add two missing test case stubs. * Eliminate redundant negation in function name. * Boolean blindness. only the first line changed, rest is ormolu noise. * Fix call side. * Changed my mind about whether boolean blindness is a good thing. * Fixup. * Cleanup (move source comment to inner block). * Tweak detail. * Remove dubious claim. #1595 (comment) * Simplify. * Move code around. * LH consent: guarantee that all conflicting conv members are removed. * Taking back e16a0bc. (I thought I had spotted a difference in database load, but I think i was wrong, and the original code is more straight-forward.) * Fixup. * Change test cases & descriptions. * fix syntax * All -> Some (explanation in message) Why 1) Because "Some" is the negation of "None" 2) This is consistent with testGroup "Legalhold is activated for user A in a group conversation" * add failing test case * Refactor: factor out new fn getLHStatusForUsers * Update business logic * Remove NoConsentingAdmins test case * Add test case: mixed invitees * Refactor: group tests regarding invite together * assertion (it's non-trivial, but easy enough to convince ourselves that it'll pass fine, so no error handling needed.) * Language. Co-authored-by: Matthias Fischmann <mf@zerobuzz.net>
https://wearezeta.atlassian.net/browse/SQSERVICES-429