Skip to content
Closed

spike #5069

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions libs/wire-subsystems/src/Wire/DeleteConversationSubsystem.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{-# 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.DeleteConversationSubsystem where

import Data.Id
import Data.Qualified
import Imports
import Polysemy

data DeleteConversationSubsystem m a where
DeleteConversation ::
Local UserId ->
ConnId ->
TeamId ->
ConvId ->
DeleteConversationSubsystem m ()

makeSem ''DeleteConversationSubsystem
1 change: 1 addition & 0 deletions libs/wire-subsystems/wire-subsystems.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ library
Wire.ConversationSubsystem.Interpreter
Wire.ConversationSubsystem.One2One
Wire.ConversationSubsystem.Util
Wire.DeleteConversationSubsystem
Wire.DeleteQueue
Wire.DeleteQueue.InMemory
Wire.DomainRegistrationStore
Expand Down
1 change: 1 addition & 0 deletions services/galley/galley.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ library
Galley.Data.TeamNotifications
Galley.Effects
Galley.Effects.CustomBackendStore
Galley.Effects.DeleteConversationSubsystem
Galley.Effects.Queue
Galley.Effects.SearchVisibilityStore
Galley.Effects.TeamMemberStore
Expand Down
27 changes: 4 additions & 23 deletions services/galley/src/Galley/API/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import Galley.API.Action
import Galley.API.LegalHold.Team
import Galley.API.Teams.Features.Get
import Galley.API.Teams.Notifications qualified as APITeamQueue
import Galley.API.Update qualified as API
import Galley.App
import Galley.Effects
import Galley.Effects.Queue qualified as E
Expand Down Expand Up @@ -131,6 +130,7 @@ import Wire.CodeStore
import Wire.ConversationStore qualified as E
import Wire.ConversationSubsystem
import Wire.ConversationSubsystem.Util
import Wire.DeleteConversationSubsystem
import Wire.FeaturesConfigSubsystem
import Wire.FederationSubsystem
import Wire.ListItems qualified as E
Expand Down Expand Up @@ -962,33 +962,14 @@ getTeamConversation zusr tid cid = do
pure $ newTeamConversation teamConv

deleteTeamConversation ::
( Member BackendNotificationQueueAccess r,
Member BrigAPIAccess r,
Member CodeStore r,
Member ConversationStore r,
Member (Error FederationError) r,
Member (ErrorS 'ConvNotFound) r,
Member (ErrorS 'InvalidOperation) r,
Member (ErrorS 'NotATeamMember) r,
Member (ErrorS ('ActionDenied 'Public.DeleteConversation)) r,
Member (FederationAPIAccess FederatorClient) r,
Member ProposalStore r,
Member ConversationSubsystem r,
Member TeamStore r,
Member TeamCollaboratorsSubsystem r,
Member E.MLSCommitLockStore r,
Member FederationSubsystem r,
Member TeamSubsystem r,
Member (Input ConversationSubsystemConfig) r
) =>
(Member DeleteConversationSubsystem r) =>
Local UserId ->
ConnId ->
TeamId ->
ConvId ->
Sem r ()
deleteTeamConversation lusr zcon _tid cid = do
let lconv = qualifyAs lusr cid
void $ API.deleteLocalConversation lusr zcon lconv
deleteTeamConversation lusr zcon _tid cid =
deleteConversation lusr zcon _tid cid

getSearchVisibility ::
( Member (ErrorS 'NotATeamMember) r,
Expand Down
2 changes: 2 additions & 0 deletions services/galley/src/Galley/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import Galley.Cassandra.Team
)
import Galley.Cassandra.TeamNotifications
import Galley.Effects
import Galley.Effects.DeleteConversationSubsystem (interpretDeleteConversationSubsystem)
import Galley.Env
import Galley.External.LegalHoldService.Internal qualified as LHInternal
import Galley.Keys
Expand Down Expand Up @@ -450,6 +451,7 @@ evalGalley e =
. runInputSem getAllTeamFeaturesForServer
. interpretTeamCollaboratorsSubsystem
. runFederationSubsystem conversationSubsystemConfig.federationProtocols
. interpretDeleteConversationSubsystem
. interpretConversationSubsystem
. Meeting.interpretMeetingsSubsystem meetingValidityPeriod
where
Expand Down
3 changes: 3 additions & 0 deletions services/galley/src/Galley/Effects.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Galley.Effects

-- * Other effects
Queue,
DeleteConversationSubsystem,

-- * Polysemy re-exports
Member,
Expand Down Expand Up @@ -85,6 +86,7 @@ import Wire.BrigAPIAccess
import Wire.CodeStore
import Wire.ConversationStore (ConversationStore, MLSCommitLockStore)
import Wire.ConversationSubsystem
import Wire.DeleteConversationSubsystem
import Wire.ExternalAccess
import Wire.FeaturesConfigSubsystem (FeaturesConfigSubsystem)
import Wire.FeaturesConfigSubsystem.Types (ExposeInvitationURLsAllowlist)
Expand Down Expand Up @@ -121,6 +123,7 @@ import Wire.UserGroupStore
type GalleyEffects1 =
'[ MeetingsSubsystem,
ConversationSubsystem,
DeleteConversationSubsystem,
FederationSubsystem,
TeamCollaboratorsSubsystem,
Input AllTeamFeatures,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
-- 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 Galley.Effects.DeleteConversationSubsystem
( interpretDeleteConversationSubsystem,
)
where

import Data.Qualified
import Galley.API.Update qualified as API
import Imports
import Polysemy
import Wire.API.Conversation.Config (ConversationSubsystemConfig)
import Wire.API.Error
import Wire.API.Error.Galley
import Wire.API.Federation.Client (FederatorClient)
import Wire.API.Federation.Error
import Wire.BackendNotificationQueueAccess (BackendNotificationQueueAccess)
import Wire.BrigAPIAccess (BrigAPIAccess)
import Wire.CodeStore (CodeStore)
import Wire.ConversationStore (ConversationStore, MLSCommitLockStore)
import Wire.ConversationSubsystem (ConversationSubsystem)
import Wire.DeleteConversationSubsystem
import Wire.FederationAPIAccess (FederationAPIAccess)
import Wire.FederationSubsystem (FederationSubsystem)
import Wire.ProposalStore (ProposalStore)
import Wire.TeamCollaboratorsSubsystem (TeamCollaboratorsSubsystem)
import Wire.TeamStore (TeamStore)
import Wire.TeamSubsystem (TeamSubsystem)
import Polysemy.Error
import Polysemy.Input

interpretDeleteConversationSubsystem ::
( Member BrigAPIAccess r,
Member BackendNotificationQueueAccess r,
Member CodeStore r,
Member ConversationStore r,
Member (Error FederationError) r,
Member (ErrorS 'NotATeamMember) r,
Member (ErrorS ('ActionDenied 'DeleteConversation)) r,
Member (ErrorS 'ConvNotFound) r,
Member (ErrorS 'InvalidOperation) r,
Member (FederationAPIAccess FederatorClient) r,
Member ConversationSubsystem r,
Member ProposalStore r,
Member TeamStore r,
Member TeamCollaboratorsSubsystem r,
Member MLSCommitLockStore r,
Member FederationSubsystem r,
Member TeamSubsystem r,
Member (Input ConversationSubsystemConfig) r
) =>
Sem (DeleteConversationSubsystem : r) a ->
Sem r a
interpretDeleteConversationSubsystem = interpret $ \case
DeleteConversation lusr con _tid cnv -> do
let lcnv = qualifyAs lusr cnv
void $ API.deleteLocalConversation lusr con lcnv