about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/feed_manager.rb28
-rw-r--r--app/lib/formatter.rb6
-rw-r--r--app/lib/tag_manager.rb4
3 files changed, 22 insertions, 16 deletions
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 8cf465da8..b808d7a0f 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'singleton'
 
 class FeedManager
@@ -60,29 +62,29 @@ class FeedManager
   private
 
   def redis
-    $redis
+    Redis.current
   end
 
   def filter_from_home?(status, receiver)
     should_filter = false
 
-    if status.reply? && !status.thread.account.nil?                                     # Filter out if it's a reply
-      should_filter = !receiver.following?(status.thread.account)                       # and I'm not following the person it's a reply to
-      should_filter = should_filter && !(receiver.id == status.thread.account_id)       # and it's not a reply to me
-      should_filter = should_filter && !(status.account_id == status.thread.account_id) # and it's not a self-reply
-    elsif status.reblog?                                                                # Filter out a reblog
-      should_filter = receiver.blocking?(status.reblog.account)                         # if I'm blocking the reblogged person
+    if status.reply? && !status.thread.account.nil?                      # Filter out if it's a reply
+      should_filter   = !receiver.following?(status.thread.account)      # and I'm not following the person it's a reply to
+      should_filter &&= !(receiver.id == status.thread.account_id)       # and it's not a reply to me
+      should_filter &&= !(status.account_id == status.thread.account_id) # and it's not a self-reply
+    elsif status.reblog?                                                 # Filter out a reblog
+      should_filter = receiver.blocking?(status.reblog.account)          # if I'm blocking the reblogged person
     end
 
     should_filter
   end
 
   def filter_from_mentions?(status, receiver)
-    should_filter = receiver.id == status.account_id                             # Filter if I'm mentioning myself
-    should_filter = should_filter || receiver.blocking?(status.account)          # or it's from someone I blocked
+    should_filter   = receiver.id == status.account_id            # Filter if I'm mentioning myself
+    should_filter ||= receiver.blocking?(status.account)          # or it's from someone I blocked
 
-    if status.reply? && !status.thread.account.nil?                              # or it's a reply
-      should_filter = should_filter || receiver.blocking?(status.thread.account) # to a user I blocked
+    if status.reply? && !status.thread.account.nil?               # or it's a reply
+      should_filter ||= receiver.blocking?(status.thread.account) # to a user I blocked
     end
 
     should_filter
@@ -92,9 +94,9 @@ class FeedManager
     should_filter = receiver.blocking?(status.account)
 
     if status.reply? && !status.thread.account.nil?
-      should_filter = should_filter || receiver.blocking?(status.thread.account)
+      should_filter ||= receiver.blocking?(status.thread.account)
     elsif status.reblog?
-      should_filter = should_filter || receiver.blocking?(status.reblog.account)
+      should_filter ||= receiver.blocking?(status.reblog.account)
     end
 
     should_filter
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 3a6ba97c8..5748680af 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'singleton'
 
 class Formatter
@@ -17,7 +19,7 @@ class Formatter
     html = link_mentions(html, status.mentions)
     html = link_hashtags(html)
 
-    html.html_safe
+    html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
   def reformat(html)
@@ -30,7 +32,7 @@ class Formatter
     html = encode(account.note)
     html = link_urls(html)
 
-    html.html_safe
+    html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
   private
diff --git a/app/lib/tag_manager.rb b/app/lib/tag_manager.rb
index d2cf35b49..fcc4b3259 100644
--- a/app/lib/tag_manager.rb
+++ b/app/lib/tag_manager.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'singleton'
 
 class TagManager
@@ -18,7 +20,7 @@ class TagManager
   end
 
   def local_domain?(domain)
-    domain.nil? || domain.gsub(/[\/]/, '').downcase == Rails.configuration.x.local_domain.downcase
+    domain.nil? || domain.gsub(/[\/]/, '').casecmp(Rails.configuration.x.local_domain).zero?
   end
 
   def uri_for(target)