From 4e2fadd8866f61a22fac3f862789f22b705035c6 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 26 Aug 2021 01:17:55 +0000 Subject: webhook inheritance --- apioforum/webhooks.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apioforum/webhooks.py b/apioforum/webhooks.py index 671100c..2407039 100644 --- a/apioforum/webhooks.py +++ b/apioforum/webhooks.py @@ -105,7 +105,18 @@ def discord_on_new_post(wh_url, post): def _do_webhooks(forum_id,thing,fn): db = get_db() # todo inheritance - webhooks = db.execute("select * from webhooks where forum = ? and type = 'discord'",(forum_id,)).fetchall() + webhooks = db.execute(""" + WITH RECURSIVE fs AS + (SELECT * FROM forums WHERE id = ? + UNION ALL + SELECT forums.* FROM forums, fs WHERE fs.parent=forums.id) + SELECT * from webhooks + WHERE + webhooks.forum = ? + OR + webhooks.inherits AND webhooks.forum IN (SELECT id FROM fS); + + """,(forum_id,forum_id)).fetchall() for wh in webhooks: wh_url = wh['url'] try: -- cgit v1.2.3