aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-08-26 01:17:55 +0000
committerubq323 <ubq323>2021-08-26 01:17:55 +0000
commit4e2fadd8866f61a22fac3f862789f22b705035c6 (patch)
tree19eff5260c672039b300d5890f3a34d9ef16383f
parent23c5ed30f115c8ee8cb9bf16441c30e0a0e61403 (diff)
webhook inheritance
-rw-r--r--apioforum/webhooks.py13
1 files changed, 12 insertions, 1 deletions
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: