-
Notifications
You must be signed in to change notification settings - Fork 39
OTS Extension for Wagtail configuration of messages #4150
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
This creates a place to put extensions django applications so that base.py doesn't run into extra changes for people who want extensions. Extension based configuration will also go here.
This is a django signal that can override various parts of the messaging infrastructure (email, slack, etc). See updated documentation for information about the signal, and what it expects/provides.
This sets up the rest of changes coming and needed. Issue ots/clients/ardc/hypha-tracker#218: Permit outgoing messages/notifications to be configured in Wagtail
This doesn't build out any of the default messages (that comes later), but sets the stage for it. Issue ots/clients/ardc/hypha-tracker#218: Permit outgoing messages/notifications to be configured in Wagtail
Issue ots/clients/ardc/hypha-tracker#218: Permit outgoing messages/notifications to be configured in Wagtail
Issue ots/clients/ardc/hypha-tracker#218: Permit outgoing messages/notifications to be configured in Wagtail
Issue ots/clients/ardc/hypha-tracker#218: Permit outgoing messages/notifications to be configured in Wagtail
This is not all of them, but a good representation for how to use the variables. We may want to build more out if the extension gets used more. For a large number of the messages, there's non trivial business logic in either the original messages or the generation of them that needs to be moved out or handled in another way. Issue ots/clients/ardc/hypha-tracker#218: Permit outgoing messages/notifications to be configured in Wagtail
|
We will take a look at this implementation. Where mush like the idea of allowing easy customisation of messages. We definitely want to make e-mail the default notification method for all users. The current Slack notifications for staff will remain as an option. |
|
I think you may be confused by the terminology. "Default" in this extension dictates whether the notifications get sent by default. The idea is letting the administrator decide whether they want emails to be off unless otherwise specified, and whether they want slack messages to be off unless otherwise specified. We ran into this because the client wanted us to have an allow list of what slack messages, and emails, to send. Rather than just blocking ones the don't. So the use case is if someone wants to only send an email message for determination, and only send a slack message for submission creation, they say "default off" for both slack and email messages, but then add an overriding "turn on for this message only" to both. This prevents messages going out in the case of an upgrade in hypha adding new ones. |
|
I was unclear, the default e-mail part refers to the work we plan to do, hopefully later this year, to have all staff notifications go via e-mail by default. |
|
Ahh! After this PR gets reviewed/accepted, there will be another which connects to Zulip (dependent on this one), which uses the hypha slack infrastructure. I expect this extension well be helpful to keep that enabled after your changes! |
frjo
left a 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.
Making messages configurable will be an excellent improvement of Hypha. This implementation however feels "plastered on".
If we in the future want to change messages we will need to update in several places from what I can see.
Can we not build this in to the activities app directly. Making this the way to handle e-mail notifications?
Are any of your clients using Slack? My guess is that only OTF uses it so we can skip Slack notifications for now.
|
|
||
|
|
||
| @register_setting | ||
| class MessagingSetting(BaseSiteSetting, ClusterableModel): |
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.
We are moving away from Wagtail sites so BaseGenericSetting is better to use.
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.
Cool! I'll tackle this depending on how the overall PR discussion goes :)
| }); | ||
| add_update_events(); | ||
| }); | ||
| })(jQuery); |
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.
VanillaJS or AlpineJS, we are retiring jQuery.
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 as familiar with those, so probably won't have a chance to do that.
|
|
||
| <p>{% trans "When the submission is available, the following are available:" %}</p> | ||
|
|
||
| <ul> |
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.
Add class w-mb-4 to add some margins to the lists.
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 call! I'll make the change depending on how the overarching PR discussion goes :)
| {% trans "Variables that will get replaced follow. Use the uppercase name (before the colon) in any subject, email message, or slack message." %} | ||
| </p> | ||
|
|
||
| <p>{% trans "When the submission is available, the following are available:" %}</p> |
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.
Maybe wrap these in <strong>? Makes it easer to see the sections of the text.
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 we have a lot of opinions on the styling of the help text, so whatever you guys think looks good.
| </ul> | ||
|
|
||
| {% for id, default in self.email_messages.items %} | ||
| <div class="is-hidden" attr-email-id="{{ id }}"> |
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.
Can we just use "hidden" attribute instead of adding a class and a custom css file?
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.
Sure!
| ) | ||
| email_subject = models.TextField(null=True, blank=True) | ||
| email_message = models.TextField(null=True, blank=True) | ||
| slack_message = models.TextField(null=True, blank=True) |
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 two messages fields should be textareas I believe.
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 can see that!
Yes! The architecture of the messaging was a bit hard to puncture. Our first attempt was to add it directly into the activities app. However, there was a lot of business logic, both in the templates themselves, as well as in the actual calls (for instance, https://github.com/HyphaApp/hypha/blob/main/hypha/apply/activity/adapters/base.py#L56-L63 adds a lot of complexity) We were able to get as far as our client needed with the first pass of configuration in the activities app, as a lot of the logic in the base hypha activities app was able to be bypassed (they really just wanted far more simplistic messaging around a small subset of messages). However, building out something that could reasonably reproduce what hypha is currently doing with configuration, turned out to be a much bigger project than we had budget for. If you guys can do that, that would be awesome! In the meantime, we settled for saying "hey, add a hook into the base messaging app, and let us do a reasonable job of using that hook for our clients"
Yes and no. As long as you make the base tests pass from the activities app, then you can safely ignore the extension. We just need the contract maintained of turning email on and off in the default case, as well as being able to replace the message generated by the activities app with one of our own.
See above! It looked like a pretty massive project to take what's currently in hypha to that method. If you guys can come up with a good way, that would be even better than our extension. One thing we did decide we needed for our client was no logic in the configuration. Simple string replacement only.
Yes! We actually subclassed the slack adapter to add zulip (coming to the hypha codebase after we work through this PR). They use it for general channel things (not targeted messages) for general events, like a submission happening. This lets people in their organization stay aware of general stuff in hypha without having to subscribe to events, or even have accounts on the hypha instance. |
|
Overall, a potential successful merge here is to say "we don't want the extension, but we will accept the changes to the base hypha app that enable your extension." That way, we can move forward on our end and let you guys put together a project that is more in line with how you'd want this feature to work in mainline hypha. If that's what you end up doing, we can create another PR with just the changes we need to enable our extension to work in isolation :) |
Like #4149 , this adds an extension to hypha. There's some overlap between the two PRs (some of the base setup). This one differs in that it uses django signals to facilitate communication with an extension.
This extension adds a wagtail configuration for email/slack messaging, overriding the developer required code. It includes simplistic find/replace for various variables depending on the object leading to the message.
Like the #4149, it includes tests and migrations that live apart from the codebase, and therefore should not cause migration conflicts. Also, it includes a number of commits that we need to be included (and tests for them) to declare the signal, even if the meat of the extension is not something you're looking for.
Those are: 9b5012d, c9fcaed