blob: 28d413d9bc4cd6266fdddee47ccc75e50f4de546 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filters
#
# id :bigint(8) not null, primary key
# account_id :bigint(8)
# expires_at :datetime
# phrase :text default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
class CustomFilter < ApplicationRecord
include Expireable
include Redisable
belongs_to :account
validates :phrase, presence: true
after_commit :remove_cache
private
def remove_cache
Rails.cache.delete("filters:#{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
end
|