mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Centralize MessageBus post updates
After this change, only two files directly publish to MessageBus with a topic interpolated in the channel: Post and TopicUser.
This commit is contained in:
@@ -21,6 +21,7 @@ class PostRevisor
|
||||
@opts = opts
|
||||
@new_raw = TextCleaner.normalize_whitespaces(new_raw).strip
|
||||
|
||||
# TODO this is not in a transaction - dangerous!
|
||||
return false unless should_revise?
|
||||
@post.acting_user = @editor
|
||||
revise_post
|
||||
@@ -30,7 +31,7 @@ class PostRevisor
|
||||
update_topic_word_counts
|
||||
@post.advance_draft_sequence
|
||||
PostAlerter.new.after_save_post(@post)
|
||||
publish_revision
|
||||
@post.publish_change_to_clients! :revised
|
||||
BadgeGranter.queue_badge_grant(Badge::Trigger::PostRevision, post: @post)
|
||||
|
||||
true
|
||||
@@ -38,17 +39,6 @@ class PostRevisor
|
||||
|
||||
private
|
||||
|
||||
def publish_revision
|
||||
MessageBus.publish("/topic/#{@post.topic_id}",{
|
||||
id: @post.id,
|
||||
post_number: @post.post_number,
|
||||
updated_at: @post.updated_at,
|
||||
type: "revised"
|
||||
},
|
||||
group_ids: @post.topic.secure_group_ids
|
||||
)
|
||||
end
|
||||
|
||||
def should_revise?
|
||||
@post.raw != @new_raw || @opts[:changed_owner]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user