2013-09-13 05:46:43 +08:00
|
|
|
require_dependency 'composer_messages_finder'
|
|
|
|
|
|
|
|
class ComposerMessagesController < ApplicationController
|
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
before_action :ensure_logged_in
|
2013-09-13 05:46:43 +08:00
|
|
|
|
|
|
|
def index
|
2016-06-07 04:58:35 +08:00
|
|
|
finder = ComposerMessagesFinder.new(current_user, params.slice(:composer_action, :topic_id, :post_id))
|
2016-06-07 01:52:24 +08:00
|
|
|
json = { composer_messages: [finder.find].compact }
|
2013-09-13 05:46:43 +08:00
|
|
|
|
2016-06-09 05:20:32 +08:00
|
|
|
if params[:topic_id].present?
|
2016-06-07 04:58:35 +08:00
|
|
|
topic = Topic.where(id: params[:topic_id]).first
|
|
|
|
if guardian.can_see?(topic)
|
2017-07-28 09:20:09 +08:00
|
|
|
json[:extras] = { duplicate_lookup: TopicLink.duplicate_lookup(topic) }
|
2016-06-07 04:58:35 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-07 01:52:24 +08:00
|
|
|
render_json_dump(json, rest_serializer: true)
|
|
|
|
end
|
2013-09-13 05:46:43 +08:00
|
|
|
end
|