about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-02-26 10:30:45 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-02-26 10:46:26 +0100
commitc6df6686af01e774b2b4618e96194bf80db6ecf2 (patch)
treed05719cda14674586cf82190d8bc0e0c59cff647
parent4eed5019a23084816931cf9a0f426003aa160256 (diff)
Disable notifications for trending links and trending statuses by default
-rw-r--r--app/controllers/settings/preferences_controller.rb2
-rw-r--r--app/models/trends.rb9
-rw-r--r--app/models/user.rb10
-rw-r--r--app/views/settings/preferences/notifications/show.html.haml2
-rw-r--r--config/locales-glitch/simple_form.en.yml4
-rw-r--r--config/settings.yml2
6 files changed, 24 insertions, 5 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index d05ceb53f..dfe2ae2e5 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -58,7 +58,7 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_use_pending_items,
       :setting_trends,
       :setting_crop_images,
-      notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account trending_tag),
+      notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account trending_tag trending_link trending_status),
       interactions: %i(must_be_follower must_be_following must_be_following_dm)
     )
   end
diff --git a/app/models/trends.rb b/app/models/trends.rb
index f8864e55f..0be900b04 100644
--- a/app/models/trends.rb
+++ b/app/models/trends.rb
@@ -32,10 +32,13 @@ module Trends
     tags_requiring_review     = tags.request_review
     statuses_requiring_review = statuses.request_review
 
-    return if links_requiring_review.empty? && tags_requiring_review.empty? && statuses_requiring_review.empty?
-
     User.staff.includes(:account).find_each do |user|
-      AdminMailer.new_trends(user.account, links_requiring_review, tags_requiring_review, statuses_requiring_review).deliver_later! if user.allows_trends_review_emails?
+      links    = user.allows_trending_tags_review_emails? ? links_requiring_review : []
+      tags     = user.allows_trending_links_review_emails? ? tags_requiring_review : []
+      statuses = user.allows_trending_statuses_review_emails? ? statuses_requiring_review : []
+      next if links.empty? && tags.empty? && statuses.empty?
+
+      AdminMailer.new_trends(user.account, links, tags, statuses).deliver_later!
     end
   end
 
diff --git a/app/models/user.rb b/app/models/user.rb
index cb03e99a0..77685ad02 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -269,10 +269,18 @@ class User < ApplicationRecord
     settings.notification_emails['appeal']
   end
 
-  def allows_trends_review_emails?
+  def allows_trending_tags_review_emails?
     settings.notification_emails['trending_tag']
   end
 
+  def allows_trending_links_review_emails?
+    settings.notification_emails['trending_link']
+  end
+
+  def allows_trending_statuses_review_emails?
+    settings.notification_emails['trending_status']
+  end
+
   def hides_network?
     @hides_network ||= settings.hide_network
   end
diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml
index 223e5d740..e01cd077f 100644
--- a/app/views/settings/preferences/notifications/show.html.haml
+++ b/app/views/settings/preferences/notifications/show.html.haml
@@ -24,6 +24,8 @@
         = ff.input :appeal, as: :boolean, wrapper: :with_label
         = ff.input :pending_account, as: :boolean, wrapper: :with_label
         = ff.input :trending_tag, as: :boolean, wrapper: :with_label
+        = ff.input :trending_link, as: :boolean, wrapper: :with_label
+        = ff.input :trending_status, as: :boolean, wrapper: :with_label
 
   .fields-group
     = f.simple_fields_for :notification_emails, hash_to_object(current_user.settings.notification_emails) do |ff|
diff --git a/config/locales-glitch/simple_form.en.yml b/config/locales-glitch/simple_form.en.yml
index 612943571..c9ef40996 100644
--- a/config/locales-glitch/simple_form.en.yml
+++ b/config/locales-glitch/simple_form.en.yml
@@ -18,3 +18,7 @@ en:
         setting_hide_followers_count: Hide your followers count
         setting_skin: Skin
         setting_system_emoji_font: Use system's default font for emojis (applies to Glitch flavour only)
+      notification_emails:
+        trending_tag: New trending tag requires review
+        trending_link: New trending link requires review
+        trending_status: New trending post requires review
diff --git a/config/settings.yml b/config/settings.yml
index d0946a668..11709cee4 100644
--- a/config/settings.yml
+++ b/config/settings.yml
@@ -52,6 +52,8 @@ defaults: &defaults
     report: true
     pending_account: true
     trending_tag: true
+    trending_link: false
+    trending_status: false
     appeal: true
   interactions:
     must_be_follower: false