-
Notifications
You must be signed in to change notification settings - Fork 8
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
refactor notification #184
Conversation
Refactor: notifications
- Rename variables and methods to make a clear distinction between OntoPortal site admins, ontology admins and support. - Add new feature to optionally disable notifications send to OntoPortal admins for each event associated with ontology creation, new user, etc - LinkedData.setting.support_contact_email is a new configuration option for setting end user support contact email. BioPortal requires different emails for contacting BioPortal site admins and end user support In order to clarify the distinction between the OntoPortal site admins and ontology owners/admins the following settings and methods are renamed: LinkedData.setting.admin_emails is renamed to ontoportal_admin_emails LinkedData::Utils::Notifier.admin_mails -> ontology_admin_emails LinkedData::Utils::support_mails -> ontoportal_admin_emails LinkedData::Utils::notify_support_grouped -> notify_ontoportal_admins_grouped
@syphax-bouazzouni please review the follow up changes and let me know if there is anything that should be tweaked in order to fit your code base |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #184 +/- ##
===========================================
- Coverage 80.76% 80.66% -0.10%
===========================================
Files 63 64 +1
Lines 4917 5337 +420
===========================================
+ Hits 3971 4305 +334
- Misses 946 1032 +86
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Hey 👋 , thanks on working on this. Fine by me.
Added some optional minor remarks that you can
puts "Error: 'redis_host' is not a valid conf parameter." | ||
puts ' Redis databases were split into multiple hosts (09/22/13).' | ||
raise Exception, 'redis_host is not a valid conf parameter.' | ||
unless @settings.admin_emails.nil? |
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.
why this part?
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.
admin_emails setting was renamed to ontoportal_admin_emails so thats a way to notify folks who have been relying on that setting to update. I would be more than happy to remove if you think thats an overkill.
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.
Yes, it is overkill, this sort of code, is always the one remaining 10 years after, with no one knowing why they are here and too screed to remove it.
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.
removed in 87afcc4
@@ -69,7 +65,8 @@ def config(&block) | |||
|
|||
# Email settings | |||
@settings.enable_notifications ||= false | |||
@settings.email_sender ||= '[email protected]' # Default sender for emails | |||
# Default sender From email address | |||
@settings.email_sender ||= '[email protected]' | |||
@settings.email_override ||= '[email protected]' # By default, all email gets sent here. Disable with email_override_disable. |
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.
email_override
and email_disable_override
are never really used, in test or development environments config the email_sender
on it self is email_override
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 use email_override in staging environment to troubleshoot send notifications to a dedicated email address used for debugging only. Sending all overwritten/debugging emails to the admin account creates too much noise so having this options works well for us.
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.
yes but I mean in your staging env, you can set admin_email as the one that you override with ? anyways no big deal.
|
||
def self.ontoportal_admin_emails | ||
|
||
if !LinkedData.settings.ontoportal_admin_emails.nil? && |
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 condition can be replaced with only, which handle nil case also
LinkedData.settings.ontoportal_admin_emails.is_a?(Array)
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.
or all the function by Array(LinkedData.settings.ontoportal_admin_emails)
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.
addressed in d0b6ad8
end | ||
recipients | ||
end | ||
|
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.
you can add (and use) the following helper/facets/alias here
def self.support_mail
Array(LinkedData.settings.support_contact_email)
end
def self.notification_enabled?
LinkedData.settings.enable_administrative_notifications
end
this will make it easier to read
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.
thanks for the suggestion
addressed in d0b6ad8
end | ||
|
||
def self.notify_ontoportal_admins(subject, body) | ||
notify_mails_grouped subject, body, ontoportal_admin_emails if LinkedData.settings.enable_administrative_notifications |
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.
no need of the if LinkedData.settings.enable_administrative_notifications
as notify already test that
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.
LinkedData.settings.enable_administrative_notifications
is not the same as LinkedData.settings.enable_notifications
enable_notifications
enables all notifications for all users
enable_administrative_notifications
enables notifications send to the admin team (or support team in your case) for things like new user creation event. BioPortal team doesn't have the need to see those notifications.
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.
Ah ok sorry, miss reading the thing,
Good for me
end | ||
|
||
def self.notify_ontoportal_admins_grouped(subject, body) | ||
notify_mails_grouped subject, body, ontoportal_admin_emails if LinkedData.settings.enable_administrative_notifications |
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.
no need of the if LinkedData.settings.enable_administrative_notifications
as notify already test that
notification refactor follow up to #148
OntoPortal site admins, ontology admins and support.
admins for each event associated with ontology creation, new user, etc
for setting end user support contact email.
BioPortal requires different emails for contacting BioPortal site
admins and end user support
In order to clarify the distinction between the OntoPortal site admins and
ontology owners/admins the following settings and methods are renamed:
LinkedData.setting.admin_emails is renamed to ontoportal_admin_emails
LinkedData::Utils::Notifier.admin_mails -> ontology_admin_emails
LinkedData::Utils::support_mails -> ontoportal_admin_emails
LinkedData::Utils::notify_support_grouped -> notify_ontoportal_admins_grouped