Skip to content

Commit 6364aeb

Browse files
committed
WPB-23789: Move operation to ConversationSubsystem
1 parent e3691a9 commit 6364aeb

103 files changed

Lines changed: 3515 additions & 1809 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

changelog.d/5-internal/WPB-23789

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### ConversationSubsystem Migration
2+
3+
* Move conversation-related operations into a unified Polysemy `ConversationSubsystem` effect across the wire-server codebase.
4+
This consolidation improves code organization and separation of concerns for conversation logic.
5+
6+
* Library updates:
7+
- Introduced dedicated error types for ConversationSubsystem to improve error handling
8+
- Consolidated conversation-related operations that were previously scattered across multiple stores and subsystems
9+
10+
**Note:** The background-worker configuration now has a dependency on the shared global settings.
11+
Deployments that previously set these values in both galley and background-worker sections
12+
can consolidate them into the global.settings section.

charts/wire-server/templates/_helpers.tpl

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,180 @@
163163
{{- end -}}
164164
{{- end -}}
165165

166+
{{/* SHARED SETTINGS */}}
167+
{{- define "wire-server.settings.common" -}}
168+
maxTeamSize: {{ .maxTeamSize }}
169+
maxConvSize: {{ .maxConvSize }}
170+
intraListing: {{ .intraListing }}
171+
{{- if .maxFanoutSize }}
172+
maxFanoutSize: {{ .maxFanoutSize }}
173+
{{- end }}
174+
{{- if .exposeInvitationURLsTeamAllowlist }}
175+
exposeInvitationURLsTeamAllowlist: {{ toYaml .exposeInvitationURLsTeamAllowlist | nindent 8 }}
176+
{{- end }}
177+
{{- if .conversationCodeURI }}
178+
conversationCodeURI: {{ .conversationCodeURI | quote }}
179+
{{- else if .multiIngress }}
180+
multiIngress: {{- toYaml .multiIngress | nindent 8 }}
181+
{{- else }}
182+
{{ fail "Either settings.conversationCodeURI or settings.multiIngress have to be set" }}
183+
{{- end }}
184+
{{- if (and .conversationCodeURI .multiIngress) }}
185+
{{ fail "settings.conversationCodeURI and settings.multiIngress are mutually exclusive" }}
186+
{{- end }}
187+
{{- if hasKey . "httpPoolSize" }}
188+
httpPoolSize: {{ .httpPoolSize }}
189+
{{- end }}
190+
{{- if hasKey . "federationDomain" }}
191+
federationDomain: {{ .federationDomain }}
192+
{{- end }}
193+
{{- if .federationProtocols }}
194+
federationProtocols: {{ .federationProtocols | toJson }}
195+
{{- end }}
196+
{{- if .mlsPrivateKeyPaths }}
197+
mlsPrivateKeyPaths: {{- toYaml .mlsPrivateKeyPaths | nindent 8 }}
198+
{{- end }}
199+
{{- if .concurrentDeletionEvents }}
200+
concurrentDeletionEvents: {{ .concurrentDeletionEvents }}
201+
{{- end }}
202+
{{- if .deleteConvThrottleMillis }}
203+
deleteConvThrottleMillis: {{ .deleteConvThrottleMillis }}
204+
{{- end }}
205+
{{- if hasKey . "disabledAPIVersions" }}
206+
disabledAPIVersions: {{ toJson .disabledAPIVersions }}
207+
{{- end }}
208+
{{- if .guestLinkTTLSeconds }}
209+
guestLinkTTLSeconds: {{ .guestLinkTTLSeconds }}
210+
{{- end }}
211+
passwordHashingOptions: {{ toYaml .passwordHashingOptions | nindent 8 }}
212+
passwordHashingRateLimit: {{ toYaml .passwordHashingRateLimit | nindent 8 }}
213+
{{- if .checkGroupInfo }}
214+
checkGroupInfo: {{ .checkGroupInfo }}
215+
{{- end }}
216+
{{- if hasKey . "meetings" }}
217+
meetings:
218+
{{- toYaml .meetings | nindent 8 }}
219+
{{- end }}
220+
{{- if .featureFlags }}
221+
featureFlags:
222+
sso: {{ .featureFlags.sso }}
223+
legalhold: {{ .featureFlags.legalhold }}
224+
teamSearchVisibility: {{ .featureFlags.teamSearchVisibility }}
225+
classifiedDomains:
226+
{{- toYaml .featureFlags.classifiedDomains | nindent 10 }}
227+
{{- if .featureFlags.fileSharing }}
228+
fileSharing:
229+
{{- toYaml .featureFlags.fileSharing | nindent 10 }}
230+
{{- end }}
231+
{{- if .featureFlags.enforceFileDownloadLocation }}
232+
enforceFileDownloadLocation:
233+
{{- toYaml .featureFlags.enforceFileDownloadLocation | nindent 10 }}
234+
{{- end }}
235+
{{- if .featureFlags.sndFactorPasswordChallenge }}
236+
sndFactorPasswordChallenge:
237+
{{- toYaml .featureFlags.sndFactorPasswordChallenge | nindent 10 }}
238+
{{- end }}
239+
{{- if .featureFlags.searchVisibilityInbound }}
240+
searchVisibilityInbound:
241+
{{- toYaml .featureFlags.searchVisibilityInbound | nindent 10 }}
242+
{{- end }}
243+
{{- /* Accept the legacy typo in Helm values, but always render the canonical Galley key. */}}
244+
{{- $validateSAMLemails := .featureFlags.validateSAMLemails | default .featureFlags.validateSAMLEmails }}
245+
{{- if $validateSAMLemails }}
246+
validateSAMLemails:
247+
{{- toYaml $validateSAMLemails | nindent 10 }}
248+
{{- end }}
249+
{{- if .featureFlags.appLock }}
250+
appLock:
251+
{{- toYaml .featureFlags.appLock | nindent 10 }}
252+
{{- end }}
253+
{{- if .featureFlags.conferenceCalling }}
254+
conferenceCalling:
255+
{{- toYaml .featureFlags.conferenceCalling | nindent 10 }}
256+
{{- end }}
257+
{{- if .featureFlags.selfDeletingMessages }}
258+
selfDeletingMessages:
259+
{{- toYaml .featureFlags.selfDeletingMessages | nindent 10 }}
260+
{{- end }}
261+
{{- if .featureFlags.conversationGuestLinks }}
262+
conversationGuestLinks:
263+
{{- toYaml .featureFlags.conversationGuestLinks | nindent 10 }}
264+
{{- end }}
265+
{{- if .featureFlags.mls }}
266+
mls:
267+
{{- toYaml .featureFlags.mls | nindent 10 }}
268+
{{- end }}
269+
{{- if .featureFlags.outlookCalIntegration }}
270+
outlookCalIntegration:
271+
{{- toYaml .featureFlags.outlookCalIntegration | nindent 10 }}
272+
{{- end }}
273+
{{- if .featureFlags.mlsE2EId }}
274+
mlsE2EId:
275+
{{- toYaml .featureFlags.mlsE2EId | nindent 10 }}
276+
{{- end }}
277+
{{- if .featureFlags.mlsMigration }}
278+
mlsMigration:
279+
{{- toYaml .featureFlags.mlsMigration | nindent 10 }}
280+
{{- end }}
281+
{{- if .featureFlags.limitedEventFanout }}
282+
limitedEventFanout:
283+
{{- toYaml .featureFlags.limitedEventFanout | nindent 10 }}
284+
{{- end }}
285+
{{- if .featureFlags.domainRegistration }}
286+
domainRegistration:
287+
{{- toYaml .featureFlags.domainRegistration | nindent 10 }}
288+
{{- end }}
289+
{{- if .featureFlags.channels }}
290+
channels:
291+
{{- toYaml .featureFlags.channels | nindent 10 }}
292+
{{- end }}
293+
{{- if .featureFlags.cells }}
294+
cells:
295+
{{- toYaml .featureFlags.cells | nindent 10 }}
296+
{{- end }}
297+
{{- if .featureFlags.cellsInternal }}
298+
cellsInternal:
299+
{{- toYaml .featureFlags.cellsInternal | nindent 10 }}
300+
{{- end }}
301+
{{- if .featureFlags.allowedGlobalOperations }}
302+
allowedGlobalOperations:
303+
{{- toYaml .featureFlags.allowedGlobalOperations | nindent 10 }}
304+
{{- end }}
305+
{{- if .featureFlags.assetAuditLog }}
306+
assetAuditLog:
307+
{{- toYaml .featureFlags.assetAuditLog | nindent 10 }}
308+
{{- end }}
309+
{{- if .featureFlags.consumableNotifications }}
310+
consumableNotifications:
311+
{{- toYaml .featureFlags.consumableNotifications | nindent 10 }}
312+
{{- end }}
313+
{{- if .featureFlags.chatBubbles }}
314+
chatBubbles:
315+
{{- toYaml .featureFlags.chatBubbles | nindent 10 }}
316+
{{- end }}
317+
{{- if .featureFlags.apps }}
318+
apps:
319+
{{- toYaml .featureFlags.apps | nindent 10 }}
320+
{{- end }}
321+
{{- if .featureFlags.simplifiedUserConnectionRequestQRCode }}
322+
simplifiedUserConnectionRequestQRCode:
323+
{{- toYaml .featureFlags.simplifiedUserConnectionRequestQRCode | nindent 10 }}
324+
{{- end }}
325+
{{- if .featureFlags.stealthUsers }}
326+
stealthUsers:
327+
{{- toYaml .featureFlags.stealthUsers | nindent 10 }}
328+
{{- end }}
329+
{{- if .featureFlags.meetings }}
330+
meetings:
331+
{{- toYaml .featureFlags.meetings | nindent 10 }}
332+
{{- end }}
333+
{{- if .featureFlags.meetingsPremium }}
334+
meetingsPremium:
335+
{{- toYaml .featureFlags.meetingsPremium | nindent 10 }}
336+
{{- end }}
337+
{{- end }}
338+
{{- end -}}
339+
166340
{{/* Compute the SCIM base URI
167341
168342
The rules are:

charts/wire-server/values.yaml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tags:
1111
backoffice: false
1212
mlsstats: false
1313
integration: false
14+
proxy: false
1415

1516
galley:
1617
replicaCount: 3
@@ -663,43 +664,6 @@ cannon:
663664
# effect: "NoSchedule"
664665
tolerations: []
665666

666-
proxy:
667-
replicaCount: 3
668-
image:
669-
repository: quay.io/wire/proxy
670-
tag: do-not-use
671-
service:
672-
externalPort: 8080
673-
internalPort: 8080
674-
imagePullPolicy: ""
675-
metrics:
676-
serviceMonitor:
677-
enabled: false
678-
resources:
679-
requests:
680-
memory: "25Mi"
681-
cpu: "50m"
682-
limits:
683-
memory: "50Mi"
684-
config:
685-
logLevel: Info
686-
logFormat: StructuredJSON
687-
logNetStrings: false
688-
proxy: {}
689-
# Disable one ore more API versions. Please make sure the configuration value is the same in all these charts:
690-
# brig, cannon, cargohold, galley, gundeck, proxy, spar.
691-
disabledAPIVersions: [development]
692-
693-
podSecurityContext:
694-
allowPrivilegeEscalation: false
695-
capabilities:
696-
drop:
697-
- ALL
698-
runAsNonRoot: true
699-
seccompProfile:
700-
type: RuntimeDefault
701-
secrets: {}
702-
703667
gundeck:
704668
replicaCount: 3
705669
image:

hack/helm_vars/wire-server/values.yaml.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tags:
55
legalhold: false
66
sftd: false
77
integration: true
8+
proxy: true
89

910
consumableNotifications: false
1011

libs/wire-api/src/Wire/API/Team/FeatureFlags.hs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ module Wire.API.Team.FeatureFlags
2525
FeatureFlags,
2626
FanoutLimit,
2727
featureDefaults,
28+
defaultFanoutLimit,
29+
currentFanoutLimit,
2830
notTeamMember,
2931
findTeamMember,
3032
isTeamMember,
@@ -42,7 +44,7 @@ import Data.ByteString.UTF8 qualified as UTF8
4244
import Data.Default
4345
import Data.Id (UserId)
4446
import Data.OpenApi qualified as S
45-
import Data.Range (Range)
47+
import Data.Range (Range, fromRange, toRange, unsafeRange)
4648
import Data.SOP
4749
import Data.Schema
4850
import Data.Set qualified as Set
@@ -53,6 +55,15 @@ import Wire.API.Team.Permission
5355

5456
type FanoutLimit = Range 1 HardTruncationLimit Int32
5557

58+
defaultFanoutLimit :: FanoutLimit
59+
defaultFanoutLimit = toRange (Proxy @HardTruncationLimit)
60+
61+
currentFanoutLimit :: Word32 -> Maybe FanoutLimit -> FanoutLimit
62+
currentFanoutLimit maxTeamSize maxFanoutSize =
63+
let optFanoutLimit = fromIntegral . fromRange $ fromMaybe defaultFanoutLimit maxFanoutSize
64+
maxSize = fromIntegral maxTeamSize
65+
in unsafeRange (min maxSize optFanoutLimit)
66+
5667
-- | Used to extract the feature config type out of 'FeatureDefaults' or
5768
-- related types.
5869
type family ConfigOf a

libs/wire-subsystems/default.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
, bytestring-conversion
2424
, case-insensitive
2525
, cassandra-util
26+
, comonad
2627
, conduit
2728
, constraints
2829
, containers
@@ -66,6 +67,7 @@
6667
, imports
6768
, iproute
6869
, iso639
70+
, kan-extensions
6971
, lens
7072
, lib
7173
, lrucaching
@@ -158,6 +160,7 @@ mkDerivation {
158160
bytestring-conversion
159161
case-insensitive
160162
cassandra-util
163+
comonad
161164
conduit
162165
constraints
163166
containers
@@ -197,6 +200,7 @@ mkDerivation {
197200
imports
198201
iproute
199202
iso639
203+
kan-extensions
200204
lens
201205
lrucaching
202206
memory
@@ -279,6 +283,7 @@ mkDerivation {
279283
bytestring-conversion
280284
case-insensitive
281285
cassandra-util
286+
comonad
282287
conduit
283288
constraints
284289
containers
@@ -319,6 +324,7 @@ mkDerivation {
319324
imports
320325
iproute
321326
iso639
327+
kan-extensions
322328
lens
323329
lrucaching
324330
memory

libs/wire-subsystems/src/Wire/BackgroundJobsRunner/Interpreter.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import Wire.API.UserGroup
4444
import Wire.BackgroundJobsPublisher
4545
import Wire.BackgroundJobsRunner (BackgroundJobsRunner (..))
4646
import Wire.ConversationStore (ConversationStore, getConversation, upsertMembers)
47-
import Wire.ConversationSubsystem
47+
import Wire.ConversationSubsystem hiding (getConversation)
4848
import Wire.Sem.Random
4949
import Wire.StoredConversation
5050
import Wire.UserGroupStore (UserGroupStore, getUserGroup, getUserGroupChannels)

libs/wire-subsystems/src/Wire/BrigAPIAccess.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ module Wire.BrigAPIAccess
7171
deleteGroupInternal,
7272
deleteApp,
7373
DeleteGroupManagedError (..),
74+
75+
-- * Assertions
76+
ensureConnectedToLocals,
7477
)
7578
where
7679

@@ -88,6 +91,7 @@ import Polysemy
8891
import Polysemy.Error
8992
import Web.Scim.Filter qualified as Scim
9093
import Wire.API.Connection
94+
import Wire.API.Error
9195
import Wire.API.Error.Galley
9296
import Wire.API.MLS.CipherSuite
9397
import Wire.API.Routes.Internal.Brig
@@ -192,3 +196,17 @@ getConnectionsUnqualifiedBidi uids1 uids2 mrel1 mrel2 = do
192196
res1 <- getConnectionsUnqualified uids1 (Just uids2) mrel1
193197
res2 <- getConnectionsUnqualified uids2 (Just uids1) mrel2
194198
pure (res1, res2)
199+
200+
ensureConnectedToLocals ::
201+
( Member (ErrorS 'NotConnected) r,
202+
Member BrigAPIAccess r
203+
) =>
204+
UserId ->
205+
[UserId] ->
206+
Sem r ()
207+
ensureConnectedToLocals _ [] = pure ()
208+
ensureConnectedToLocals u uids = do
209+
(connsFrom, connsTo) <-
210+
getConnectionsUnqualifiedBidi [u] uids (Just Accepted) (Just Accepted)
211+
unless (length connsFrom == length uids && length connsTo == length uids) $
212+
throwS @'NotConnected

libs/wire-subsystems/src/Wire/ConversationStore/Cassandra.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ addMembers conv (UserList lusers rusers) = do
455455
-- User is remote, so we only add it to the member_remote_user
456456
-- table, but the reverse mapping has to be done on the remote
457457
-- backend; so we assume an additional call to their backend has
458-
-- been (or will be) made separately. See Galley.API.Update.addMembers
458+
-- been (or will be) made separately. See Wire.ConversationSubsystem.Update.addMembers
459459
addPrepQuery Cql.insertRemoteMember (conv, domain, uid, role)
460460

461461
pure (map newMemberWithRole lusers, map newRemoteMemberWithRole rusers)

0 commit comments

Comments
 (0)