From 7536d15c7322d3ead1ad00f30289fa2b3c4a65a0 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sun, 14 Aug 2022 06:28:14 -0700 Subject: [PATCH] Only include issue description on open Closes issue #4 --- webhooks.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webhooks.py b/webhooks.py index 954e1fa..3caf0a1 100644 --- a/webhooks.py +++ b/webhooks.py @@ -27,7 +27,11 @@ with open(filename, "rb") as config_file: srht_public_key = Ed25519PublicKey.from_public_bytes( base64.b64decode(config['srht_payload_sig'])) +# GitHub webhooks +# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads +# Gittea webhooks +# https://docs.gitea.io/en-us/webhooks/ @app.route('/gitea/', methods=['POST']) def gitea_event(gateway=None): @@ -97,7 +101,8 @@ def gt_issue_event(gateway, data): action = data["action"] body = f"[{project}] {username} {action} issue #{number}: {title}\n" - body += f"{description}" + if action in ["opened", "reopened"]: + body += f"{description}" logging.debug(body) mb_url = config["codeberg_gateway"] @@ -124,6 +129,9 @@ def gt_comment_event(gateway, data): payload = { 'gateway': gateway, 'username': "codeberg", 'text': body.rstrip() } r = requests.post(mb_url, json=payload) +# GitLab webhooks +# https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html + @app.route('/gitlab/', methods=['POST']) def gitlab_event(gateway=None): token = request.headers['X-Gitlab-Token'] @@ -199,8 +207,9 @@ def gl_issue_event(gateway, data): action = data["object_attributes"]["action"] else: action = "?" - body = f"[{project}] {username} {action}ed issue #{oid}: {title}\n" - body += f"{description}" + body = f"[{project}] {username} {action} issue #{oid}: {title}\n" + if action in ["open", "reopen"]: + body += f"{description}" logging.debug(body) mb_url = config["gitlab_gateway"]