FEATURE: Remove ignore feature SiteSetting and enable ignore by default (#7349)

FEATURE: Remove ignore feature SiteSetting and enable ignore by default (#7349)

diff --git a/app/assets/javascripts/discourse/templates/preferences/users.hbs b/app/assets/javascripts/discourse/templates/preferences/users.hbs
index 9899be2..7a89a35 100644
--- a/app/assets/javascripts/discourse/templates/preferences/users.hbs
+++ b/app/assets/javascripts/discourse/templates/preferences/users.hbs
@@ -6,16 +6,14 @@
   </div>
   <div class="instructions">{{i18n 'user.muted_users_instructions'}}</div>
 
-  {{#if siteSettings.ignore_user_enabled}}
-    <div class="controls tracking-controls">
-      <label>{{d-icon "eye-slash" class="icon"}} {{i18n 'user.ignored_users'}}</label>
-      {{user-selector excludeCurrentUser=true
-                      usernames=model.ignored_usernames
-                      onChangeCallback=(action "ignoredUsernamesChanged")
-                      class="user-selector"}}
-    </div>
-    <div class="instructions">{{i18n 'user.ignored_users_instructions'}}</div>
-  {{/if}}
+  <div class="controls tracking-controls">
+    <label>{{d-icon "eye-slash" class="icon"}} {{i18n 'user.ignored_users'}}</label>
+    {{user-selector excludeCurrentUser=true
+                    usernames=model.ignored_usernames
+                    onChangeCallback=(action "ignoredUsernamesChanged")
+                    class="user-selector"}}
+  </div>
+  <div class="instructions">{{i18n 'user.ignored_users_instructions'}}</div>
 </div>
 
 {{plugin-outlet name="user-preferences-notifications" args=(hash model=model save=(action "save"))}}
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9dbf412..482814f 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -993,7 +993,6 @@ class UsersController < ApplicationController
   end
 
   def notification_level
-    raise Discourse::NotFound unless SiteSetting.ignore_user_enabled
     user = fetch_user_from_params
 
     if params[:notification_level] == "ignore"
diff --git a/app/jobs/scheduled/ignored_users_summary.rb b/app/jobs/scheduled/ignored_users_summary.rb
index 1371091..b050d9b 100644
--- a/app/jobs/scheduled/ignored_users_summary.rb
+++ b/app/jobs/scheduled/ignored_users_summary.rb
@@ -3,8 +3,6 @@ module Jobs
     every 1.day
 
     def execute(args)
-      return unless SiteSetting.ignore_user_enabled
-
       params = {
         threshold: SiteSetting.ignored_users_count_message_threshold,
         gap_days: SiteSetting.ignored_users_message_gap_days,
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 585cc6f..0fcf19e 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1837,8 +1837,6 @@ en:
 
     log_personal_messages_views: "Log personal message views by Admin for other users/groups."
 
-    ignore_user_enabled: "[Beta] Allow ignoring users."
-
     ignored_users_count_message_threshold: "Notify moderators if a particular user is ignored by this many other users."
 
     ignored_users_message_gap_days: "How long to wait before notifying moderators again about a user who has been ignored by many others."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 6b9a16c..73ccd66 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -529,9 +529,6 @@ users:
     default: false
     client: true
   log_personal_messages_views: false
-  ignore_user_enabled:
-    default: false
-    client: true
   ignored_users_count_message_threshold:
     default: 5
     client: true
diff --git a/db/migrate/20190410102915_remove_ignore_user_enabled_site_setting.rb b/db/migrate/20190410102915_remove_ignore_user_enabled_site_setting.rb
new file mode 100644
index 0000000..126a7d1
--- /dev/null
+++ b/db/migrate/20190410102915_remove_ignore_user_enabled_site_setting.rb
@@ -0,0 +1,8 @@
+class RemoveIgnoreUserEnabledSiteSetting < ActiveRecord::Migration[5.2]
+  def up
+    execute "DELETE FROM site_settings WHERE name = 'ignore_user_enabled'"
+  end
+
+  def down
+  end
+end
diff --git a/lib/guardian.rb b/lib/guardian.rb
index c5fe976..5207989 100644
--- a/lib/guardian.rb
+++ b/lib/guardian.rb
@@ -407,7 +407,7 @@ class Guardian
 
   def can_ignore_users?
     return false if anonymous?
-    SiteSetting.ignore_user_enabled? && (@user.staff? || @user.trust_level >= TrustLevel.levels[:member])
+    @user.staff? || @user.trust_level >= TrustLevel.levels[:member]
   end
 
   def allow_themes?(theme_ids, include_preview: false)
diff --git a/lib/topic_view.rb b/lib/topic_view.rb
index 5705ab3..66da453 100644
--- a/lib/topic_view.rb
+++ b/lib/topic_view.rb
@@ -602,24 +602,21 @@ class TopicView
     @contains_gaps = false
     @filtered_posts = unfiltered_posts
 
-    if SiteSetting.ignore_user_enabled
-
-      sql = <<~SQL
-          SELECT ignored_user_id
-          FROM ignored_users as ig
-          JOIN users as u ON u.id = ig.ignored_user_id
-          WHERE ig.user_id = :current_user_id
-            AND ig.ignored_user_id <> :current_user_id
-            AND NOT u.admin
-            AND NOT u.moderator
-      SQL
+    sql = <<~SQL
+        SELECT ignored_user_id
+        FROM ignored_users as ig
+        JOIN users as u ON u.id = ig.ignored_user_id
+        WHERE ig.user_id = :current_user_id
+          AND ig.ignored_user_id <> :current_user_id
+          AND NOT u.admin
+          AND NOT u.moderator
+    SQL
 
-      ignored_user_ids = DB.query_single(sql, current_user_id: @user&.id)
+    ignored_user_ids = DB.query_single(sql, current_user_id: @user&.id)
 
-      if ignored_user_ids.present?
-        @filtered_posts = @filtered_posts.where.not("user_id IN (?) AND id <> ?", ignored_user_ids, first_post_id)
-        @contains_gaps = true
-      end
+    if ignored_user_ids.present?
+      @filtered_posts = @filtered_posts.where.not("user_id IN (?) AND id <> ?", ignored_user_ids, first_post_id)
+      @contains_gaps = true
     end
 
     # Filters
diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb
index 9fa878d..1fff913 100644
--- a/spec/components/guardian_spec.rb
+++ b/spec/components/guardian_spec.rb
@@ -2676,9 +2676,6 @@ describe Guardian do
   end
 
   describe '#can_ignore_user?' do
-    before do
-      SiteSetting.ignore_user_enabled = true
-    end
 
     let(:guardian) { Guardian.new(trust_level_2) }
 
diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb
index 8999f63..11e1c2d 100644
--- a/spec/components/topic_view_spec.rb
+++ b/spec/components/topic_view_spec.rb
@@ -39,64 +39,48 @@ describe TopicView do
       let!(:post2) { Fabricate(:post, topic: topic, user: evil_trout) }
       let!(:post3) { Fabricate(:post, topic: topic, user: user) }
 
-      describe "when SiteSetting.ignore_user_enabled is false" do
-        it "does not filter out ignored user posts" do
-          SiteSetting.ignore_user_enabled = false
-
-          tv = TopicView.new(topic.id, evil_trout)
-          expect(tv.filtered_post_ids).to eq([post.id, post2.id, post3.id])
-        end
+      it "filters out ignored user posts" do
+        tv = TopicView.new(topic.id, evil_trout)
+        expect(tv.filtered_post_ids).to eq([post.id, post2.id])
       end
 
-      describe "when SiteSetting.ignore_user_enabled is true" do
-
-        before do
-          SiteSetting.ignore_user_enabled = true
-        end
+      describe "when an ignored user made the original post" do
+        let!(:post) { Fabricate(:post, topic: topic, user: user) }
 
-        it "filters out ignored user posts" do
+        it "filters out ignored user posts only" do
           tv = TopicView.new(topic.id, evil_trout)
           expect(tv.filtered_post_ids).to eq([post.id, post2.id])
         end
+      end
 
-        describe "when an ignored user made the original post" do
-          let!(:post) { Fabricate(:post, topic: topic, user: user) }
-
-          it "filters out ignored user posts only" do
-            tv = TopicView.new(topic.id, evil_trout)
-            expect(tv.filtered_post_ids).to eq([post.id, post2.id])
-          end
-        end
-

[... diff too long, it was truncated ...]

GitHub sha: 442fb2fa