mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
This change ensures that users can only create tickets for topics they have access to view. Also adds tests to the happy path of ticket creation.
23 lines
653 B
Ruby
Vendored
23 lines
653 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseZendeskPlugin
|
|
class IssuesController < ApplicationController
|
|
include DiscourseZendeskPlugin::Helper
|
|
|
|
requires_plugin PLUGIN_NAME
|
|
|
|
def create
|
|
topic = Topic.find(params[:topic_id])
|
|
guardian.ensure_can_see!(topic)
|
|
|
|
if topic.custom_fields[DiscourseZendeskPlugin::ZENDESK_ID_FIELD].blank?
|
|
create_ticket(topic.first_post)
|
|
end
|
|
|
|
topic_view = ::TopicView.new(topic.id, current_user)
|
|
topic_view_serializer =
|
|
::TopicViewSerializer.new(topic_view, scope: topic_view.guardian, root: false)
|
|
render_json_dump topic_view_serializer
|
|
end
|
|
end
|
|
end
|