FEATURE: fix avatar in quotes when changing avatars

This commit is contained in:
Régis Hanol 2015-03-30 12:31:10 +02:00
parent b861669ceb
commit 588667b1e4
2 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,11 @@
module Jobs
class FixAvatarInQuotes < Jobs::Base
def execute(args)
user = User.find(args[:user_id])
post_ids_to_rebake = Post.exec_sql("SELECT post_id FROM quoted_posts WHERE quoted_post_id IN (SELECT id FROM posts WHERE user_id = ?)", user.id).values.flatten.map(&:to_i)
Post.where(id: post_ids_to_rebake).find_each.map(&:rebake!)
end
end
end

View File

@ -645,6 +645,8 @@ class User < ActiveRecord::Base
if SiteSetting.automatically_download_gravatars? && !avatar.last_gravatar_download_attempt if SiteSetting.automatically_download_gravatars? && !avatar.last_gravatar_download_attempt
Jobs.enqueue(:update_gravatar, user_id: self.id, avatar_id: avatar.id) Jobs.enqueue(:update_gravatar, user_id: self.id, avatar_id: avatar.id)
end end
Jobs.enqueue(:fix_avatar_in_quotes, user_id: self.id)
end end
def first_post_created_at def first_post_created_at