feat: 增加新建 issue 的通知 TUN-31
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
129c550d09
commit
8afd4b4132
20
app.py
20
app.py
@ -41,24 +41,34 @@ def linear_issue():
|
|||||||
if not 'action' in data:
|
if not 'action' in data:
|
||||||
logger.error('Invalid issue data: %s' % data)
|
logger.error('Invalid issue data: %s' % data)
|
||||||
return jsonify({'message': 'Invalid issue data'}), 400
|
return jsonify({'message': 'Invalid issue data'}), 400
|
||||||
if data['action'] != 'update':
|
if data['action'] not in ['update', 'create']:
|
||||||
logger.warning('Ignoring issue action: %s' % data['action'])
|
logger.warning('Ignoring issue action: %s' % data['action'])
|
||||||
return jsonify({'message': 'Ignoring issue action'}), 200
|
return jsonify({'message': 'Ignoring issue action'}), 200
|
||||||
# Send Discord message
|
# Send Discord message
|
||||||
if not data['updatedFrom'].get('stateId'):
|
|
||||||
logger.warning('Ignoring issue changes')
|
|
||||||
return jsonify({'message': 'Ignoring issue changes'}), 200
|
|
||||||
apobj = apprise.Apprise()
|
apobj = apprise.Apprise()
|
||||||
apobj.add(f'discord://{DISCORD_WEBHOOK_ID}/{DISCORD_WEBHOOK_TOKEN}/?avatar=No&format=markdown&url={data["data"]["url"]}')
|
apobj.add(f'discord://{DISCORD_WEBHOOK_ID}/{DISCORD_WEBHOOK_TOKEN}/?avatar=No&format=markdown&url={data["data"]["url"]}')
|
||||||
apobj.asset.app_id = None
|
apobj.asset.app_id = None
|
||||||
|
|
||||||
|
if data['action'] == 'update':
|
||||||
|
if not data['updatedFrom'].get('stateId'):
|
||||||
|
logger.warning('Ignoring issue changes')
|
||||||
|
return jsonify({'message': 'Ignoring issue changes'}), 200
|
||||||
title = data['data']['identifier'] + ' - ' + data['data']['title']
|
title = data['data']['identifier'] + ' - ' + data['data']['title']
|
||||||
|
|
||||||
body = f"状态变更。\n#Status\n{data['data']['state']['name']}"
|
body = f"状态变更。\n#Status\n{data['data']['state']['name']}"
|
||||||
notify_type = apprise.NotifyType.INFO
|
notify_type = apprise.NotifyType.INFO
|
||||||
if data['data']['state']['type'] == 'completed':
|
if data['data']['state']['type'] == 'completed':
|
||||||
notify_type = apprise.NotifyType.SUCCESS
|
notify_type = apprise.NotifyType.SUCCESS
|
||||||
apobj.notify(body=body, title=title, notify_type=notify_type)
|
apobj.notify(body=body, title=title, notify_type=notify_type)
|
||||||
|
elif data['action'] == 'create':
|
||||||
|
title = data['data']['identifier'] + ' - ' + data['data']['title']
|
||||||
|
body = f"创建 issue。\n#Status\n{data['data']['state']['name']}"
|
||||||
|
notify_type = apprise.NotifyType.INFO
|
||||||
|
for label in data['data']['labels']:
|
||||||
|
if label['name'] == 'Bug':
|
||||||
|
notify_type = apprise.NotifyType.FAILURE
|
||||||
|
break
|
||||||
|
apobj.notify(body=body, title=title, notify_type=notify_type)
|
||||||
|
|
||||||
return jsonify({'message': 'Ok'}), 200
|
return jsonify({'message': 'Ok'}), 200
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user