From 192fb3f6a9e2a1f1e14e2171c404c6561d7a8edf Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Fri, 29 May 2026 12:27:02 +0200 Subject: [PATCH 1/2] Changelog. --- .../2-features/WPB-25982-distribution-state-for-collaborators | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/2-features/WPB-25982-distribution-state-for-collaborators diff --git a/changelog.d/2-features/WPB-25982-distribution-state-for-collaborators b/changelog.d/2-features/WPB-25982-distribution-state-for-collaborators new file mode 100644 index 0000000000..6fe187c987 --- /dev/null +++ b/changelog.d/2-features/WPB-25982-distribution-state-for-collaborators @@ -0,0 +1 @@ +Distribution state for collaborators. From 12072dce7c86b52bb408d2daaf48e88fa9296304 Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Fri, 29 May 2026 12:42:06 +0200 Subject: [PATCH 2/2] Types and routes [WIP] --- .../src/Wire/API/Routes/Public/Brig.hs | 11 ++++++ libs/wire-api/src/Wire/API/User.hs | 38 +++++++++++++++++++ .../API/Golden/Generated/SelfProfile_user.hs | 1 + 3 files changed, 50 insertions(+) diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Brig.hs b/libs/wire-api/src/Wire/API/Routes/Public/Brig.hs index 760b7da289..d9daf00397 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Brig.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Brig.hs @@ -188,6 +188,17 @@ type UserAPI = :> ReqBody '[JSON] EmailUpdate :> Put '[JSON] () ) + :<|> Named + "update-collaborator-settings" + ( Summary "Set user's distribution status as collaborator in other teams. Default: none" + :> From 'V5 + :> ZLocalUser + :> "users" + :> QualifiedCaptureUserId "uid" + :> "collaborator-settings" + :> ReqBody '[JSON] CollaboratorSettings + :> Put '[JSON] () + ) :<|> Named "get-handle-info-unqualified" ( Summary "(deprecated, use /search/contacts) Get information on a user handle" diff --git a/libs/wire-api/src/Wire/API/User.hs b/libs/wire-api/src/Wire/API/User.hs index 889e22a619..95d83ef984 100644 --- a/libs/wire-api/src/Wire/API/User.hs +++ b/libs/wire-api/src/Wire/API/User.hs @@ -35,6 +35,7 @@ module Wire.API.User -- User (should not be here) User (..), UserType (..), + CollaboratorSettings (..), isSamlUser, userId, userDeleted, @@ -626,6 +627,8 @@ data User = User -- | Set if the user represents an external service, -- i.e. it is a "bot". userService :: Maybe ServiceRef, + -- | How user behaves in other teams as collaborator. + userCollaboratorSettings :: Maybe CollaboratorSettings, -- | not required; must be unique if present userHandle :: Maybe Handle, -- | Set if the user is ephemeral @@ -642,6 +645,40 @@ data User = User deriving (Arbitrary) via (GenericUniform User) deriving (ToJSON, FromJSON, S.ToSchema) via (Schema User) +-- | How user behaves in other teams as collaborator. +-- TODO(fisx): maybe move to a better place? +-- TODO(fisx): golden tests. +data CollaboratorSettings = CollaboratorSettings + { distributionState :: CollaboratorDistributionState + } + deriving stock (Eq, Ord, Show, Generic) + deriving (Arbitrary) via (GenericUniform CollaboratorSettings) + deriving (ToJSON, FromJSON, S.ToSchema) via (Schema CollaboratorSettings) + +instance ToSchema CollaboratorSettings where + schema = + object $ + CollaboratorSettings + <$> distributionState .= field "distribution_state" schema + +-- TODO(fisx): maybe move to a better place? +data CollaboratorDistributionState + = CollaboratorDraft + | CollaboratorNoDistribution + | CollaboratorFullDistribution + deriving stock (Eq, Ord, Show, Generic) + deriving (Arbitrary) via (GenericUniform CollaboratorDistributionState) + deriving (ToJSON, FromJSON, S.ToSchema) via (Schema CollaboratorDistributionState) + +instance ToSchema CollaboratorDistributionState where + schema = + enum @Text $ + mconcat + [ element "draft" CollaboratorDraft, + element "none" CollaboratorNoDistribution, + element "full" CollaboratorFullDistribution + ] + isSamlUser :: User -> Bool isSamlUser usr = do case usr.userIdentity of @@ -682,6 +719,7 @@ userObjectSchema = <*> userStatus .= field "status" schema <*> userLocale .= field "locale" schema <*> userService .= maybe_ (optField "service" schema) + <*> userCollaboratorSettings .= maybe_ (optField "collaborator_settings" schema) <*> userHandle .= maybe_ (optField "handle" schema) <*> userExpire .= maybe_ (optField "expires_at" schema) <*> userTeam .= maybe_ (optField "team" schema) diff --git a/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/SelfProfile_user.hs b/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/SelfProfile_user.hs index 44eab4b0d5..4f1758f4f2 100644 --- a/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/SelfProfile_user.hs +++ b/libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/SelfProfile_user.hs @@ -59,6 +59,7 @@ testObject_SelfProfile_user_1 = _serviceRefProvider = Id (fromJust (UUID.fromString "00000000-0000-0001-0000-000000000001")) } ), + userCollaboratorSettings = Nothing, userHandle = Just (fromJust (parseHandle "do9-5")), userExpire = Just (fromJust (readUTCTimeMillis "1864-05-07T21:09:29.342Z")), userTeam = Just (Id (fromJust (UUID.fromString "00000001-0000-0002-0000-000000000002"))),