Skip to content

Commit

Permalink
Update for latest Sendgrid webhook format
Browse files Browse the repository at this point in the history
  • Loading branch information
paltman committed Aug 17, 2014
1 parent 3532601 commit 6ea9d0c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions sendgrid_events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ class Event(models.Model):
@classmethod
def process_batch(cls, data):
events = []
for line in data.split("\r\n"):
if line:
d = json.loads(line.strip())
events.append(Event.objects.create(
kind=d["event"],
email=d["email"],
data=d
))
for event in json.loads(data):
events.append(Event.objects.create(
kind=event["event"],
email=event["email"],
data=event
))
batch_processed.send(sender=Event, events=events)
return events

0 comments on commit 6ea9d0c

Please sign in to comment.