diff --git a/changelog.d/5-internal/pr-3030 b/changelog.d/5-internal/pr-3030 new file mode 100644 index 0000000000..4a8bede709 --- /dev/null +++ b/changelog.d/5-internal/pr-3030 @@ -0,0 +1 @@ +Branch on performAction tags for finer-grained CallsFed constraints diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs b/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs index 3c877fe475..da6a4b53a9 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs @@ -701,7 +701,6 @@ type ConversationAPI = ( Summary "Update membership of the specified user (deprecated)" :> Description "Use `PUT /conversations/:cnv_domain/:cnv/members/:usr_domain/:usr` instead" :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> ZLocalUser :> ZConn @@ -726,7 +725,6 @@ type ConversationAPI = ( Summary "Update membership of the specified user" :> Description "**Note**: at least one field has to be provided." :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> ZLocalUser :> ZConn @@ -753,7 +751,6 @@ type ConversationAPI = ( Summary "Update conversation name (deprecated)" :> Description "Use `/conversations/:domain/:conv/name` instead." :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> CanThrow ('ActionDenied 'ModifyConversationName) :> CanThrow 'ConvNotFound @@ -774,7 +771,6 @@ type ConversationAPI = ( Summary "Update conversation name (deprecated)" :> Description "Use `/conversations/:domain/:conv/name` instead." :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> CanThrow ('ActionDenied 'ModifyConversationName) :> CanThrow 'ConvNotFound @@ -795,7 +791,6 @@ type ConversationAPI = "update-conversation-name" ( Summary "Update conversation name" :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> CanThrow ('ActionDenied 'ModifyConversationName) :> CanThrow 'ConvNotFound @@ -819,7 +814,6 @@ type ConversationAPI = ( Summary "Update the message timer for a conversation (deprecated)" :> Description "Use `/conversations/:domain/:cnv/message-timer` instead." :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> ZLocalUser :> ZConn @@ -841,7 +835,6 @@ type ConversationAPI = "update-conversation-message-timer" ( Summary "Update the message timer for a conversation" :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> ZLocalUser :> ZConn @@ -866,7 +859,6 @@ type ConversationAPI = ( Summary "Update receipt mode for a conversation (deprecated)" :> Description "Use `PUT /conversations/:domain/:cnv/receipt-mode` instead." :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> MakesFederatedCall 'Galley "update-conversation" :> ZLocalUser @@ -889,7 +881,6 @@ type ConversationAPI = "update-conversation-receipt-mode" ( Summary "Update receipt mode for a conversation" :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> MakesFederatedCall 'Galley "update-conversation" :> ZLocalUser diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Galley/TeamConversation.hs b/libs/wire-api/src/Wire/API/Routes/Public/Galley/TeamConversation.hs index 76753f48f2..759b83c6cc 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Galley/TeamConversation.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Galley/TeamConversation.hs @@ -69,7 +69,6 @@ type TeamConversationAPI = "delete-team-conversation" ( Summary "Remove a team conversation" :> MakesFederatedCall 'Galley "on-conversation-updated" - :> MakesFederatedCall 'Galley "on-mls-message-sent" :> MakesFederatedCall 'Galley "on-new-remote-conversation" :> CanThrow ('ActionDenied 'DeleteConversation) :> CanThrow 'ConvNotFound diff --git a/services/galley/src/Galley/API/Action.hs b/services/galley/src/Galley/API/Action.hs index 03a344533b..2e638ec79c 100644 --- a/services/galley/src/Galley/API/Action.hs +++ b/services/galley/src/Galley/API/Action.hs @@ -14,6 +14,7 @@ -- -- You should have received a copy of the GNU Affero General Public License along -- with this program. If not, see . +{-# LANGUAGE StandaloneKindSignatures #-} module Galley.API.Action ( -- * Conversation action types @@ -272,14 +273,29 @@ ensureAllowed tag loc action conv origUser = do throwS @'InvalidTargetAccess _ -> pure () +type PerformActionCalls :: ConversationActionTag -> Constraint +type family PerformActionCalls tag where + PerformActionCalls 'ConversationAccessDataTag = + ( CallsFed 'Galley "on-conversation-updated", + CallsFed 'Galley "on-mls-message-sent", + CallsFed 'Galley "on-new-remote-conversation" + ) + PerformActionCalls 'ConversationJoinTag = + ( CallsFed 'Galley "on-conversation-updated", + CallsFed 'Galley "on-mls-message-sent", + CallsFed 'Galley "on-new-remote-conversation" + ) + PerformActionCalls 'ConversationLeaveTag = + ( CallsFed 'Galley "on-mls-message-sent" + ) + PerformActionCalls tag = () + -- | Returns additional members that resulted from the action (e.g. ConversationJoin) -- and also returns the (possible modified) action that was performed performAction :: forall tag r. ( HasConversationActionEffects tag r, - CallsFed 'Galley "on-mls-message-sent", - CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-new-remote-conversation" + PerformActionCalls tag ) => Sing tag -> Qualified UserId -> @@ -581,9 +597,9 @@ updateLocalConversation :: r, HasConversationActionEffects tag r, SingI tag, - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation", - CallsFed 'Galley "on-conversation-updated" + CallsFed 'Galley "on-conversation-updated", + PerformActionCalls tag ) => Local ConvId -> Qualified UserId -> @@ -621,9 +637,9 @@ updateLocalConversationUnchecked :: Member GundeckAccess r, Member (Input UTCTime) r, HasConversationActionEffects tag r, - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation", - CallsFed 'Galley "on-conversation-updated" + CallsFed 'Galley "on-conversation-updated", + PerformActionCalls tag ) => Local Conversation -> Qualified UserId -> @@ -819,9 +835,9 @@ kickMember :: Member (Input Env) r, Member MemberStore r, Member TinyLog r, - CallsFed 'Galley "on-mls-message-sent", + CallsFed 'Galley "on-new-remote-conversation", CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-new-remote-conversation" + PerformActionCalls 'ConversationLeaveTag ) => Qualified UserId -> Local Conversation -> diff --git a/services/galley/src/Galley/API/Teams.hs b/services/galley/src/Galley/API/Teams.hs index 20197ae4fc..fcad2b51e5 100644 --- a/services/galley/src/Galley/API/Teams.hs +++ b/services/galley/src/Galley/API/Teams.hs @@ -1120,7 +1120,6 @@ deleteTeamConversation :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> diff --git a/services/galley/src/Galley/API/Update.hs b/services/galley/src/Galley/API/Update.hs index 1065f4f92e..06133de467 100644 --- a/services/galley/src/Galley/API/Update.hs +++ b/services/galley/src/Galley/API/Update.hs @@ -343,7 +343,6 @@ updateConversationReceiptMode :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation", CallsFed 'Galley "update-conversation" ) => @@ -380,7 +379,6 @@ updateRemoteConversation :: TinyLog ] r, - Members (HasConversationActionGalleyErrors tag) r, RethrowErrors (HasConversationActionGalleyErrors tag) (Error NoChanges : r), SingI tag, CallsFed 'Galley "update-conversation" @@ -425,7 +423,6 @@ updateConversationReceiptModeUnqualified :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation", CallsFed 'Galley "update-conversation" ) => @@ -451,7 +448,6 @@ updateConversationMessageTimer :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -490,7 +486,6 @@ updateConversationMessageTimerUnqualified :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -518,7 +513,6 @@ deleteLocalConversation :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -1034,7 +1028,6 @@ updateOtherMemberLocalConv :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local ConvId -> @@ -1066,7 +1059,6 @@ updateOtherMemberUnqualified :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -1098,7 +1090,6 @@ updateOtherMember :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -1467,7 +1458,6 @@ updateConversationName :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -1498,7 +1488,6 @@ updateUnqualifiedConversationName :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId -> @@ -1525,7 +1514,6 @@ updateLocalConversationName :: ] r, CallsFed 'Galley "on-conversation-updated", - CallsFed 'Galley "on-mls-message-sent", CallsFed 'Galley "on-new-remote-conversation" ) => Local UserId ->