Files
VOREStation/code/controllers/subsystems/webhooks.dm
T
Selis f4bf017921 Unit Test rework & Master/Ticker update (#17912)
* Unit Test rework & Master/Ticker update

* Fixes and working unit testing

* Fixes

* Test fixes and FA update

* Fixed runtimes

* Radio subsystem

* move that glob wherever later

* ident

* CIBUILDING compile option

* Fixed runtimes

* Some changes to the workflow

* CI Split

* More split

* Pathing

* Linters and Annotators

* ci dir fix

* Missing undef fixed

* Enable grep checks

* More test conversions

* More split

* Correct file

* Removes unneeded inputs

* oop

* More dependency changes

* More conversions

* Conversion fixes

* Fixes

* Some assert fixes

* Corrects start gate

* Converted some README.dms to README.mds

* Removes duplicate proc

* Removes unused defines

* Example configs

* fix dll access viol by double calling

* Post-rebase fixes

* Cleans up names global list

* Undef restart counter

* More code/game/ cleanup

* Statpanel update

* Skybox

* add

* Fix ticker

* Roundend fix

* Persistence dependency update

* Reordering

* Reordering

* Reordering

* Initstage fix

* .

* .

* Reorder

* Reorder

* Circle

* Mobs

* Air

* Test fix

* CI Script Fix

* Configs

* More ticker stuff

* This is now in 'reboot world'

* Restart world announcements

* no glob in PreInit

* to define

* Update

* Removed old include

* Make this file normal again

* moved

* test

* shared unit testing objects

* Updates batched_spritesheets and universal_icon

* .

* job data debug

* rm that

* init order

* show us

* .

* i wonder

* .

* .

* urg

* do we not have a job ID?

* .

* rm sleep for now

* updated rust-g linux binaries

* binaries update 2

* binaries update 3

* testing something

* change that

* test something

* .

* .

* .

* locavar

* test

* move that

* .

* debug

* don't run this test

* strack trace it

* cleaner

* .

* .

* cras again

* also comment this out

* return to official rust g

* Update robot_icons.dm

* monitor the generation

* .

---------

Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
2025-08-10 01:37:23 +02:00

97 lines
3.1 KiB
Plaintext

SUBSYSTEM_DEF(webhooks)
name = "Webhooks"
dependencies = list(
/datum/controller/subsystem/server_maint,
)
flags = SS_NO_FIRE
var/list/webhook_decls = list()
/datum/controller/subsystem/webhooks/Initialize()
load_webhooks()
return SS_INIT_SUCCESS
/datum/controller/subsystem/webhooks/proc/load_webhooks()
if(!fexists(HTTP_POST_DLL_LOCATION))
to_world_log("Unable to locate HTTP POST lib at [HTTP_POST_DLL_LOCATION], webhooks will not function on this run.")
return
var/list/all_webhooks_by_id = list()
var/list/all_webhooks = decls_repository.get_decls_of_subtype(/decl/webhook)
for(var/wid in all_webhooks)
var/decl/webhook/webhook = all_webhooks[wid]
if(webhook.id)
all_webhooks_by_id[webhook.id] = webhook
webhook_decls.Cut()
var/webhook_config = safe_file2text("config/webhooks.json")
if(webhook_config)
for(var/webhook_data in cached_json_decode(webhook_config))
var/wid = webhook_data["id"]
var/wurl = webhook_data["url"]
var/list/wmention = webhook_data["mentions"]
if(wmention && !islist(wmention))
wmention = list(wmention)
to_world_log("Setting up webhook [wid].")
if(wid && wurl && all_webhooks_by_id[wid])
var/decl/webhook/webhook = all_webhooks_by_id[wid]
webhook.urls = islist(wurl) ? wurl : list(wurl)
for(var/url in webhook.urls)
if(!webhook.urls[url])
webhook.urls[url] = list()
else if(!islist(webhook.urls[url]))
webhook.urls[url] = list(webhook.urls[url])
if(wmention)
webhook.mentions = wmention?.Copy()
webhook_decls[wid] = webhook
to_world_log("Webhook [wid] ready.")
else
to_world_log("Failed to set up webhook [wid].")
/datum/controller/subsystem/webhooks/proc/send(var/wid, var/wdata)
var/decl/webhook/webhook = webhook_decls[wid]
if(webhook)
if(webhook.send(wdata))
to_world_log("Sent webhook [webhook.id].")
log_debug("Webhook sent: [webhook.id].")
else
to_world_log("Failed to send webhook [webhook.id].")
log_debug("Webhook failed to send: [webhook.id].")
/client/proc/reload_webhooks()
set name = "Reload Webhooks"
set category = "Debug"
if(!check_rights_for(src, R_HOLDER))
return
if(!SSwebhooks.initialized)
to_chat(usr, span_warning("Let the webhook subsystem initialize before trying to reload it."))
return
to_world_log("[usr.key] has reloaded webhooks.")
log_and_message_admins("has reloaded webhooks.")
SSwebhooks.load_webhooks()
/client/proc/ping_webhook()
set name = "Ping Webhook"
set category = "Debug"
if(!check_rights_for(src, R_HOLDER))
return
if(!length(SSwebhooks.webhook_decls))
to_chat(usr, span_warning("Webhook list is empty; either webhooks are disabled, webhooks aren't configured, or the subsystem hasn't initialized."))
return
var/choice = tgui_input_list(usr, "Select a webhook to ping.", "Ping Webhook", SSwebhooks.webhook_decls)
if(choice && SSwebhooks.webhook_decls[choice])
var/decl/webhook/webhook = SSwebhooks.webhook_decls[choice]
log_and_message_admins("has pinged webhook [choice].", usr)
to_world_log("[usr.key] has pinged webhook [choice].")
webhook.send()
/hook/roundstart/proc/run_webhook()
SSwebhooks.send(WEBHOOK_ROUNDSTART, list("url" = get_world_url()))
return 1