diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-20 14:42:48 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:44:01 -0500 |
commit | 2c0a92bc3f85f8668fff66fcf942a1878363426d (patch) | |
tree | 9c0e24f5f954c12f2ee04c29090f30d7739e8d97 /app/lib | |
parent | 3366a957219b15f5ab6f6eabbf5466e1e12082de (diff) |
[Bug] Purge cached status when processing command tags and edits
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/command_tag/processor.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/lib/command_tag/processor.rb b/app/lib/command_tag/processor.rb index b122b9e8d..74dcb047d 100644 --- a/app/lib/command_tag/processor.rb +++ b/app/lib/command_tag/processor.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class CommandTag::Processor + include Redisable include CommandTag::Commands STATEMENT_RE = /^\s*#!\s*([^\n]+ (?:start|begin|do)$.*)\n\s*#!\s*(?:end|stop|done)\s*$|^\s*#!\s*(.*?)\s*$/im.freeze @@ -18,6 +19,8 @@ class CommandTag::Processor end def process! + reset_status_caches + @statements = parse_statements @text = @text.gsub(STATEMENT_STRIP_RE, '').split("\n") @@ -42,6 +45,7 @@ class CommandTag::Processor end %w(at_end once_at_end).each { |suffix| execute_statements(suffix) } + reset_status_caches end private @@ -65,6 +69,17 @@ class CommandTag::Processor end end + def reset_status_caches + [@status, @parent].each do |status| + next unless @account.id == status&.account_id + + Rails.cache.delete_matched("statuses/#{status.id}-*") + Rails.cache.delete("statuses/#{status.id}") + Rails.cache.delete(status) + redis.zremrangebyscore("spam_check:#{status.account.id}", status.id, status.id) + end + end + def author_of_status? @account.id == @status.account_id end |