Skip to content

Conversation

blackheaven
Copy link
Contributor

https://wearezeta.atlassian.net/browse/WPB-18190

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

PS: I did not see #4685, sorry

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jul 30, 2025
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to handle this one.

I have tried to move services/galley/src/Galley/Effects/ConversationStore.hs in lib/wire-subsystems, but Cassandra queries and many data-types are in Galley.

I'm also not sure how to list the O2O conversations of a (TeamId, UserId).

I would be inclined to create a dedicate effects, with one operation and a Cassandra interpreter, having queries in the same file.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is failing with:

[[email protected]] E, IO Exception occurred, message=ResponseError {reHost = datacenter1:rack1:127.0.0.1:9042, reTrace = Nothing, reWarn = [], reCause = Invalid "unconfigured table conversation"}, request=abef79a6-8f9f-41b3-b674-036e4216db63
[[email protected]] E, request=abef79a6-8f9f-41b3-b674-036e4216db63, code=500, label=server-error, "Server Error"

I feel like I'm in another key space, can I have some hints about it?

@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from 8e873f3 to 78aea4e Compare August 5, 2025 12:32
@blackheaven blackheaven marked this pull request as ready for review August 5, 2025 12:34
@blackheaven blackheaven requested review from a team as code owners August 5, 2025 12:35
Copy link
Contributor

@pcapriotti pcapriotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but I'm not sure about the logic for deleting conversations. See comments below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is enough. This would leave the conversation in the database, as well as member entries. It's probably better to reuse the conversation store here, which already has a deleteConversation method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me, but maybe I'm not understanding something. In my understanding, we should:

  • delete all one2one conversations with unconnected team members
  • remove ourselves from team conversations.

The code here seems to only look for team conversations that were created by the collaborator, and then delete them. I can't see anything about one2one conversations. Regardless, I don't think it matters who created the conversation. When a collaboration is ended, the collaborator should simply be kicked from team conversations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have deleteConversation for One2One conversations type, and remove user-conversation relationship otherwise, let me know what you think.

@blackheaven blackheaven requested a review from pcapriotti August 6, 2025 15:35
@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from 83eb7a1 to c1f5acf Compare August 6, 2025 16:54
@blackheaven
Copy link
Contributor Author

I cannot reproduce the error, which seems not related to my changes.

@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from c1f5acf to 0969d6d Compare August 13, 2025 16:05
@blackheaven blackheaven self-assigned this Aug 14, 2025
@blackheaven
Copy link
Contributor Author

@battermann I have made the change to rely on the same mechanisms behind rmUser, feel free to have a look.

Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a few team and 1:1 conversations and verify that the user is removed.

We should also verify that the user still exists and is still member of other non-team conersations etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have missed it:

yes, I would create a couple of conversations, team group conv, 1:1 conv, non-team conv, and then check membership after the collaborator is removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: find how to create team and non-team convs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@battermann I did not managed to create non-team conversation becoming one, but the remaining edge cases are checked let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the naming convention here. Why the prefix Internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly because we do not check permissions in it, should I drop it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it. It's fine then.

@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from c5e0a60 to 30c92d0 Compare August 19, 2025 15:29
@blackheaven blackheaven requested a review from battermann August 20, 2025 14:45
Copy link
Contributor

@pcapriotti pcapriotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not convinced that the removal logic is correct.

  • we shouldn't delete all 1-1 conversations indiscriminately, but just the ones with unconnected team members. I'm thinking of cases where a user A was connected with team member B, then A is added as a collaborator of B's team, then removed. We don't want to delete the conversation between A and B in that case.
  • I don't think we should be manually making db queries. That makes it harder to check that we're not breaking any invariants. Instead, we should use internal APIs and/or low-level helper functions that are shared with the rest of the code, even if that makes things less efficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as in #4708: we shouldn't use IN queries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Instead, I think we should use the existing pagination internal API, like we do when deleting a user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped, however, I'm not sur what you are referring to, there is nothing more in rmUser.

@blackheaven blackheaven requested a review from pcapriotti August 22, 2025 14:18
@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch 4 times, most recently from 5eb2959 to c510050 Compare September 3, 2025 12:16
@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from 741ffd8 to 0ec3937 Compare September 5, 2025 16:06
:<|> Named @"get-team-size" (\uid tid -> lift . liftSem $ teamSizePublic uid tid)
:<|> Named @"accept-team-invitation" (\luid req -> lift $ liftSem $ acceptTeamInvitation luid req.password req.code)
:<|> Named @"add-team-collaborator" (\zuid tid (NewTeamCollaborator uid perms) -> lift . liftSem $ createTeamCollaborator zuid uid tid perms)
:<|> Named @"remove-team-collaborator" (\zuid tid uid -> lift . liftSem $ GalleyAPIAccess.removeTeamMember zuid uid tid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this handler to galley, so that we do not need to make an extra unnecessary call from brig to galley.

@blackheaven
Copy link
Contributor Author

@battermann I have reworked the the design, I still have to rework the tests

:<|> Named
"remove-team-collaborator"
( Summary "Remove a collaborator from the team."
:> From 'V11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be V12 by now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks.

| NewTeamCollaborator
| JoinRegularConversations
| CreateApp
| RemoveTeamCollaborator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used, I can't find it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in removeTeamCollaborator, the handler.

defProteus {team = Just team, qualifiedUsers = [alice, bob]}
>>= getJSON 201

withWebSockets [owner, alice] $ \[wsOwner, wsAlice] -> do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the collaborator themselves, also get an event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

)
. (.status)
uncheckedDeleteTeamMember lusr Nothing tid rusr toNotify
internalRemoveTeamCollaborator rusr tid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we send the collaborator remove event here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, thanks.

| EdConvDelete ConvId
| EdCollaboratorAdd UserId [CollaboratorPermission]
| EdAppCreate UserId
| EdCollaboratorRemove UserId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not sent, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, thanks.

EdReasonDeleted
)
def
case () of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a funny construct, why not match on the cnvmType value directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thanks

@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from f7bee64 to 1c458bf Compare September 17, 2025 08:55
@blackheaven blackheaven force-pushed the gdifolco/WPB-18190_collaborator-delete-endpoint branch from 6ab2eaa to 9986c2f Compare September 24, 2025 08:49
@blackheaven blackheaven merged commit f957075 into develop Sep 24, 2025
8 checks passed
@blackheaven blackheaven deleted the gdifolco/WPB-18190_collaborator-delete-endpoint branch September 24, 2025 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants