Post created is fired when topic created


(jj11909) #1

Working with the internal event hooks and I noticed, when the topic_created event triggers so does post_created. For the initial topic post, wouldn’t the assumption be that a post was created as well?

Is there a reason why they both would fire at the same time? It seems redundant to have both fire at the same time, especially because you cannot create a topic without an inital post.

Ex:

DiscourseEvent.on(:topic_created) do |topic|
    puts "New Topic"
end

DiscourseEvent.on(:post_created) do |post|
   puts "New post"
end

(Vinoth Kannan) #2

It is by design. If post_created event skipped in topic creations then the code which only listening post_created events won’t be executed.


(jj11909) #3

Ah that makes sense just seemed odd to me at first glance.


(Vinoth Kannan) #4