Class: Admin::InboundWebhookSourcesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Admin::InboundWebhookSourcesController
- Defined in:
- lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb
Overview
Manage the external systems allowed to POST webhooks into this tenant (OpenLoam::InboundWebhookSource) — manager-only. Create a source (token + secret are generated), copy the receive URL and secret to the sender, rotate either, toggle active, and see the most recent received deliveries.
Constant Summary
Constants included from Pagination
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #rotate_secret ⇒ Object
- #rotate_token ⇒ Object
- #toggle ⇒ Object
Methods inherited from BaseController
Methods included from Pagination
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 19 def create @source = OpenLoam::InboundWebhookSource.new(source_params) if @source.save redirect_to admin_inbound_webhook_sources_path, notice: "Source created. Copy the secret now — it signs every call." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
28 29 30 31 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 28 def destroy @source.destroy! redirect_to admin_inbound_webhook_sources_path, notice: "Source deleted." end |
#index ⇒ Object
10 11 12 13 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 10 def index @sources = OpenLoam::InboundWebhookSource.order(:name) @recent = OpenLoam::InboundWebhookDelivery.order(received_at: :desc).limit(20) end |
#new ⇒ Object
15 16 17 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 15 def new @source = OpenLoam::InboundWebhookSource.new(event_name: "inbound.webhook.received") end |
#rotate_secret ⇒ Object
33 34 35 36 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 33 def rotate_secret @source.rotate_secret! redirect_to admin_inbound_webhook_sources_path, notice: "Secret rotated — update the sender." end |
#rotate_token ⇒ Object
38 39 40 41 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 38 def rotate_token @source.rotate_token! redirect_to admin_inbound_webhook_sources_path, notice: "Token rotated — update the sender's URL." end |
#toggle ⇒ Object
43 44 45 46 |
# File 'lib/generators/open_loam/install/templates/admin/inbound_webhook_sources_controller.rb', line 43 def toggle @source.update!(active: !@source.active?) redirect_to admin_inbound_webhook_sources_path, notice: "Source #{@source.active? ? 'enabled' : 'disabled'}." end |