From be4472d4eea1a5789451327bba522e36118c8487 Mon Sep 17 00:00:00 2001 From: Ching Date: Tue, 9 Apr 2024 15:11:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20sentry=20webhook=20?= =?UTF-8?q?=20=E8=8E=B7=E5=8F=96=20issue=20=E5=AD=97=E6=AE=B5=E6=9C=89?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E7=94=A8=20webhook=20=E5=88=9B=E5=BB=BA=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 5dd7368..adbf0ab 100644 --- a/app.py +++ b/app.py @@ -160,10 +160,12 @@ def sentry_event(): data = request.json logger.info('Received sentry event webhook: %s' % data) event = request.headers.get('Sentry-Hook-Resource') + # 因为 sentry 的 alert 还能用,所以暂时不需要通过 webhook 来通知 + return jsonify({'message': 'Ok'}), 200 if event == 'issue': if data.get('action') == 'created': title = f"{data['issue']['shortId']} {data['issue']['title']}" - body = data['issue']['culprit'] + body = data['data']['issue']['culprit'] # create a new issue in linear create_data = {'query': 'mutation { issueCreate(input: { title: "%s" description: "%s" teamId: "1f28d52c-c91a-4c48-8ca8-96425dfd6516" assigneeId: "38c20f6d-8088-461c-9ea3-9f36e185cb62" labelIds: ["b40ea30a-e48b-4511-bde7-0a3c732cf752"]}) { issue { id } } }' % (title, body)} resp = requests.post(LINEAR_API_URL, json=create_data, headers={'Authorization': LINEAR_API_KEY}) @@ -171,7 +173,7 @@ def sentry_event(): logger.error('Failed to create issue: %s' % resp.text) return jsonify({'message': 'Failed to create issue'}), 500 issue_id = resp.json().get('data').get('issueCreate').get('issue').get('id') - _attach_url_to_issue(issue_id, data['issue']['web_url'], title) + _attach_url_to_issue(issue_id, data['data']['issue']['web_url'], title) return jsonify({'message': 'Ok'}), 200