Extensibility for tracking changes to a topic

This commit is contained in:
Robin Ward
2015-01-27 12:13:45 -05:00
parent 420abdff69
commit d43944b3ed
7 changed files with 133 additions and 39 deletions

View File

@ -85,7 +85,7 @@ class PostsController < ApplicationController
[false, MultiJson.dump(errors: post_creator.errors.full_messages)]
else
DiscourseEvent.trigger(:topic_saved, post.topic, params, current_user)
DiscourseEvent.trigger(:topic_created, post.topic, params, current_user)
post_serializer = PostSerializer.new(post, scope: guardian, root: false)
post_serializer.draft_sequence = DraftSequence.current(current_user, post.topic.draft_key)
[true, MultiJson.dump(post_serializer)]
@ -382,7 +382,6 @@ class PostsController < ApplicationController
permitted = [
:raw,
:topic_id,
:title,
:archetype,
:category,
:target_usernames,
@ -415,8 +414,10 @@ class PostsController < ApplicationController
result[:is_warning] = (params[:is_warning] == "true")
end
# Enable plugins to whitelist additional parameters they might need
DiscourseEvent.trigger(:permit_post_params, result, params)
PostRevisor.tracked_fields.keys.each do |f|
params.permit(f => [])
result[f] = params[f] if params.has_key?(f)
end
result
end