From 10b4e91caa38b97c6b3b54a4ccc0a06f069418d8 Mon Sep 17 00:00:00 2001 From: Zachary Orr Date: Fri, 3 May 2019 15:16:21 -0400 Subject: [PATCH] Small changes --- firebase_admin/_messaging_utils.py | 2 +- firebase_admin/messaging.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/firebase_admin/_messaging_utils.py b/firebase_admin/_messaging_utils.py index 63623e33e..373adf68c 100644 --- a/firebase_admin/_messaging_utils.py +++ b/firebase_admin/_messaging_utils.py @@ -72,7 +72,7 @@ class MulticastMessage(object): def __init__(self, tokens, data=None, notification=None, android=None, webpush=None, apns=None): _Validators.check_string_list('MulticastMessage.tokens', tokens) if len(tokens) > 100: - raise ValueError('MulticastMessage.tokens must contain less than 100 tokens.') + raise ValueError('MulticastMessage.tokens must not contain more than 100 tokens.') self.tokens = tokens self.data = data self.notification = notification diff --git a/firebase_admin/messaging.py b/firebase_admin/messaging.py index a488539a0..facda605d 100644 --- a/firebase_admin/messaging.py +++ b/firebase_admin/messaging.py @@ -100,7 +100,7 @@ def send(message, dry_run=False, app=None): return _get_messaging_service(app).send(message, dry_run) def send_all(messages, dry_run=False, app=None): - """Batch sends the given messages via Firebase Cloud Messaging (FCM). + """Sends the given list of messages via Firebase Cloud Messaging as a single batch. If the ``dry_run`` mode is enabled, the message will not be actually delivered to the recipients. Instead FCM performs all the usual validations, and emulates the send operation. @@ -258,10 +258,7 @@ class BatchResponse(object): def __init__(self, responses): self._responses = responses - self._success_count = 0 - for response in responses: - if response.success: - self._success_count += 1 + self._success_count = len([resp for resp in responses if resp.success]) @property def responses(self): @@ -455,7 +452,7 @@ def _message_data(self, message, dry_run): def _postproc(self, resp, body): if resp.status == 200: - return json.loads(body) + return json.loads(body.decode()) else: raise Exception('unexpected response')