-
Notifications
You must be signed in to change notification settings - Fork 334
WPB-24076: Add meeting cleaner job in background-worker
#5207
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: develop
Are you sure you want to change the base?
Changes from 5 commits
525b82e
0400ed6
ce1b6b8
e2bc2f1
0f2ca05
762bf2f
e8d58ff
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 @@ | ||
| Add meeting cleaner job in `background-worker`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| {-# LANGUAGE TemplateHaskell #-} | ||
|
|
||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Wire.MeetingsSubsystemCleaning where | ||
|
|
||
| import Data.Time.Clock (UTCTime) | ||
| import Imports | ||
| import Polysemy | ||
|
|
||
| data MeetingsSubsystemCleaning m a where | ||
| CleanupOldMeetings :: | ||
|
battermann marked this conversation as resolved.
Outdated
|
||
| UTCTime -> | ||
| Int -> | ||
| MeetingsSubsystemCleaning m Int64 | ||
|
|
||
| makeSem ''MeetingsSubsystemCleaning | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| {-# LANGUAGE DuplicateRecordFields #-} | ||
|
|
||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Wire.MeetingsSubsystemCleaning.Interpreter where | ||
|
battermann marked this conversation as resolved.
Outdated
|
||
|
|
||
| import Data.Time.Clock (UTCTime) | ||
| import Imports | ||
| import Polysemy | ||
| import Wire.API.Conversation (GroupConvType (MeetingConversation), cnvmGroupConvType) | ||
| import Wire.ConversationStore qualified as ConvStore | ||
| import Wire.MeetingsStore qualified as Store | ||
| import Wire.MeetingsSubsystemCleaning | ||
| import Wire.StoredConversation (StoredConversation (..)) | ||
|
|
||
| interpretMeetingsSubsystemCleaning :: | ||
| ( Member Store.MeetingsStore r, | ||
| Member ConvStore.ConversationStore r | ||
| ) => | ||
| InterpreterFor MeetingsSubsystemCleaning r | ||
| interpretMeetingsSubsystemCleaning = interpret $ \case | ||
| CleanupOldMeetings cutoffTime batchSize -> | ||
| cleanupOldMeetingsImpl cutoffTime batchSize | ||
|
|
||
| cleanupOldMeetingsImpl :: | ||
| ( Member Store.MeetingsStore r, | ||
| Member ConvStore.ConversationStore r | ||
| ) => | ||
| UTCTime -> | ||
| Int -> | ||
| Sem r Int64 | ||
| cleanupOldMeetingsImpl cutoffTime batchSize = do | ||
| oldMeetings <- Store.getOldMeetings cutoffTime batchSize | ||
| if null oldMeetings | ||
| then pure 0 | ||
| else do | ||
| -- 2. Delete associated conversations first (before meetings) | ||
| -- This ensures proper cleanup: conversation data should be removed before meeting records | ||
| -- We only delete conversations that are meeting conversations (GroupConvType = MeetingConversation) | ||
| for_ oldMeetings $ \meeting -> do | ||
| maybeConv <- ConvStore.getConversation meeting.conversationId | ||
| case maybeConv of | ||
| Just conv | ||
| | conv.metadata.cnvmGroupConvType == Just MeetingConversation, | ||
| conv.id_ == meeting.conversationId -> | ||
| ConvStore.deleteConversation meeting.conversationId | ||
|
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. I still think that we should use the MeetingSubsystem to delete the meeting because that properly cleans up the conversation data. Here AFAICT we only delete the conversation via the ConversationStore but instead we should use the handler from the ConversationSubsystem because that takes care of deleting all the other stuff that is related to a conversation.
Contributor
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. We have to pair program on this tomorrow because regular meeting deletion requires a |
||
| _ -> pure () | ||
|
|
||
| -- 3. Now delete the meeting records from the database | ||
| Store.deleteMeetingBatch $ map (\Store.StoredMeeting {id = mid} -> mid) oldMeetings | ||
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.
Interesting finding 👍