Skip to content

Commit

Permalink
Merge pull request #16 from zeroae/bug-15-compact-json
Browse files Browse the repository at this point in the history
Encode Smee body content with compat json settings
  • Loading branch information
sodre authored May 1, 2020
2 parents 711fb5f + d87a816 commit 0ed206a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions zeroae/smee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# ------------------------------------------------------------------------------

"""Webhook data delivery client. Please visit https://smee.io for more information."""
import json
import logging
from dataclasses import dataclass

Expand Down Expand Up @@ -52,11 +53,11 @@ def on_ready(self, event):

def on_message(self, event: event_stream.Event):
smee_event = event.json()
body = smee_event.pop("body")
body = json.dumps(smee_event.pop("body"), separators=(",", ":"))
_ = smee_event.pop("query")
_ = smee_event.pop("timestamp")
try:
requests.post(self.target, json=body, headers=smee_event)
requests.post(self.target, data=body, headers=smee_event)
except requests.exceptions.ConnectionError:
logger.warning(
f"Event {event.id} was not delivered. Target did not respond."
Expand Down

0 comments on commit 0ed206a

Please sign in to comment.