-
Notifications
You must be signed in to change notification settings - Fork 333
[WPB-3633] client receives conversation deleted conversation events after federation delete event #3485
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
[WPB-3633] client receives conversation deleted conversation events after federation delete event #3485
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
No `conversation.delete` event is sent to users during de-federation clean up |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -366,13 +366,12 @@ deleteFederationRemote dom = do | |
queue = routingKey defederationQueue | ||
|
||
-- | Remove one-on-one conversations for the given remote domain. This is called from Galley as | ||
-- part of the defederation process, and should not be called duriung the initial domain removal | ||
-- part of the defederation process, and should not be called during the initial domain removal | ||
-- call to brig. This is so we can ensure that domains are correctly cleaned up if a service | ||
-- falls over for whatever reason. | ||
deleteFederationRemoteGalley :: Domain -> ExceptT Brig.API.Error.Error (AppT r) () | ||
deleteFederationRemoteGalley dom = do | ||
lift . wrapClient . Data.deleteRemoteConnectionsDomain $ dom | ||
assertNoDomainsFromConfigFiles dom | ||
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 reason for this line is that if you delete a remote that's also present in the config file, it will fail silently (signal success), as read is always the union of cassandra and yaml, and yaml can't be changed here. there is a comment about this somewhere in this CRUD family. why did you remove it? 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. Yes, but it is in the wrong place. At this point, the federation domain has already been deleted, and we are now cleaning up the local state. There is no need to check this again here. |
||
|
||
-- | Responds with 'Nothing' if field is NULL in existing user or user does not exist. | ||
getAccountConferenceCallingConfig :: UserId -> (Handler r) (ApiFt.WithStatusNoLock ApiFt.ConferenceCallingConfig) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ import Galley.API.Clients qualified as Clients | |
import Galley.API.Create qualified as Create | ||
import Galley.API.CustomBackend qualified as CustomBackend | ||
import Galley.API.Error | ||
import Galley.API.Federation (onConversationUpdated) | ||
import Galley.API.LegalHold (unsetTeamLegalholdWhitelistedH) | ||
import Galley.API.LegalHold.Conflicts | ||
import Galley.API.MLS.Removal | ||
|
@@ -94,7 +93,6 @@ import Network.Wai.Utilities.ZAuth | |
import Polysemy | ||
import Polysemy.Error | ||
import Polysemy.Input | ||
import Polysemy.TinyLog (logAndIgnoreErrors) | ||
import Polysemy.TinyLog qualified as P | ||
import Servant hiding (JSON, WithStatus) | ||
import Servant.Client (BaseUrl (BaseUrl), ClientEnv (ClientEnv), Scheme (Http), defaultMakeClientRequest) | ||
|
@@ -109,7 +107,6 @@ import Wire.API.Error.Galley | |
import Wire.API.Event.Conversation | ||
import Wire.API.Federation.API | ||
import Wire.API.Federation.API.Galley | ||
import Wire.API.Federation.API.Galley qualified as F | ||
import Wire.API.Federation.Error | ||
import Wire.API.FederationUpdate | ||
import Wire.API.Provider.Service hiding (Service) | ||
|
@@ -508,15 +505,12 @@ deleteFederationDomain :: | |
( Member (Input Env) r, | ||
Member (P.Logger (Msg -> Msg)) r, | ||
Member (Error FederationError) r, | ||
Member (Input (Local ())) r, | ||
Member MemberStore r, | ||
Member ConversationStore r, | ||
Member (Embed IO) r, | ||
Member CodeStore r, | ||
Member TeamStore r, | ||
Member BrigAccess r, | ||
Member GundeckAccess r, | ||
Member ExternalAccess r | ||
Member (Error InternalError) r | ||
) => | ||
Domain -> | ||
Sem r () | ||
|
@@ -529,16 +523,13 @@ internalDeleteFederationDomainH :: | |
( Member (Input Env) r, | ||
Member (P.Logger (Msg -> Msg)) r, | ||
Member (Error FederationError) r, | ||
Member (Input (Local ())) r, | ||
Member MemberStore r, | ||
Member ConversationStore r, | ||
Member (Embed IO) r, | ||
Member CodeStore r, | ||
Member TeamStore r, | ||
Member BrigAccess r, | ||
Member GundeckAccess r, | ||
Member ExternalAccess r, | ||
Member DefederationNotifications r | ||
Member DefederationNotifications r, | ||
Member (Error InternalError) r | ||
) => | ||
Domain ::: JSON -> | ||
Sem r Response | ||
|
@@ -611,50 +602,17 @@ deleteFederationDomainRemoteUserFromLocalConversations dom = do | |
|
||
-- Remove local members from remote conversations | ||
deleteFederationDomainLocalUserFromRemoteConversation :: | ||
( Member (Input (Local ())) r, | ||
Member (Input Env) r, | ||
Member (P.Logger (Msg -> Msg)) r, | ||
Member MemberStore r, | ||
Member (Embed IO) r, | ||
Member BrigAccess r, | ||
Member GundeckAccess r, | ||
Member ExternalAccess r | ||
( Member (Error InternalError) r, | ||
Member MemberStore r | ||
) => | ||
Domain -> | ||
Sem r () | ||
deleteFederationDomainLocalUserFromRemoteConversation dom = do | ||
localUsers <- E.getLocalMembersByDomain dom | ||
env <- input | ||
-- As above, build the map so we can get all local users per conversation | ||
let rCnvMap = foldr insertIntoMap mempty localUsers | ||
localDomain = env ^. Galley.App.options . optSettings . setFederationDomain | ||
-- Process each user. | ||
for_ (Map.toList rCnvMap) $ \(cnv, lUsers) -> do | ||
let catchBaddies = | ||
logAndIgnoreErrors @NoChanges | ||
( const "NoChanges: Could not remove a local member from a remote conversation." | ||
-- `NoChanges` doesn't contain too many details, so no point in showing it here. | ||
) | ||
"Federation domain removal" | ||
catchBaddies $ do | ||
now <- liftIO $ getCurrentTime | ||
for_ lUsers $ \user -> do | ||
let lUser = toLocalUnsafe localDomain user | ||
convUpdate = | ||
F.ConversationUpdate | ||
{ cuTime = now, | ||
cuOrigUserId = tUntagged lUser, | ||
cuConvId = cnv, | ||
cuAlreadyPresentUsers = [user], | ||
cuAction = SomeConversationAction (sing @'ConversationDeleteTag) () | ||
} | ||
-- These functions are used directly rather than as part of a larger conversation | ||
-- delete function, as we don't have an originating user, and we can't send data | ||
-- to the remote backend. | ||
-- We don't need to check the conversation type here, as we can't tell the | ||
-- remote federation server to delete the conversation. They will have to do a | ||
-- similar processing run for removing the local domain from their federation list. | ||
onConversationUpdated dom convUpdate | ||
remoteConvs <- foldr insertIntoMap mempty <$> E.getLocalMembersByDomain dom | ||
for_ (Map.toList remoteConvs) $ \(cnv, lUsers) -> do | ||
-- All errors, either exceptions or Either e, get thrown into IO | ||
mapError @NoChanges (const (InternalErrorWithDescription "No Changes: Could not remove a local member from a remote conversation.")) $ do | ||
E.deleteMembersInRemoteConversation (toRemoteUnsafe dom cnv) (N.toList lUsers) | ||
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 certainly more to the point! :) |
||
|
||
-- These need to be recoverable? | ||
-- This is recoverable with the following flow conditions. | ||
|
Uh oh!
There was an error while loading. Please reload this page.