Beispiel #1
0
    def post(self, request):
        app = request.META['app']
        user = request.user.username
        channel = app.name
        count = get_subscriber_count(channel)
        try:
            body = json.loads(request.body)
            message = body["message"]
        except Exception:
            # body is probably urlencoded
            try:
                message = request.POST['message']
            except Exception:
                return Response("Invalid request. Check request format",
                                status=status.HTTP_400_BAD_REQUEST)

        push_to_channel(channel, message)
        notification = PushNotification(app=app, num_subscribers=count)
        notification.save()
        return Response({"result": count})
Beispiel #2
0
    def post(self, request):
        app = request.META['app']
        user = request.user.username
        channel = app.name
        count = get_subscriber_count(channel)
        try:
            body = json.loads(request.body)
            message = body["message"]
        except Exception:
            # body is probably urlencoded
            try:
                message = request.POST['message']
            except Exception:
                return Response("Invalid request. Check request format",
                                status=status.HTTP_400_BAD_REQUEST)

        push_to_channel(channel, message)
        notification = PushNotification(app=app, num_subscribers=count)
        notification.save()
        return Response({"result": count})
Beispiel #3
0
 def get(self, request):
     app = request.META['app']
     channel = app.name
     count = get_subscriber_count(channel)
     return Response({"result": count})
Beispiel #4
0
 def get(self, request):
     app = request.META['app']
     channel = app.name
     count = get_subscriber_count(channel)
     return Response({"result": count})