(self, request)
return HttpResponse(challenge)
Callback used by the Hub to verify the subscription request
Callback used by the Hub to verify the subscription request
Callback used by the Hub to verify the subscription request
def get(self, request):
        """Callback used by the Hub to verify the subscription request"""

        # received arguments: hub.mode, hub.topic, hub.challenge,
        # hub.lease_seconds, hub.verify_token
        mode = request.GET.get("hub.mode")
        feed_url = request.GET.get("hub.topic")
        challenge = request.GET.get("hub.challenge")
        lease_seconds = request.GET.get("hub.lease_seconds")
        verify_token = request.GET.get("hub.verify_token")

        logger.debug(
            (
                "received subscription-parameters: mode: %(mode)s, "
                + "topic: %(topic)s, challenge: %(challenge)s, lease_seconds: "
                + "%(lease_seconds)s, verify_token: %(verify_token)s"
            )
            % dict(
                mode=mode,
                topic=feed_url,
                challenge=challenge,
                lease_seconds=lease_seconds,
                verify_token=verify_token,
            )
        )

        try:
            subscription = HubSubscription.objects.get(topic_url=feed_url)

        except HubSubscription.DoesNotExist:
            logger.warning("subscription does not exist")
            return HttpResponseNotFound()

        if subscription.mode != mode:
            logger.warning("invalid mode, %s expected" % subscription.mode)
            return HttpResponseNotFound()

        if subscription.verify_token != verify_token:
            logger.warning(
                "invalid verify_token, %s expected" % subscription.verify_token
            )
            return HttpResponseNotFound()

        subscription.verified = True
        subscription.save()

        logger.info("subscription confirmed")
        return HttpResponse(challenge)
def get ( self , request ) : # received arguments: hub.mode, hub.topic, hub.challenge, # hub.lease_seconds, hub.verify_token mode = request . GET . get ( "hub.mode" ) feed_url = request . GET . get ( "hub.topic" ) challenge = request . GET . get ( "hub.challenge" ) lease_seconds = request . GET . get ( "hub.lease_seconds" ) verify_token = request . GET . get ( "hub.verify_token" ) logger . debug ( ( "received subscription-parameters: mode: %(mode)s, " + "topic: %(topic)s, challenge: %(challenge)s, lease_seconds: " + "%(lease_seconds)s, verify_token: %(verify_token)s" ) % dict ( mode = mode , topic = feed_url , challenge = challenge , lease_seconds = lease_seconds , verify_token = verify_token , ) ) try : subscription = HubSubscription . objects . get ( topic_url = feed_url ) except HubSubscription . DoesNotExist : logger . warning ( "subscription does not exist" ) return HttpResponseNotFound ( ) if subscription . mode != mode : logger . warning ( "invalid mode, %s expected" % subscription . mode ) return HttpResponseNotFound ( ) if subscription . verify_token != verify_token : logger . warning ( "invalid verify_token, %s expected" % subscription . verify_token ) return HttpResponseNotFound ( ) subscription . verified = True subscription . save ( ) logger . info ( "subscription confirmed" ) return HttpResponse ( challenge )