-
-
Notifications
You must be signed in to change notification settings - Fork 702
Add support for scheduled summary notifications #4783
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
Conversation
4af866e to
9891a28
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
db5b388 to
8adfdb9
Compare
|
@nscuro Thank you very much, we will check this asap.
|
7468f09 to
aaa9826
Compare
Yes, see here: DependencyTrack/frontend#1210
Basically, the default email publisher uses the MIME type In order to change the MIME type, you need a new publisher. This is what your original PR did. The downside is that that publisher and its associated template only catered to the new scheduled notification, but not any other notification type. In your PR, you worked around this by differentiating between publishers for scheduled, and those for "normal" notifications. But this was really just a workaround, and it was really only necessary for email due to the MIME type conflict. On a technical level there is nothing that would prevent a normal publisher to be used for scheduled notifications, other than that its template would need updating. So I had two options at this point:
For time reasons, I went with (2). Reasoning being that at least the core functionality would be out sooner, and those wishing to use HTML could simply provide a custom template (see below). We can of course still include the partial HTML email template per default, but my fear is that it'd be too confusing if it only supports a very small subset of notifications. If you can think of other options I'm open to that of course.
You can just clone the default email publisher via the UI, and provide a custom template: https://docs.dependencytrack.org/integrations/notifications/#creation-of-publisher |
079c54c to
c9e952b
Compare
Why not just change the mime type of the existing publisher? Shouldn't matter if you send HTML or non-html via HTML mime type. Would also open the existing templates up for using html if someone wants to |
Mostly because I am unsure about the consequences, tbh. It's really hard to tell if this switch could break things for people who may currently rely on it being plain text. You likely have more experience than me when it comes to mail clients. Possible I am overthinking this. If you think it's a safe thing to do, we can simply add your original HTML template code to the |
|
@nscuro Thank you very much for helping us to implement this feature. From a first look, everything looks good and fulfills the needs which we had when creating the original PR. The only issue which I am currently experiencing, is that scheduled mail notifications only seem to work via the Everytime the scheduled email should be dispatched, the following two exceptions occur and no mail is sent: ExceptionsThose exception always occur, regardless whether using the original Email template or the newly created HTML template. Maybe you've got any idea why this could be happening? |
Yep, good catch. Here I am adding to a list while iterating over it:
|
|
@rbt-mm Should be fixed now, please have another go when you find the time.
On that topic. what are your thoughts on my previous question:
I def. see the value in having summaries such as these in HTML format, I'm just not too fond of shipping partial templates. So wondering how to best progress on this. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Thanks for the quick fix, the mails are now correctly dispatched! Stuff like limiting to projects/teams and not publishing mails when there is no new information also seems to work fine. So the changes look good to me 👍
I also think its better to have such summaries in an easy to digest format like HTML, but I wouldn't add it to the current Maybe providing this HTML summary template (and potentially other useful templates from the community which might be contributed in the future?) in a designated documentation/wiki page could be a solution for this? |
Like the idea. We could introduce a Can I ask one last favour? What are your thoughts on the text-based templates in this PR? Any more info you'd like to see there? |
|
I think the text-based templates look good and contain all the necessary information 👍
|
Great feedback, thanks. Will add this.
Unfortunately it's not, currently. Email is kind of unique in that the title of the message is specified separate from the main body. We'd need separate templating to enable this. But agree on that it'd be good to have. |
Co-authored-by: Max Schiller <msr@mm-software.com> Co-authored-by: Marlon Gäthje <mge@mm-software.com> Co-authored-by: Richard Bickert <rbt@mm-software.com> Signed-off-by: nscuro <nscuro@protonmail.com>
60251e3 to
eabd376
Compare
Description
Builds upon @MM-msr's PR #3925 in the following ways:
ScheduledNotificationRulemodel, associated persistence methods, and REST endpoints. Add the fields and capabilities required to support scheduled notifications to the existingNotificationRulemodel instead. This avoids a ton of redundant code.ScheduledNotificationTaskManagerin favour of the existing eventing system. An event is emitted every minute to check for due scheduled notifications. To keep track of when a notification was last sent, and when it's next due, we simply use dedicated fields in theNotificationRulemodel.SendScheduledNotificationTaskand leverages the existingNotificationRouterinstead. Again avoiding a lot of redundant code.NotificationGroups for scheduled notifications, and integrate them into existing templates. There are no longer separateNotificationPublishers for scheduled notifications. Instead, templates may be updated to support them.Addressed Issue
Supersedes #3925
Closes #322
Additional Details
Frontend PR: DependencyTrack/frontend#1210
Checklist
This PR fixes a defect, and I have provided tests to verify that the fix is effectiveThis PR introduces changes to the database model, and I have added corresponding update logic