From 873a82ce46a7054d6ffec255f7cfc8ce3f206818 Mon Sep 17 00:00:00 2001 From: Leif Battermann Date: Fri, 27 Feb 2026 09:22:01 +0000 Subject: [PATCH] spike --- .../src/Wire/DeleteConversationSubsystem.hs | 35 +++++++++ libs/wire-subsystems/wire-subsystems.cabal | 1 + services/galley/galley.cabal | 1 + services/galley/src/Galley/API/Teams.hs | 27 ++----- services/galley/src/Galley/App.hs | 2 + services/galley/src/Galley/Effects.hs | 3 + .../Effects/DeleteConversationSubsystem.hs | 72 +++++++++++++++++++ 7 files changed, 118 insertions(+), 23 deletions(-) create mode 100644 libs/wire-subsystems/src/Wire/DeleteConversationSubsystem.hs create mode 100644 services/galley/src/Galley/Effects/DeleteConversationSubsystem.hs diff --git a/libs/wire-subsystems/src/Wire/DeleteConversationSubsystem.hs b/libs/wire-subsystems/src/Wire/DeleteConversationSubsystem.hs new file mode 100644 index 00000000000..a8073f11ab8 --- /dev/null +++ b/libs/wire-subsystems/src/Wire/DeleteConversationSubsystem.hs @@ -0,0 +1,35 @@ +{-# LANGUAGE TemplateHaskell #-} + +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2026 Wire Swiss GmbH +-- +-- 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 . + +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 diff --git a/libs/wire-subsystems/wire-subsystems.cabal b/libs/wire-subsystems/wire-subsystems.cabal index 77419041f76..9923c60f4a2 100644 --- a/libs/wire-subsystems/wire-subsystems.cabal +++ b/libs/wire-subsystems/wire-subsystems.cabal @@ -251,6 +251,7 @@ library Wire.ConversationSubsystem.Interpreter Wire.ConversationSubsystem.One2One Wire.ConversationSubsystem.Util + Wire.DeleteConversationSubsystem Wire.DeleteQueue Wire.DeleteQueue.InMemory Wire.DomainRegistrationStore diff --git a/services/galley/galley.cabal b/services/galley/galley.cabal index f0586d727e9..99eb8d7969a 100644 --- a/services/galley/galley.cabal +++ b/services/galley/galley.cabal @@ -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 diff --git a/services/galley/src/Galley/API/Teams.hs b/services/galley/src/Galley/API/Teams.hs index fa73ab30a53..6495472eadb 100644 --- a/services/galley/src/Galley/API/Teams.hs +++ b/services/galley/src/Galley/API/Teams.hs @@ -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 @@ -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 @@ -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, diff --git a/services/galley/src/Galley/App.hs b/services/galley/src/Galley/App.hs index aeb8718c92e..40ae2203626 100644 --- a/services/galley/src/Galley/App.hs +++ b/services/galley/src/Galley/App.hs @@ -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 @@ -450,6 +451,7 @@ evalGalley e = . runInputSem getAllTeamFeaturesForServer . interpretTeamCollaboratorsSubsystem . runFederationSubsystem conversationSubsystemConfig.federationProtocols + . interpretDeleteConversationSubsystem . interpretConversationSubsystem . Meeting.interpretMeetingsSubsystem meetingValidityPeriod where diff --git a/services/galley/src/Galley/Effects.hs b/services/galley/src/Galley/Effects.hs index c6bf5c7309f..c34560732fc 100644 --- a/services/galley/src/Galley/Effects.hs +++ b/services/galley/src/Galley/Effects.hs @@ -49,6 +49,7 @@ module Galley.Effects -- * Other effects Queue, + DeleteConversationSubsystem, -- * Polysemy re-exports Member, @@ -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) @@ -121,6 +123,7 @@ import Wire.UserGroupStore type GalleyEffects1 = '[ MeetingsSubsystem, ConversationSubsystem, + DeleteConversationSubsystem, FederationSubsystem, TeamCollaboratorsSubsystem, Input AllTeamFeatures, diff --git a/services/galley/src/Galley/Effects/DeleteConversationSubsystem.hs b/services/galley/src/Galley/Effects/DeleteConversationSubsystem.hs new file mode 100644 index 00000000000..319d3903c68 --- /dev/null +++ b/services/galley/src/Galley/Effects/DeleteConversationSubsystem.hs @@ -0,0 +1,72 @@ +-- This file is part of the Wire Server implementation. +-- +-- Copyright (C) 2026 Wire Swiss GmbH +-- +-- 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 . + +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