about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-15 23:22:43 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-15 23:22:43 -0500
commitf40c6dbc9325eac1d75959b4b78666efdb82a735 (patch)
treea1aa50696900206cac1e5e1e76a75a563c398c59 /app/helpers
parent14cf223041031731d8ee48ec0e5bef5f26868bd2 (diff)
handle custom cws when a filter has the `entire thread` option set
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/filter_helper.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/helpers/filter_helper.rb b/app/helpers/filter_helper.rb
index 66ac5014d..b2b78bc44 100644
--- a/app/helpers/filter_helper.rb
+++ b/app/helpers/filter_helper.rb
@@ -3,7 +3,7 @@ module FilterHelper
 
 	def phrase_filtered?(status, receiver_id, context)
     if redis.sismember("filtered_statuses:#{receiver_id}", status.id)
-      return redis.hexists("custom_cw:#{receiver_id}", status.id)
+      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)
@@ -38,7 +38,7 @@ module FilterHelper
       matched = true unless tags.empty? || regex.match(tags).nil?
 
       if matched
-        filter_thread(receiver_id, status.conversation_id) if filter.thread
+        filter_thread(receiver_id, status.conversation_id) if filter.thread && filter.custom_cw.blank?
 
         unless filter.custom_cw.blank?
           cw = if filter.override_cw || status.spoiler_text.blank?
@@ -46,7 +46,12 @@ module FilterHelper
                else
                  "[#{filter.custom_cw}] #{status.spoiler_text}".rstrip
                end
-          redis.hset("custom_cw:#{receiver_id}", status.id, cw)
+
+          if filter.thread
+            redis.hset("custom_cw:#{receiver_id}", "c#{status.conversation_id}", cw)
+          else
+            redis.hset("custom_cw:#{receiver_id}", status.id, cw)
+          end
         end
 
         redis.sadd("filtered_statuses:#{receiver_id}", status.id)