diff options
| author | 2025-05-30 19:43:55 +0200 | |
|---|---|---|
| committer | 2025-05-30 19:43:55 +0200 | |
| commit | 706816b4321337d56ff3121186567363b882d01d (patch) | |
| tree | fd2791488024273af9795fe6399f507a78994439 | |
| parent | Added a new server knob disable_notify_webhook. (diff) | |
| download | penes-snac2-706816b4321337d56ff3121186567363b882d01d.tar.gz penes-snac2-706816b4321337d56ff3121186567363b882d01d.tar.xz penes-snac2-706816b4321337d56ff3121186567363b882d01d.zip | |
Added uid, basedir and baseurl to the notify webhook message.
| -rw-r--r-- | data.c | 4 | ||||
| -rwxr-xr-x | examples/auto_follower_webhook.py | 10 |
2 files changed, 9 insertions, 5 deletions
| @@ -3534,6 +3534,10 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) | |||
| 3534 | 3534 | ||
| 3535 | /* add more data */ | 3535 | /* add more data */ |
| 3536 | msg = xs_dict_set(msg, "target", user->actor); | 3536 | msg = xs_dict_set(msg, "target", user->actor); |
| 3537 | msg = xs_dict_set(msg, "uid", user->uid); | ||
| 3538 | msg = xs_dict_set(msg, "basedir", srv_basedir); | ||
| 3539 | msg = xs_dict_set(msg, "baseurl", srv_baseurl); | ||
| 3540 | |||
| 3537 | xs *actor_obj = NULL; | 3541 | xs *actor_obj = NULL; |
| 3538 | 3542 | ||
| 3539 | if (valid_status(object_get(xs_dict_get(noti, "actor"), &actor_obj)) && actor_obj) | 3543 | if (valid_status(object_get(xs_dict_get(noti, "actor"), &actor_obj)) && actor_obj) |
diff --git a/examples/auto_follower_webhook.py b/examples/auto_follower_webhook.py index e1192c1..eb632a3 100755 --- a/examples/auto_follower_webhook.py +++ b/examples/auto_follower_webhook.py | |||
| @@ -2,8 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | # This is an example of a snac webhook that automatically follows all new followers. | 3 | # This is an example of a snac webhook that automatically follows all new followers. |
| 4 | 4 | ||
| 5 | # To use it, set the variables snac_basedir and snac_user to something reasonable, | 5 | # To use it, configure the user webhook to be http://localhost:12345, and run this program. |
| 6 | # configure the user webhook to be http://localhost:12345, and run this program. | ||
| 7 | 6 | ||
| 8 | # copyright (C) 2025 grunfink et al. / MIT license | 7 | # copyright (C) 2025 grunfink et al. / MIT license |
| 9 | 8 | ||
| @@ -14,8 +13,6 @@ import os | |||
| 14 | 13 | ||
| 15 | host_name = "localhost" | 14 | host_name = "localhost" |
| 16 | server_port = 12345 | 15 | server_port = 12345 |
| 17 | snac_basedir = "/var/snac/example_instance" | ||
| 18 | snac_user = "example_user" | ||
| 19 | 16 | ||
| 20 | class SnacAutoResponderServer(BaseHTTPRequestHandler): | 17 | class SnacAutoResponderServer(BaseHTTPRequestHandler): |
| 21 | 18 | ||
| @@ -35,7 +32,10 @@ class SnacAutoResponderServer(BaseHTTPRequestHandler): | |||
| 35 | 32 | ||
| 36 | if type == "Follow": | 33 | if type == "Follow": |
| 37 | actor = noti["actor"] | 34 | actor = noti["actor"] |
| 38 | cmd = "snac follow %s %s %s" % (snac_basedir, snac_user, actor) | 35 | uid = noti["uid"] |
| 36 | basedir = noti["basedir"] | ||
| 37 | |||
| 38 | cmd = "snac follow %s %s %s" % (basedir, uid, actor) | ||
| 39 | 39 | ||
| 40 | os.system(cmd) | 40 | os.system(cmd) |
| 41 | 41 | ||