diff options
Diffstat (limited to 'app/models/namespace_setting.rb')
-rw-r--r-- | app/models/namespace_setting.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/namespace_setting.rb b/app/models/namespace_setting.rb index 3befcdeaec5..13d2c5a62e2 100644 --- a/app/models/namespace_setting.rb +++ b/app/models/namespace_setting.rb @@ -63,6 +63,12 @@ class NamespaceSetting < ApplicationRecord namespace.root_ancestor.prevent_sharing_groups_outside_hierarchy end + def emails_enabled? + return emails_enabled unless namespace.has_parent? + + all_ancestors_have_emails_enabled? + end + def show_diff_preview_in_email? return show_diff_preview_in_email unless namespace.has_parent? @@ -89,6 +95,10 @@ class NamespaceSetting < ApplicationRecord private + def all_ancestors_have_emails_enabled? + self.class.where(namespace_id: namespace.self_and_ancestors, emails_enabled: false).none? + end + def all_ancestors_allow_diff_preview_in_email? !self.class.where(namespace_id: namespace.self_and_ancestors, show_diff_preview_in_email: false).exists? end |