From ce732d22521440a010390ab4f6785c1ed048fbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 11 Jun 2014 17:14:00 +0200 Subject: [PATCH] FEATURE: new "disable_edit_notifications" site setting Should be used whenever you activate the "download_remote_images_to_local" site setting to prevent users from receiving a lot of edit notifications from the system user. --- app/models/post_alert_observer.rb | 1 + config/locales/server.en.yml | 2 ++ config/site_settings.yml | 2 ++ spec/models/post_alert_observer_spec.rb | 8 ++++++++ 4 files changed, 13 insertions(+) diff --git a/app/models/post_alert_observer.rb b/app/models/post_alert_observer.rb index fcefb7021cf..61bf57e6df5 100644 --- a/app/models/post_alert_observer.rb +++ b/app/models/post_alert_observer.rb @@ -41,6 +41,7 @@ class PostAlertObserver < ActiveRecord::Observer post = post_revision.post return unless post + return if SiteSetting.disable_edit_notifications return if post_revision.user.blank? return if post_revision.user_id == post.user_id return if post.topic.private_message? diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 94f6250865f..faa880d169f 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -889,6 +889,8 @@ en: global_notice: "Display an URGENT, EMERGENCY global banner notice to all visitors, change to blank to hide it (HTML allowed)." + disable_edit_notifications: "Used to disable edit notifications when you activate the 'download_remote_images_to_local' site setting." + enable_names: "Allow users to show their full names" display_name_on_posts: "Also show a user's full name on their posts" invites_shown: "Maximum invites shown on a user page" diff --git a/config/site_settings.yml b/config/site_settings.yml index c96b3b0933d..84145cfe51d 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -598,3 +598,5 @@ uncategorized: enable_system_avatars: hidden: true default: true + + disable_edit_notifications: false diff --git a/spec/models/post_alert_observer_spec.rb b/spec/models/post_alert_observer_spec.rb index c243f2cb13b..8e16f6cbe92 100644 --- a/spec/models/post_alert_observer_spec.rb +++ b/spec/models/post_alert_observer_spec.rb @@ -38,6 +38,14 @@ describe PostAlertObserver do post.revise(evil_trout, "world is the new body of the message") }.should change(post.user.notifications, :count).by(1) end + + it 'does not notifiy a user of the revision when edit notifications are disabled' do + SiteSetting.stubs(:disable_edit_notifications).returns(true) + lambda { + post.revise(evil_trout, "world is the new body of the message") + }.should_not change(post.user.notifications, :count).by(1) + end + end context 'private message' do