about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/filter_helper.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/helpers/filter_helper.rb b/app/helpers/filter_helper.rb
index b2b78bc44..079075a97 100644
--- a/app/helpers/filter_helper.rb
+++ b/app/helpers/filter_helper.rb
@@ -6,8 +6,11 @@ module FilterHelper
       return !(redis.hexists("custom_cw:#{receiver_id}", status.id) || redis.hexists("custom_cw:#{receiver_id}", "c#{status.conversation_id}"))
     end
 
-    filters = cached_filters(receiver_id)
-    filters.select! { |filter| filter.context.include?(context.to_s) && !filter.expired? }
+    filters = cached_filters(receiver_id).select { |filter| !filter.expired? }
+
+    unless context.nil?
+      filters.select! { |filter| filter.context.include?(context.to_s) && !filter.expired? }
+    end
 
     if status.media_attachments.any?
       filters.delete_if { |filter| filter.exclude_media }
@@ -33,9 +36,9 @@ module FilterHelper
       end
 
       matched = false
-      matched = true unless regex.match(status_text).nil?
-      matched = true unless spoiler_text.blank? || regex.match(spoiler_text).nil?
-      matched = true unless tags.empty? || regex.match(tags).nil?
+      matched ||= regex.match(status_text).present? if filter.status_text
+      matched ||= regex.match(spoiler_text).present? if filter.spoiler && spoiler_text.present?
+      matched ||= regex.match(tags).present? if filter.tags && tags.present?
 
       if matched
         filter_thread(receiver_id, status.conversation_id) if filter.thread && filter.custom_cw.blank?