mirror of https://github.com/zulip/zulip.git
push_notification: Push data from Zilencer.
This commit is contained in:
parent
ab411ab7b3
commit
c4e5b75ead
|
@ -79,4 +79,30 @@ def remote_server_notify_push(request, # type: HttpRequest
|
||||||
):
|
):
|
||||||
# type: (...) -> HttpResponse
|
# type: (...) -> HttpResponse
|
||||||
validate_entity(entity)
|
validate_entity(entity)
|
||||||
|
server = cast(RemoteZulipServer, entity)
|
||||||
|
|
||||||
|
user_id = payload['user_id']
|
||||||
|
gcm_payload = payload['gcm_payload']
|
||||||
|
apns_payload = payload['apns_payload']
|
||||||
|
|
||||||
|
android_devices = list(RemotePushDeviceToken.objects.filter(
|
||||||
|
user_id=user_id,
|
||||||
|
kind=RemotePushDeviceToken.GCM,
|
||||||
|
server=server
|
||||||
|
))
|
||||||
|
|
||||||
|
apple_devices = list(RemotePushDeviceToken.objects.filter(
|
||||||
|
user_id=user_id,
|
||||||
|
kind=RemotePushDeviceToken.APNS,
|
||||||
|
server=server
|
||||||
|
))
|
||||||
|
|
||||||
|
if android_devices:
|
||||||
|
send_android_push_notification(android_devices, gcm_payload)
|
||||||
|
|
||||||
|
# TODO: set badge count in a better way
|
||||||
|
if apple_devices:
|
||||||
|
send_apple_push_notification(user_id, apple_devices,
|
||||||
|
badge=1, zulip=apns_payload)
|
||||||
|
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
Loading…
Reference in New Issue