From: Eugen Rochko Date: Mon, 17 Apr 2017 23:09:57 +0000 (+0200) Subject: Merge branch 'fix/cache_blocking' of git://github.com/pixiv/mastodon into pixiv-fix... X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=2fd0473aa16603ca85e9e71dfbf4f32420f68327;p=mastodon.git Merge branch 'fix/cache_blocking' of git://github.com/pixiv/mastodon into pixiv-fix/cache_blocking --- 2fd0473aa16603ca85e9e71dfbf4f32420f68327 diff --cc app/models/mute.rb index 7987ed007,875d030e9..0cf17be4f --- a/app/models/mute.rb +++ b/app/models/mute.rb @@@ -3,8 -3,16 +3,15 @@@ class Mute < ApplicationRecord include Paginable - belongs_to :account - belongs_to :target_account, class_name: 'Account' + belongs_to :account, required: true + belongs_to :target_account, class_name: 'Account', required: true - validates :account, :target_account, presence: true validates :account_id, uniqueness: { scope: :target_account_id } + + after_create :remove_blocking_cache + after_destroy :remove_blocking_cache + + def remove_blocking_cache + Rails.cache.delete("blocked_account_ids:#{account_id}") + end end