-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DANS/7564 messaging from workflows #7635
DANS/7564 messaging from workflows #7635
Conversation
case WORKFLOW_FAILURE: | ||
version = (DatasetVersion) targetObject; | ||
pattern = BundleUtil.getStringFromBundle("notification.email.workflow.failure"); | ||
String[] paramArrayWorkflowFailure = {version.getDataset().getDisplayName(), getDatasetLink(version.getDataset())}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading this correctly, that it's not populating the 3rd parameter of notification.email.workflow.failure
pattern here?
So, should probably be
{version.getDataset().getDisplayName(), getDatasetLink(version.getDataset()), comment};
(it's probably more important to show the "reason" comment in the failure email, than in the success one...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - not sure why I left it out - perhaps I just tested failure prior to adding the messaging part and didn't update it later. In any case, added now.
} | ||
|
||
/** | ||
* Holds the user-friendly message explaining the failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not very "friendly", to claim it's a failure, even though it's a success! :)
(I know, it's just a copy-and-paste thing...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sadly this workflow successfully completed as designed. Please contact support if you are disappointed because you were expecting something less reliable." :-) - fixed.
@@ -171,10 +178,20 @@ private void doResume(PendingWorkflowInvocation pending, String body) { | |||
final WorkflowContext ctxt = refresh(newCtxt,retrieveRequestedSettings( wf.getRequiredSettings()), getCurrentApiToken(newCtxt.getRequest().getAuthenticatedUser())); | |||
WorkflowStepResult res = pendingStep.resume(ctxt, pending.getLocalData(), body); | |||
if (res instanceof Failure) { | |||
userNotificationService.sendNotification(ctxt.getRequest().getAuthenticatedUser(), Timestamp.from(Instant.now()), UserNotification.Type.WORKFLOW_FAILURE, ctxt.getDataset().getLatestVersion().getId(), ((Failure) res).getMessage()); | |||
//UserNotification isn't meant to be a long-term record and doesn't store the comment, so we'll also keep it as a workflow comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand this correctly, that these notifications for workflow success and failure are email-only; in that you are purposefully excluding them from being shown on the dataverseuser.xhtml page? In part, I'm assuming, because of the above, that the custom comment/message doesn't get stored in the database. And with the assumption that the message will be shown to the user using the workflow UI messaging...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... having read the PR description one more time though, you are saying
a new enum type of UserNotification (resulting in an email and addition on the notification tab)
so, is it "purposefully", or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notification should be standard and show up in both places. The comment is just noting that UserNotification doesn't include a comment field, so the comment goes out in the email but isn't saved as part of the UserNotification . So, when I need to show something on the page which includes the comment, I needed a place to store the comment.
An alternate design would be to add a comment field to UserNotification but that was bigger, not necessarily something we'd want for other notifications, and the WorkflowComment class seemed to be ~intended for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I may be being slow here, but I just didn't see any code being added to dataverseuser.xhtml, that would show these new notifications in that tab. So my first assumption was that it was on purpose. Although, on a 2nd or 3rd thought, that could be confusing - if the little red alert in the account header is showing that there's one new notification, but nothing new is showing in the notifications tab - ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not intentional - I missed it, so the count goes up and a line in the table shows the date (done for all notifications), but there's not dataverseuser.xhtml fragment to provide the info specific to these types. I'll add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense. I obviously didn't remember how that tab was working either; my recollection was that every table entry had to be hard-coded in full.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this solution for reporting the results of tasks that are executed asynchronously.
I mostly figured out how the actual messaging/notifications work. But please see my individual comments.
The following is not important for the purposes of approving and merging the PR, but something I've been thinking about:
Should/could this WorkflowComment mechanism be used for informing the user about the status of other things that happen during asynchronous publication, that are not part of a specific workflow? Specifically, the global id registration. We didn't have any way of communicating to the user about datacite failures during asynchronous publishing; so we solved it by adding a special UserNotification for such failures. But adding a WorkflowComment as well would be an easy way to get a more prominent message right on the dataset page - ?
... and is shown as a green/yellow(warning - for Failures) banner if the user remains on/returns to the associated dataset page. The latter mirrors the functionality for the overall publication process.
There is actually no overall "success" message with async publishing; there's a UserNotification (and there's the fact that the dataset is no longer locked, and the version is no longer draft), but there's no explicit "success! ..." banner. And as of 5.0, publishing is always asynchronous.
In fact Mike just opened an issue, asking for a "publish success" banner (#7653). Again, is another WorkflowComment an obvious solution here?
(I'm assuming the 3 conflicts are being reported because #7568 has been merged - but these need to be resolved) |
@landreev - Thanks for the thorough review - yeah, aside from WorkflowComment potentially implying a Workflow, I was also thinking it could be a general mechanism for async processing (and #7653 in particular) (and for external tools/api actions?). Minimally I was hoping this would cover doing the spam detection as a workflow, but broader use for anything async should work - maybe a future refactor to rename the class? Or adding the comment field and has been shown flag to UserNotification at some point? |
DANS/7564_messaging_from_workflows Conflicts: doc/sphinx-guides/source/developers/workflows.rst src/main/java/edu/harvard/iq/dataverse/UserNotification.java src/main/java/edu/harvard/iq/dataverse/workflow/internalspi/AuthorizedExternalStep.java src/main/java/edu/harvard/iq/dataverse/workflow/step/Success.java
The branch is looking good now. |
~yeah - a name change is easy, but I guess bundling that with the first non-workflow use would make more sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the PR into QA.
This works but did find a few issues for review:
|
Just committed fixes for the issues above (including both '5's :-) ) except: |
Have not been able to get null in email when failure due to parsing error to work. Passing back for now. |
What this PR does / why we need it: Defines a mechanism for workflows to send a messages (strings) - one that will be logged and one to be shown to the user upon successful/unsuccessful completion. The user message is added as a new enum type of UserNotification (resulting in an email and addition on the notification tab), and is show as a green/yellow(warning - for Failures) banner if the user remains on/returns to the associated dataset page. The latter mirrors the functionality for the overall publication process. The new mechanism is required because workflows run asynchronously (and don't otherwise interact with the DatasetPage after being launched).
Expected initial uses include DANS' migration process and a potential refactoring of the invocation of spam processing prior to dataset publication.
Which issue(s) this PR closes:
Closes #7564
Special notes for your reviewer: aligned with the initial slack discussion I had with Gustavo about ways of providing a banner.
Suggestions on how to test this: The easiest way is to setup the new pause/message step and to then respond with a success/failure json object per the new workflow documentation on that step. The optional Reason and Message entries in the object should show in the log and as a banner/notification (respectively).
Does this PR introduce a user interface change? If mockups are available, please link/include them here: uses existing GUI elements for two new events (workflow success/failure), but doesn't change the display otherwise.
Is there a release notes update needed for this change?: could note the functionality, but it developer-level. The only config change required is the flyway script, so automatic.
Additional documentation: