2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-09-12 16:46:43 -05:00
|
|
|
class ComposerMessagesController < ApplicationController
|
|
|
|
|
2018-01-31 22:17:59 -06:00
|
|
|
requires_login
|
2013-09-12 16:46:43 -05:00
|
|
|
|
|
|
|
def index
|
2016-06-06 15:58:35 -05:00
|
|
|
finder = ComposerMessagesFinder.new(current_user, params.slice(:composer_action, :topic_id, :post_id))
|
2016-06-06 12:52:24 -05:00
|
|
|
json = { composer_messages: [finder.find].compact }
|
2013-09-12 16:46:43 -05:00
|
|
|
|
2016-06-08 16:20:32 -05:00
|
|
|
if params[:topic_id].present?
|
2016-06-06 15:58:35 -05:00
|
|
|
topic = Topic.where(id: params[:topic_id]).first
|
|
|
|
if guardian.can_see?(topic)
|
2017-07-27 20:20:09 -05:00
|
|
|
json[:extras] = { duplicate_lookup: TopicLink.duplicate_lookup(topic) }
|
2016-06-06 15:58:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-06 12:52:24 -05:00
|
|
|
render_json_dump(json, rest_serializer: true)
|
|
|
|
end
|
2013-09-12 16:46:43 -05:00
|
|
|
end
|