diff --git a/app/assets/javascripts/admin/addon/components/webhook-events.hbs b/app/assets/javascripts/admin/addon/components/webhook-events.hbs index 7bfdeb1111d..0ba3222c84e 100644 --- a/app/assets/javascripts/admin/addon/components/webhook-events.hbs +++ b/app/assets/javascripts/admin/addon/components/webhook-events.hbs @@ -13,6 +13,12 @@ class="delivery-status-filters" /> + + event.id); + + this.count = this.events.length; + return this.dialog.yesNoConfirm({ + message: I18n.t("admin.web_hooks.events.bulk_redeliver_confirm", { + count: this.count, + }), + didConfirm: async () => { + try { + const json = await ajax( + `/admin/api/web_hooks/${this.args.webhookId}/events/bulk_redeliver`, + { type: "POST", data: { event_ids: this.eventIds } } + ); + this.args.event.setProperties(json.web_hook_event); + } catch (e) { + popupAjaxError(e); + } + }, + }); + } } diff --git a/app/controllers/admin/web_hooks_controller.rb b/app/controllers/admin/web_hooks_controller.rb index 8c99e6a7702..64945205f92 100644 --- a/app/controllers/admin/web_hooks_controller.rb +++ b/app/controllers/admin/web_hooks_controller.rb @@ -135,6 +135,13 @@ class Admin::WebHooksController < Admin::AdminController end end + def bulk_redeliver_events + limit = 50 + offset = params[:offset].to_i + failed_events = @web_hook.web_hook_events.failed.limit(limit).offset(offset) + render_serialized(failed_events, AdminWebHookEventSerializer, root: "web_hook_event") + end + def ping Jobs.enqueue( :emit_web_hook_event, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index caa093d2a41..adfb2a952b0 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5347,6 +5347,7 @@ en: request: "Request" response: "Response" redeliver_confirm: "Are you sure you want to redeliver the same payload?" + bulk_redeliver_confirm: "Are you sure you want to redeliver %{count} webhook events? (You can redeliver up to 50 failed events at once.)" headers: "Headers" payload: "Payload" body: "Body" @@ -5356,6 +5357,7 @@ en: timestamp: "Created" completion: "Completion Time" actions: "Actions" + redeliver_failed: "Redeliver Failed" filter_status: all: "All Events" successful: "Delivered" diff --git a/config/routes.rb b/config/routes.rb index 6058895335b..626ac09d8d3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -344,6 +344,7 @@ Discourse::Application.routes.draw do get "web_hook_events/:id" => "web_hooks#list_events", :as => :web_hook_events get "web_hooks/:id/events/bulk" => "web_hooks#bulk_events" post "web_hooks/:web_hook_id/events/:event_id/redeliver" => "web_hooks#redeliver_event" + post "web_hooks/:web_hook_id/events/bulk_redeliver" => "web_hooks#bulk_redeliver_events" post "web_hooks/:id/ping" => "web_hooks#ping" end end