webhooks_controller.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class WebhooksController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  4. def preview
  5. ticket = TicketPolicy::ReadScope.new(current_user).resolve.last
  6. render json: JSON.pretty_generate({
  7. ticket: TriggerWebhookJob::RecordPayload.generate(ticket),
  8. article: TriggerWebhookJob::RecordPayload.generate(ticket.articles.last),
  9. }),
  10. status: :ok
  11. end
  12. def index
  13. model_index_render(Webhook, params)
  14. end
  15. def show
  16. model_show_render(Webhook, params)
  17. end
  18. def create
  19. model_create_render(Webhook, params)
  20. end
  21. def update
  22. model_update_render(Webhook, params)
  23. end
  24. def destroy
  25. model_destroy_render(Webhook, params)
  26. end
  27. def pre_defined_webhooks
  28. render json: Webhook::PreDefined.pre_defined_webhook_definitions, status: :ok
  29. end
  30. def replacements
  31. render json: TriggerWebhookJob::CustomPayload.replacements(pre_defined_webhook_type: params[:pre_defined_webhook_type]),
  32. status: :ok
  33. end
  34. end