Skip to content

Commit

Permalink
fix broadcast for device_type_android and fcm (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkstnr authored Mar 25, 2020
1 parent cc05732 commit 68090af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

@route(r"/api/v2/broadcast[\/]?")
class BroadcastHandler(APIBaseHandler):
def post(self):
async def post(self):
if not self.can("send_broadcast"):
self.send_response(FORBIDDEN, dict(error="No permission to send broadcast"))
return
Expand All @@ -70,7 +70,7 @@ def post(self):
alert["title"] + ": " + alert["body"],
"important",
)
self.application.send_broadcast(
await self.application.send_broadcast(
self.appname,
self.db,
channel=channel,
Expand Down
6 changes: 3 additions & 3 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_broadcast_status(self, appname):

return {"msg": status, "error": error}

def send_broadcast(self, appname, appdb, **kwargs):
async def send_broadcast(self, appname, appdb, **kwargs):
channel = kwargs.get("channel", "default")
alert = kwargs.get("alert", None)
sound = kwargs.get("sound", None)
Expand Down Expand Up @@ -117,8 +117,8 @@ def send_broadcast(self, appname, appdb, **kwargs):
extra=extra,
apns=kwargs.get("apns", {}),
)
elif token["device"] == DEVICE_TYPE_FCM:
fcm.process(
elif token["device"] == DEVICE_TYPE_FCM or token["device"] == DEVICE_TYPE_ANDROID:
await fcm.process(
token=t, alert=alert, extra=extra, fcm=kwargs.get("fcm", {})
)
elif token["device"] == DEVICE_TYPE_WNS:
Expand Down

0 comments on commit 68090af

Please sign in to comment.