]> cat aescling's git repositories - mastodon.git/commitdiff
Disable notifications for trending links and trending statuses by default
authorClaire <claire.github-309c@sitedethib.com>
Sat, 26 Feb 2022 09:30:45 +0000 (10:30 +0100)
committerClaire <claire.github-309c@sitedethib.com>
Sat, 26 Feb 2022 09:46:26 +0000 (10:46 +0100)
app/controllers/settings/preferences_controller.rb
app/models/trends.rb
app/models/user.rb
app/views/settings/preferences/notifications/show.html.haml
config/locales-glitch/simple_form.en.yml
config/settings.yml

index d05ceb53f63277217202b298db5f874bdb6f3784..dfe2ae2e501129bd5edaf9b450c2b29b79dc8288 100644 (file)
@@ -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
index f8864e55f55623e9e5ef476350e47b2769a1cf14..0be900b048b4761773a4b03a302c028a7b55425a 100644 (file)
@@ -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
 
index cb03e99a0063a9e0b4031c05d6004db2a9f9bed8..77685ad027bfdebba9a49c6c23d49a23142e0b75 100644 (file)
@@ -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
index 223e5d7407a5b21cc6cd91f031167f60e48a84bb..e01cd077ff1fc1f2a495d2bd4e0e762ed551bb5c 100644 (file)
@@ -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|
index 612943571924ed436c12e87a192a8faaff4c3977..c9ef409962af6c1f180939d7f523edc735f58958 100644 (file)
@@ -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
index d0946a668e45fd42ff893be9eca760ade50aebe6..11709cee4b6421f6c3d5239d15af211de3c2c8e6 100644 (file)
@@ -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