support "event category" for github so we can e.g. show only approvals
This commit is contained in:
parent
96d175bc31
commit
1d777f88b3
2 changed files with 22 additions and 5 deletions
|
@ -111,10 +111,23 @@ class GitHub(object):
|
||||||
|
|
||||||
def event(self, data, headers):
|
def event(self, data, headers):
|
||||||
event = headers["X-GitHub-Event"]
|
event = headers["X-GitHub-Event"]
|
||||||
|
action = None
|
||||||
event_action = None
|
event_action = None
|
||||||
if "action" in data:
|
if "action" in data:
|
||||||
event_action = "%s/%s" % (event, data["action"])
|
action = data["action"]
|
||||||
return [event]+([event_action] if event_action else [])
|
|
||||||
|
category = None
|
||||||
|
category_action = None
|
||||||
|
if "review" in data and "state" in data["review"]:
|
||||||
|
category = "%s+%s" % (event, data["review"]["state"])
|
||||||
|
|
||||||
|
if action:
|
||||||
|
if category:
|
||||||
|
category_action = "%s/%s" % (category, action)
|
||||||
|
event_action = "%s/%s" % (event, action)
|
||||||
|
|
||||||
|
return [event]+list(filter(None,
|
||||||
|
[event_action, category, category_action]))
|
||||||
|
|
||||||
def event_categories(self, event):
|
def event_categories(self, event):
|
||||||
return EVENT_CATEGORIES.get(event, [event])
|
return EVENT_CATEGORIES.get(event, [event])
|
||||||
|
|
|
@ -74,6 +74,7 @@ class GitLab(object):
|
||||||
event = headers["X-GitLab-Event"].rsplit(" ", 1)[0].lower()
|
event = headers["X-GitLab-Event"].rsplit(" ", 1)[0].lower()
|
||||||
|
|
||||||
event = event.replace(" ", "_")
|
event = event.replace(" ", "_")
|
||||||
|
action = None
|
||||||
event_action = None
|
event_action = None
|
||||||
|
|
||||||
category = None
|
category = None
|
||||||
|
@ -81,12 +82,15 @@ class GitLab(object):
|
||||||
|
|
||||||
if "object_attributes" in data:
|
if "object_attributes" in data:
|
||||||
if "action" in data["object_attributes"]:
|
if "action" in data["object_attributes"]:
|
||||||
event_action = "%s/%s" % (
|
action = data["object_attributes"]["action"]
|
||||||
event, data["object_attributes"]["action"])
|
|
||||||
if "noteable_type" in data["object_attributes"]:
|
if "noteable_type" in data["object_attributes"]:
|
||||||
category = data["object_attributes"]["noteable_type"].lower()
|
category = data["object_attributes"]["noteable_type"].lower()
|
||||||
category = "%s+%s" % (event, category)
|
category = "%s+%s" % (event, category)
|
||||||
category_action = "%s/%s" % (category, event_action)
|
|
||||||
|
if action:
|
||||||
|
if category:
|
||||||
|
category_action = "%s/%s" % (category, action)
|
||||||
|
event_action = "%s/%s" % (event, action)
|
||||||
|
|
||||||
return [event]+list(filter(None,
|
return [event]+list(filter(None,
|
||||||
[event_action, category, category_action]))
|
[event_action, category, category_action]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue