handle custom cws when a filter has the `entire thread` option set
parent
14cf223041
commit
f40c6dbc93
|
@ -3,7 +3,7 @@ module FilterHelper
|
||||||
|
|
||||||
def phrase_filtered?(status, receiver_id, context)
|
def phrase_filtered?(status, receiver_id, context)
|
||||||
if redis.sismember("filtered_statuses:#{receiver_id}", status.id)
|
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
|
end
|
||||||
|
|
||||||
filters = cached_filters(receiver_id)
|
filters = cached_filters(receiver_id)
|
||||||
|
@ -38,7 +38,7 @@ module FilterHelper
|
||||||
matched = true unless tags.empty? || regex.match(tags).nil?
|
matched = true unless tags.empty? || regex.match(tags).nil?
|
||||||
|
|
||||||
if matched
|
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?
|
unless filter.custom_cw.blank?
|
||||||
cw = if filter.override_cw || status.spoiler_text.blank?
|
cw = if filter.override_cw || status.spoiler_text.blank?
|
||||||
|
@ -46,7 +46,12 @@ module FilterHelper
|
||||||
else
|
else
|
||||||
"[#{filter.custom_cw}] #{status.spoiler_text}".rstrip
|
"[#{filter.custom_cw}] #{status.spoiler_text}".rstrip
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
redis.sadd("filtered_statuses:#{receiver_id}", status.id)
|
redis.sadd("filtered_statuses:#{receiver_id}", status.id)
|
||||||
|
|
|
@ -58,7 +58,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def spoiler_text
|
def spoiler_text
|
||||||
redis.hget("custom_cw:#{current_user&.account_id}", object.id) || object.spoiler_text
|
redis.hget("custom_cw:#{current_user&.account_id}", object.id) || redis.hget("custom_cw:#{current_user&.account_id}", "c#{object.conversation_id}") || object.spoiler_text
|
||||||
end
|
end
|
||||||
|
|
||||||
def visibility
|
def visibility
|
||||||
|
|
Loading…
Reference in New Issue