[FIX] runbot: allow to manually hook by calling route

This commit is contained in:
Xavier-Do 2019-11-05 13:15:05 +01:00 committed by XavierDo
parent daea9018d3
commit 10799ba9d6

View File

@ -14,7 +14,7 @@ class RunbotHook(http.Controller):
@http.route(['/runbot/hook/<int:repo_id>', '/runbot/hook/org'], type='http', auth="public", website=True, csrf=False)
def hook(self, repo_id=None, **post):
event = request.httprequest.headers.get("X-Github-Event")
payload = json.loads(request.params['payload'])
payload = json.loads(request.params.get('payload', '{}'))
if repo_id is None:
repo_data = payload.get('repository')
if repo_data and event in ['push', 'pull_request']:
@ -30,7 +30,7 @@ class RunbotHook(http.Controller):
repo = request.env['runbot.repo'].sudo().browse([repo_id])
# force update of dependencies to in case a hook is lost
if event == 'push' or (event == 'pull_request' and payload.get('action') in ('synchronize', 'opened', 'reopened')):
if not payload or event == 'push' or (event == 'pull_request' and payload.get('action') in ('synchronize', 'opened', 'reopened')):
(repo | repo.dependency_ids).write({'hook_time': time.time()})
else:
_logger.debug('Ignoring unsupported hook %s %s', event, payload.get('action', ''))