mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 04:33:37 +08:00
b58867b6e9
Includes support for flags, reviewable users and queued posts, with REST API backwards compatibility. Co-Authored-By: romanrizzi <romanalejandro@gmail.com> Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
19 lines
716 B
Ruby
19 lines
716 B
Ruby
class Jobs::TopicActionConverter < Jobs::Base
|
|
|
|
# Re-creating all the user actions could be very slow, so let's do it in a job
|
|
# to avoid a N+1 query on a front facing operation.
|
|
def execute(args)
|
|
topic = Topic.find_by(id: args[:topic_id])
|
|
return if topic.blank?
|
|
|
|
UserAction.where(
|
|
target_topic_id: topic.id,
|
|
action_type: [UserAction::GOT_PRIVATE_MESSAGE, UserAction::NEW_PRIVATE_MESSAGE]).find_each do |ua|
|
|
UserAction.remove_action!(ua.attributes.symbolize_keys.slice(:action_type, :user_id, :acting_user_id, :target_topic_id, :target_post_id))
|
|
end
|
|
topic.posts.each { |post| UserActionManager.post_created(post) }
|
|
UserActionManager.topic_created(topic)
|
|
end
|
|
|
|
end
|