Conversation
The new OCA\Approval\Events\ApprovalStateChangedEvent is dispatched when an approval is requested, approved or rejected, right before the corresponding system tags are (un)assigned. Next to the acting user it carries the user who requested the approval. That information is otherwise lost on approve/reject, because the pending activity row is replaced by the approver's one before the tag change is triggered. This enables other apps, e.g. workflow engines like workflow_script, to react to approval state changes on behalf of the requester, see nextcloud/workflow_script#363 Signed-off-by: eli <shark_xc@hotmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Apps reacting to approval state changes (e.g. via workflow engine rules on the approval tags) currently cannot know who requested an approval:
approval_activityrow holding the requester is replaced bystoreAction()before the tag change is triggeredThis was reported in nextcloud/workflow_script#363, where a flow script needs the requester's user id to route the file after approval.
What this PR does
Adds
OCA\Approval\Events\ApprovalStateChangedEvent, dispatched viadispatchTyped()when an approval isApprovalService::request())requestViaTagAssignment())approve())reject())The event carries:
getFileId()getRuleId()getNewState()Application::STATE_PENDING/STATE_APPROVED/STATE_REJECTEDgetActorUserId()getRequesterUserId()On approve/reject the requester is read via
getLastAction(..., STATE_PENDING)beforestoreAction()replaces that row, and the event is dispatched before the tags change, so listeners reacting to the tag assignment events (like workflow engines) already have the context within the same request.A unit test asserts the events and their payloads on request and approve.
Counterpart
This enables nextcloud/workflow_script#363 — consumed by nextcloud/workflow_script#534 which adds a
%rplaceholder for the requester's user id.