2013-09-12 17:46:43 -04:00
|
|
|
require_dependency 'composer_messages_finder'
|
|
|
|
|
|
|
|
class ComposerMessagesController < ApplicationController
|
|
|
|
|
|
|
|
before_filter :ensure_logged_in
|
|
|
|
|
|
|
|
def index
|
2016-06-06 16:58:35 -04:00
|
|
|
finder = ComposerMessagesFinder.new(current_user, params.slice(:composer_action, :topic_id, :post_id))
|
2016-06-06 13:52:24 -04:00
|
|
|
json = { composer_messages: [finder.find].compact }
|
2013-09-12 17:46:43 -04:00
|
|
|
|
2016-06-06 16:58:35 -04:00
|
|
|
if params[:composer_action] == "reply" && params[:topic_id].present?
|
|
|
|
topic = Topic.where(id: params[:topic_id]).first
|
|
|
|
if guardian.can_see?(topic)
|
|
|
|
json[:extras] = {duplicate_lookup: TopicLink.duplicate_lookup(topic)}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-06 13:52:24 -04:00
|
|
|
render_json_dump(json, rest_serializer: true)
|
|
|
|
end
|
2013-09-12 17:46:43 -04:00
|
|
|
end
|