add handler for installation trigger

This commit is contained in:
zhangxunhui 2021-08-21 08:59:28 +08:00
parent bb2d2cfe26
commit 61c2936c13
2 changed files with 3 additions and 4 deletions

View File

@ -24,7 +24,7 @@ def application(environ, start_response) -> bytearray:
trigger: Trigger = parseTriggers(json_dict)
# only when the trigger is open pull request can return the result
if type(trigger) == PRTrigger and trigger.action == "opened":
if trigger is not None and type(trigger) == PRTrigger and trigger.action == "opened":
return_pr_decision(trigger)
return ["success".encode('utf-8')]

View File

@ -13,10 +13,9 @@ from app.db.operators.pull_request_operator import PullRequestOperator
from typing import Dict
def parseTriggers(response: Dict) -> Trigger:
'''
the trigger will also be touched when install the app, we need to handle the exception
'''
try:
if 'reponsitory' not in response or "installation" not in response:
return None # this is not a right trigger, e.g., the trigger will also be touched when install the app
repo = Repository(name=response['repository']['name'])
owner = User(login=response['repository']['full_name'].split("/")[0])
sender = User(login=response['sender']['login'])