55
66logger = init_logger (__name__ )
77
8+ # Example configuration:
9+ # default_options = {
10+ # "webhook-urls": ["https://your-webhook-endpoint.com"],
11+ # "headers": {
12+ # "Authorization": "Bearer YourToken",
13+ # "x-conserver-api-token": "your-api-token",
14+ # },
15+ # }
16+
817default_options = {
9- "webhook-urls" : ["https://eo91qivu6evxsty.m.pipedream.net" ],
10- "auth_header" : "Bearer ThompsonsClamBar" ,
11- "api_token" : "default-api-token" ,
18+ "webhook-urls" : [],
19+ "headers" : {},
1220}
1321
1422
@@ -17,23 +25,30 @@ def run(
1725 link_name ,
1826 opts = default_options ,
1927):
20- logger .debug ("Starting transcribe ::run" )
28+ logger .debug ("Starting webhook ::run" )
2129
2230 vcon_redis = VconRedis ()
2331 vCon = vcon_redis .get_vcon (vcon_uuid )
2432
2533 # The webhook needs a stringified JSON version.
2634 json_dict = vCon .to_dict ()
2735
36+ # Build headers from configuration
37+ headers = opts .get ("headers" , {})
38+
39+ # Validate webhook URLs are configured
40+ webhook_urls = opts .get ("webhook-urls" , [])
41+ if not webhook_urls :
42+ logger .warning (
43+ f"webhook plugin: no webhook-urls configured for vcon { vcon_uuid } , skipping"
44+ )
45+ return vcon_uuid
46+
2847 # Post this to each webhook url
29- for url in opts [ "webhook-urls" ] :
48+ for url in webhook_urls :
3049 logger .info (
3150 f"webhook plugin: posting vcon { vcon_uuid } to webhook url: { url } "
3251 )
33- headers = {
34- "Authorization" : opts .get ("auth_header" ),
35- "x-conserver-api-token" : opts .get ("api_token" ),
36- }
3752 resp = requests .post (url , json = json_dict , headers = headers )
3853 logger .info (
3954 f"webhook plugin response for { vcon_uuid } : { resp .status_code } { resp .text } "
0 commit comments