aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-10-11 16:46:35 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-10-11 16:46:35 -0400
commitf0dbc2734d7e51ccfbba99f2e4b89fbe1dce0bdc (patch)
treef594feee1a5225156fdd4bb2eabd2407f825674b
parent7b708a358db586545cd36d8842efd94dece124af (diff)
downloadkorg-helpers-f0dbc2734d7e51ccfbba99f2e4b89fbe1dce0bdc.tar.gz
More debugging options for groupsio webhook
Should be largely backwards compatible with what we had before, but allowing us to also troubleshoot occasional 500 errors. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--groupsio-webhook.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/groupsio-webhook.py b/groupsio-webhook.py
index b70ecc3..b140acb 100644
--- a/groupsio-webhook.py
+++ b/groupsio-webhook.py
@@ -18,6 +18,7 @@ import os
import sys
import logging
import logging.handlers
+import datetime
from configparser import ConfigParser, ExtendedInterpolation
@@ -121,6 +122,7 @@ class GroupsioListener(object):
try:
import ezpi
ezpi.add_rfc822(pirepo, msg)
+ ezpi.run_hook(pirepo)
logger.info('Wrote to public-inbox at %s', pirepo)
success = True
except Exception as ex:
@@ -168,6 +170,17 @@ class GroupsioListener(object):
resp.body = 'HMAC signature verification failed\n'
return
+ if self._config['main'].get('loglevel', 'info') == 'debug':
+ # In debug mode, we save all json submissions in the emerg dir
+ emerg_dir = self._config['main'].get('emerg_dir')
+ if emerg_dir and os.path.isdir(emerg_dir):
+ dt = datetime.datetime.now()
+ fname = dt.strftime('%Y%m%d-%H%M%S-%f')
+ efile = os.path.join(emerg_dir, f'{fname}.js')
+ with open(efile, 'w') as fh:
+ fh.write(raw)
+ logger.debug('Wrote raw json into %s', efile)
+
try:
doc = json.loads(raw)
except Exception as ex: