Verified Commit 193d7465 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

GitLab: Add issue integration

parent 1cbe447f
import asyncio
from emily.core import push_event, merge_event, pipe_event
from emily.core import (push_event, merge_event, pipe_event,
issue_open_event, issue_close_event)
from emily.protocols.http import http_handle, HTTPProtocol
SKIP_PIPE = ('pending', 'running',)
......@@ -70,5 +71,25 @@ class GitLab:
request.match_info.get('project')
yield from pipe_event.call_async(project, pipe_info)
elif json['object_kind'] == 'issue':
attrs = json['object_attributes']
action = attrs.get('action', 'open')
if action in ('open', 'reopen'):
event = issue_open_event
elif action == 'close':
event = issue_close_event
else:
return True # Silently ignore 'update' events.
issue_info = {}
issue_info['user'] = {'name': json.get('user', {}).get('name', '')}
# Not a typo: 'iid' is the Issue ID, while 'id' is the project object ID
issue_info['id'] = str(attrs.get('iid'))
issue_info['title'] = attrs.get('title', 'Missing title')
issue_info['url'] = attrs.get('url')
project = request.match_info.get('grp', 'default') + '/' + \
request.match_info.get('project')
yield from event.call_async(project, issue_info)
else:
return False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment