fix: 修复 sentry webhook 获取 issue 字段有误的问题;暂时禁用 webhook 创建 issue
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ching 2024-04-09 15:11:53 +08:00
parent 979b5e8f1a
commit be4472d4ee

6
app.py
View File

@ -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