Skip to content
Merged
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
1 change: 1 addition & 0 deletions changelog.d/5-internal/pr-3030
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Branch on performAction tags for finer-grained CallsFed constraints
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 25 additions & 9 deletions services/galley/src/Galley/API/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
--
-- 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/>.
{-# LANGUAGE StandaloneKindSignatures #-}

module Galley.API.Action
( -- * Conversation action types
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down
1 change: 0 additions & 1 deletion services/galley/src/Galley/API/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
12 changes: 0 additions & 12 deletions services/galley/src/Galley/API/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
) =>
Expand Down Expand Up @@ -380,7 +379,6 @@ updateRemoteConversation ::
TinyLog
]
r,
Members (HasConversationActionGalleyErrors tag) r,
RethrowErrors (HasConversationActionGalleyErrors tag) (Error NoChanges : r),
SingI tag,
CallsFed 'Galley "update-conversation"
Expand Down Expand Up @@ -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"
) =>
Expand All @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand All @@ -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 ->
Expand Down