about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-05-20 11:32:44 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-20 17:32:44 +0200
commit8f4b7c1820b046c8df10e043a0bc605f3007eee7 (patch)
treecd8703410d9c374f89e4845600aad931f04bd6a9 /app
parent2e112e240666b62b8c3d4fa201fb24b841f6c92b (diff)
Filter languages with opt out (#3175)
* Remove allowed_languages and add filtered_languages

* Use filtered_languages instead of allowed_languages
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/preferences_controller.rb2
-rw-r--r--app/javascript/styles/forms.scss2
-rw-r--r--app/models/account.rb2
-rw-r--r--app/models/status.rb6
-rw-r--r--app/models/user.rb4
-rw-r--r--app/views/settings/preferences/show.html.haml2
6 files changed, 9 insertions, 9 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 04a85849d..28757d1bc 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -26,7 +26,7 @@ class Settings::PreferencesController < ApplicationController
   def user_params
     params.require(:user).permit(
       :locale,
-      allowed_languages: []
+      filtered_languages: []
     )
   end
 
diff --git a/app/javascript/styles/forms.scss b/app/javascript/styles/forms.scss
index ce31f01af..db60e1e10 100644
--- a/app/javascript/styles/forms.scss
+++ b/app/javascript/styles/forms.scss
@@ -352,7 +352,7 @@ code {
   }
 }
 
-.user_allowed_languages {
+.user_filtered_languages {
   li {
     float: left;
     width: 50%;
diff --git a/app/models/account.rb b/app/models/account.rb
index 726e6c127..7e4291d55 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -99,7 +99,7 @@ class Account < ApplicationRecord
            prefix: true,
            allow_nil: true
 
-  delegate :allowed_languages, to: :user, prefix: false, allow_nil: true
+  delegate :filtered_languages, to: :user, prefix: false, allow_nil: true
 
   def local?
     domain.nil?
diff --git a/app/models/status.rb b/app/models/status.rb
index a4e581a06..d7304152f 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -142,8 +142,8 @@ class Status < ApplicationRecord
   before_validation :set_conversation
 
   class << self
-    def in_allowed_languages(account)
-      where(language: account.allowed_languages)
+    def not_in_filtered_languages(account)
+      where.not(language: account.filtered_languages)
     end
 
     def as_home_timeline(account)
@@ -234,7 +234,7 @@ class Status < ApplicationRecord
     def filter_timeline_for_account(query, account, local_only)
       query = query.not_excluded_by_account(account)
       query = query.not_domain_blocked_by_account(account) unless local_only
-      query = query.in_allowed_languages(account) if account.allowed_languages.present?
+      query = query.not_in_filtered_languages(account) if account.filtered_languages.present?
       query.merge(account_silencing_filter(account))
     end
 
diff --git a/app/models/user.rb b/app/models/user.rb
index 7cf3a1290..2ad68f9ae 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -30,7 +30,7 @@
 #  otp_required_for_login    :boolean
 #  last_emailed_at           :datetime
 #  otp_backup_codes          :string           is an Array
-#  allowed_languages         :string           default([]), not null, is an Array
+#  filtered_languages        :string           default([]), not null, is an Array
 #
 
 class User < ApplicationRecord
@@ -83,6 +83,6 @@ class User < ApplicationRecord
   private
 
   def sanitize_languages
-    allowed_languages.reject!(&:blank?)
+    filtered_languages.reject!(&:blank?)
   end
 end
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index b64fd7c96..0532d1dc8 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -12,7 +12,7 @@
       label_method: lambda { |locale| human_locale(locale) },
       selected: I18n.locale
 
-    = f.input :allowed_languages,
+    = f.input :filtered_languages,
       collection: I18n.available_locales,
       wrapper: :with_label,
       include_blank: false,