parent
a2740624cd
commit
7536d15c73
1 changed files with 12 additions and 3 deletions
15
webhooks.py
15
webhooks.py
|
@ -27,7 +27,11 @@ with open(filename, "rb") as config_file:
|
||||||
|
|
||||||
srht_public_key = Ed25519PublicKey.from_public_bytes(
|
srht_public_key = Ed25519PublicKey.from_public_bytes(
|
||||||
base64.b64decode(config['srht_payload_sig']))
|
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/<gateway>', methods=['POST'])
|
@app.route('/gitea/<gateway>', methods=['POST'])
|
||||||
def gitea_event(gateway=None):
|
def gitea_event(gateway=None):
|
||||||
|
@ -97,7 +101,8 @@ def gt_issue_event(gateway, data):
|
||||||
action = data["action"]
|
action = data["action"]
|
||||||
|
|
||||||
body = f"[{project}] {username} {action} issue #{number}: {title}\n"
|
body = f"[{project}] {username} {action} issue #{number}: {title}\n"
|
||||||
body += f"{description}"
|
if action in ["opened", "reopened"]:
|
||||||
|
body += f"{description}"
|
||||||
|
|
||||||
logging.debug(body)
|
logging.debug(body)
|
||||||
mb_url = config["codeberg_gateway"]
|
mb_url = config["codeberg_gateway"]
|
||||||
|
@ -124,6 +129,9 @@ def gt_comment_event(gateway, data):
|
||||||
payload = { 'gateway': gateway, 'username': "codeberg", 'text': body.rstrip() }
|
payload = { 'gateway': gateway, 'username': "codeberg", 'text': body.rstrip() }
|
||||||
r = requests.post(mb_url, json=payload)
|
r = requests.post(mb_url, json=payload)
|
||||||
|
|
||||||
|
# GitLab webhooks
|
||||||
|
# https://docs.gitlab.com/ee/user/project/integrations/webhook_events.html
|
||||||
|
|
||||||
@app.route('/gitlab/<gateway>', methods=['POST'])
|
@app.route('/gitlab/<gateway>', methods=['POST'])
|
||||||
def gitlab_event(gateway=None):
|
def gitlab_event(gateway=None):
|
||||||
token = request.headers['X-Gitlab-Token']
|
token = request.headers['X-Gitlab-Token']
|
||||||
|
@ -199,8 +207,9 @@ def gl_issue_event(gateway, data):
|
||||||
action = data["object_attributes"]["action"]
|
action = data["object_attributes"]["action"]
|
||||||
else:
|
else:
|
||||||
action = "?"
|
action = "?"
|
||||||
body = f"[{project}] {username} {action}ed issue #{oid}: {title}\n"
|
body = f"[{project}] {username} {action} issue #{oid}: {title}\n"
|
||||||
body += f"{description}"
|
if action in ["open", "reopen"]:
|
||||||
|
body += f"{description}"
|
||||||
|
|
||||||
logging.debug(body)
|
logging.debug(body)
|
||||||
mb_url = config["gitlab_gateway"]
|
mb_url = config["gitlab_gateway"]
|
||||||
|
|
Reference in a new issue