-
Notifications
You must be signed in to change notification settings - Fork 1
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
Send optional notifications via email #474
Changes from 1 commit
3767822
692f4c8
95c333c
654b316
1ae834f
ccf73a7
e87cece
9f7249f
e782888
2913061
21230f5
f5d4c90
94f434f
979edb5
cc61090
b64d89a
a2808c9
6565c4d
eb9fcf9
2343690
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,20 +28,16 @@ public EmailNotificationTransmitter( | |
@Override | ||
public void send(Notification notification) { | ||
if (notification.getUser().getEmailAddress() == null || notification.getUser().getEmailAddress().isBlank()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can move try to the top here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
log.error("Could not transmit a notification via email because subject {} has no email address.", | ||
log.warn("Could not transmit a notification via email because subject {} has no email address.", | ||
notification.getUser().getSubjectId()); | ||
return; | ||
} | ||
if (notification.isEmailEnabled()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need this if statement for enabling email per assessment through the protocol. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I do not understand what you did with the protocol. I cannot find the place where the NotificationProtocol is informed whether to use or not use email. I have the feeling that this protocol-based mechanism is a parallel track next to the conditional bean creation of the EmailTranmitterService:
And would this be not a more correct implementation if I understand your proposal well?
Note the isEmailEnabled check as first thing in the block? I am fine with readding this line, but I also would like to make sure that I understand it and change the other code accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Apologies, my bad. I should have included a rationale with the code. The information about whether to use email will come from the project protocol. This will be in the notifications key (e.g. here) in each assessment's protocol block. This is to make the email configuration more granular than enabling it to be deployment-wide. This is because of these reasons -
We are moving task and protocol scheduling from the aRMT app to the AppServer, so if you are still using scheduling in the app, you might need a minor update there. This would involve reading the new email block in the protocols, and passing this info (
Yes, you are correct. That is a better approach. If the email is not enabled for this notification (signified by the assessment in the protocol), then we don't execute the email-sending code. You can log a debug message if it was not executed due to emailEnabled=false, which can help debug issues with email sending. I hope this was clear, but if not, please feel free to Slack me, and we can discuss this further. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reintroduced the |
||
try { | ||
emailSender.send(createEmailFromNotification(notification)); | ||
} catch (Exception e) { | ||
// Note: the EmailNotificationTransmitter does not emit Exceptions caught by the JobExecutionException. | ||
// As a result, email notifications are not influencing the job success/failure status. | ||
log.error("Could not transmit a notification via email", e); | ||
} | ||
} else { | ||
log.debug("Email notification is not enabled for: {}", notification.toString()); | ||
try { | ||
emailSender.send(createEmailFromNotification(notification)); | ||
} catch (Exception e) { | ||
// Note: the EmailNotificationTransmitter does not emit Exceptions caught by the JobExecutionException. | ||
// As a result, email notifications are not influencing the job success/failure status. | ||
log.error("Could not transmit a notification via email", e); | ||
} | ||
} | ||
|
||
|
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 don't think this should be a requirement for adding a user, as this can be added later using the update endpoint. Moreover, I am adding the ability to customise email sending per assessment block in the protocol as I don't like enabling this for the whole deployment, so this can be disabled for some tasks/projects even when the environment property is enabled.
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.
Perhaps a warn log should be enough
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, good point. I did not know about the update endpoint. I will log a warning instead.