Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions github_webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import json
import six
from flask import abort, request
from quart import abort, request


class Webhook(object):
Expand Down Expand Up @@ -56,9 +56,9 @@ def decorator(func):
def _get_digest(self):
"""Return message digest if a secret key was provided"""

return hmac.new(self._secret, request.data, hashlib.sha1).hexdigest() if self._secret else None
return hmac.new(self._secret, request.get_data(), hashlib.sha1).hexdigest() if self._secret else None

def _postreceive(self):
async def _postreceive(self):
"""Callback from Flask"""

digest = self._get_digest()
Expand All @@ -73,8 +73,9 @@ def _postreceive(self):

event_type = _get_header("X-Github-Event")
content_type = _get_header("content-type")
form_data = await request.form
data = (
json.loads(request.form.to_dict(flat=True)["payload"])
json.loads(form_data.to_dict(flat=True)["payload"])
if content_type == "application/x-www-form-urlencoded"
else request.get_json()
)
Expand All @@ -85,7 +86,7 @@ def _postreceive(self):
self._logger.info("%s (%s)", _format_event(event_type, data), _get_header("X-Github-Delivery"))

for hook in self._hooks.get(event_type, []):
hook(data)
await hook(data)

return "", 204

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

setup(
name="github-webhook",
version="1.0.4",
version="1.0.5",
description="Very simple, but powerful, microframework for writing Github webhooks in Python",
url="https://github.com/bloomberg/python-github-webhook",
author="Alex Chamberlain, Fred Phillips, Daniel Kiss, Daniel Beer",
author_email="[email protected], [email protected], [email protected], [email protected]",
license="Apache 2.0",
packages=["github_webhook"],
install_requires=["flask", "six"],
install_requires=["quart", "six"],
tests_require=["mock", "pytest"],
classifiers=[
"Development Status :: 4 - Beta",
Expand Down