مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-01-18 05:49:47 +00:00
initial commit from appmail
هذا الالتزام موجود في:
51
app/controllers/webhooks_controller.rb
Normal file
51
app/controllers/webhooks_controller.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
class WebhooksController < ApplicationController
|
||||
include WithinOrganization
|
||||
before_action { @server = organization.servers.present.find_by_permalink!(params[:server_id]) }
|
||||
before_action { params[:id] && @webhook = @server.webhooks.find_by_uuid!(params[:id]) }
|
||||
|
||||
def index
|
||||
@webhooks = @server.webhooks.order(:url).to_a
|
||||
end
|
||||
|
||||
def new
|
||||
@webhook = @server.webhooks.build(:all_events => true)
|
||||
end
|
||||
|
||||
def create
|
||||
@webhook = @server.webhooks.build(safe_params)
|
||||
if @webhook.save
|
||||
redirect_to_with_json [organization, @server, :webhooks]
|
||||
else
|
||||
render_form_errors 'new', @webhook
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @webhook.update(safe_params)
|
||||
redirect_to_with_json [organization, @server, :webhooks]
|
||||
else
|
||||
render_form_errors 'edit', @webhook
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@webhook.destroy
|
||||
redirect_to_with_json [organization, @server, :webhooks]
|
||||
end
|
||||
|
||||
def history
|
||||
@current_page = params[:page] ? params[:page].to_i : 1
|
||||
@requests = @server.message_db.webhooks.list(@current_page)
|
||||
end
|
||||
|
||||
def history_request
|
||||
@req = @server.message_db.webhooks.find(params[:uuid])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def safe_params
|
||||
params.require(:webhook).permit(:name, :url, :all_events, :enabled, :events => [])
|
||||
end
|
||||
|
||||
end
|
||||
المرجع في مشكلة جديدة
حظر مستخدم