From 706816b4321337d56ff3121186567363b882d01d Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 19:43:55 +0200 Subject: Added uid, basedir and baseurl to the notify webhook message. --- data.c | 4 ++++ examples/auto_follower_webhook.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/data.c b/data.c index 74bc112..28f7cd9 100644 --- a/data.c +++ b/data.c @@ -3534,6 +3534,10 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) /* add more data */ msg = xs_dict_set(msg, "target", user->actor); + msg = xs_dict_set(msg, "uid", user->uid); + msg = xs_dict_set(msg, "basedir", srv_basedir); + msg = xs_dict_set(msg, "baseurl", srv_baseurl); + xs *actor_obj = NULL; 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 @@ # This is an example of a snac webhook that automatically follows all new followers. -# To use it, set the variables snac_basedir and snac_user to something reasonable, -# configure the user webhook to be http://localhost:12345, and run this program. +# To use it, configure the user webhook to be http://localhost:12345, and run this program. # copyright (C) 2025 grunfink et al. / MIT license @@ -14,8 +13,6 @@ import os host_name = "localhost" server_port = 12345 -snac_basedir = "/var/snac/example_instance" -snac_user = "example_user" class SnacAutoResponderServer(BaseHTTPRequestHandler): @@ -35,7 +32,10 @@ class SnacAutoResponderServer(BaseHTTPRequestHandler): if type == "Follow": actor = noti["actor"] - cmd = "snac follow %s %s %s" % (snac_basedir, snac_user, actor) + uid = noti["uid"] + basedir = noti["basedir"] + + cmd = "snac follow %s %s %s" % (basedir, uid, actor) os.system(cmd) -- cgit v1.2.3