webhooks_controller.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 search
  28. model_search_render(Webhook, params)
  29. end
  30. def pre_defined_webhooks
  31. render json: Webhook::PreDefined.pre_defined_webhook_definitions, status: :ok
  32. end
  33. def replacements
  34. render json: TriggerWebhookJob::CustomPayload.replacements(pre_defined_webhook_type: params[:pre_defined_webhook_type]),
  35. status: :ok
  36. end
  37. end