Commit ddd6f804 authored by Wei-Meng Lee's avatar Wei-Meng Lee

Move method into group

parent f7238306
...@@ -82,7 +82,7 @@ class Notify < BaseMailer ...@@ -82,7 +82,7 @@ class Notify < BaseMailer
group_notification_email = nil group_notification_email = nil
if notification_group if notification_group
notification_settings = notification_group.notification_settings(hierarchy_order: :asc).where(user: @current_user) # rubocop: disable CodeReuse/ActiveRecord notification_settings = notification_group.notification_settings_for(@current_user, hierarchy_order: :asc)
group_notification_email = notification_settings.find { |n| n.notification_email.present? }&.notification_email group_notification_email = notification_settings.find { |n| n.notification_email.present? }&.notification_email
end end
......
...@@ -138,6 +138,10 @@ class Group < Namespace ...@@ -138,6 +138,10 @@ class Group < Namespace
.order("ordered_groups.depth #{hierarchy_order}") .order("ordered_groups.depth #{hierarchy_order}")
end end
def notification_settings_for(user, hierarchy_order: nil)
notification_settings(hierarchy_order: hierarchy_order).where(user: user)
end
def to_reference(_from = nil, full: nil) def to_reference(_from = nil, full: nil)
"#{self.class.reference_prefix}#{full_path}" "#{self.class.reference_prefix}#{full_path}"
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment