diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-08-15 22:40:20 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-08-15 22:40:20 -0500 |
commit | 7bbcf793bc75b44f2b20de77b7774759af60cd90 (patch) | |
tree | d8d441c2d8cf245b28651efa14f6460841a8e304 /app/models | |
parent | f783ec279d03b7b56c96af5e18e0dd8c7a0710a1 (diff) |
custom filters now have an option to add or override content warnings; filter caching has been fixed
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/custom_filter.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb index a1db3940c..ddf6cc7ab 100644 --- a/app/models/custom_filter.rb +++ b/app/models/custom_filter.rb @@ -18,6 +18,8 @@ # spoiler :boolean default(FALSE), not null # tags :boolean default(FALSE), not null # status_text :boolean default(FALSE), not null +# custom_cw :text +# override_cw :boolean default(FALSE), not null # class CustomFilter < ApplicationRecord @@ -29,6 +31,7 @@ class CustomFilter < ApplicationRecord ).freeze include Expireable + include Redisable belongs_to :account @@ -38,6 +41,7 @@ class CustomFilter < ApplicationRecord scope :active_irreversible, -> { where(irreversible: true).where(Arel.sql('expires_at IS NULL OR expires_at > NOW()')) } + before_validation :prepare_custom_cw before_validation :clean_up_contexts after_commit :remove_cache @@ -47,9 +51,15 @@ class CustomFilter < ApplicationRecord self.context = Array(context).map(&:strip).map(&:presence).compact end + def prepare_custom_cw + custom_cw&.strip! + end + def remove_cache Rails.cache.delete("filters:#{account_id}") - Rails.cache.delete("filtered_threads:#{account_id}") + redis.del("custom_cw:#{account_id}") + redis.del("filtered_threads:#{account_id}") + redis.del("filtered_statuses:#{account_id}") Redis.current.publish("timeline:#{account_id}", Oj.dump(event: :filters_changed)) end |