Beispiel #1
0
    def process_response(self, request, response):
        if (
            (
                request.path == "/"
                or request.path.startswith("/reader/refresh_feeds")
                or request.path.startswith("/reader/load_feeds")
                or request.path.startswith("/reader/feeds")
            )
            and hasattr(request, "user")
            and request.user.is_authenticated()
        ):
            hour_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes=60)
            ip = request.META.get("HTTP_X_FORWARDED_FOR", None) or request.META["REMOTE_ADDR"]
            # SUBSCRIBER_EXPIRE = datetime.datetime.utcnow() - datetime.timedelta(days=settings.SUBSCRIBER_EXPIRE)
            if request.user.profile.last_seen_on < hour_ago:
                logging.user(request, "~FG~BBRepeat visitor: ~SB%s (%s)" % (request.user.profile.last_seen_on, ip))
                CleanupUser.delay(user_id=request.user.pk)
            elif settings.DEBUG:
                logging.user(
                    request, "~FG~BBRepeat visitor (ignored): ~SB%s (%s)" % (request.user.profile.last_seen_on, ip)
                )

            request.user.profile.last_seen_on = datetime.datetime.utcnow()
            request.user.profile.last_seen_ip = ip[-15:]
            request.user.profile.save()

        return response
Beispiel #2
0
    def process_response(self, request, response):
        if ((request.path == '/' or
             request.path.startswith('/reader/refresh_feeds') or
             request.path.startswith('/reader/load_feeds') or
             request.path.startswith('/reader/feeds'))
            and hasattr(request, 'user')
            and request.user.is_authenticated()): 
            hour_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes=60)
            ip = request.META.get('HTTP_X_REAL_IP', None) or request.META['REMOTE_ADDR']
            # SUBSCRIBER_EXPIRE = datetime.datetime.utcnow() - datetime.timedelta(days=settings.SUBSCRIBER_EXPIRE)
            if request.user.profile.last_seen_on < hour_ago:
                logging.user(request, "~FG~BBRepeat visitor: ~SB%s (%s)" % (
                    request.user.profile.last_seen_on, ip))
                CleanupUser.delay(user_id=request.user.pk)
            elif settings.DEBUG:
                logging.user(request, "~FG~BBRepeat visitor (ignored): ~SB%s (%s)" % (
                    request.user.profile.last_seen_on, ip))

            # if request.user.profile.last_seen_on < SUBSCRIBER_EXPIRE:
                # request.user.profile.refresh_stale_feeds()
            request.user.profile.last_seen_on = datetime.datetime.utcnow()
            request.user.profile.last_seen_ip = ip
            request.user.profile.save()
        
        return response
Beispiel #3
0
    def process_response(self, request, response):
        if ((request.path == '/'
             or request.path.startswith('/reader/refresh_feeds')
             or request.path.startswith('/reader/load_feeds'))
                and hasattr(request, 'user')
                and request.user.is_authenticated()):
            hour_ago = datetime.datetime.utcnow() - datetime.timedelta(
                minutes=60)
            ip = request.META.get('HTTP_X_REAL_IP',
                                  None) or request.META['REMOTE_ADDR']
            # SUBSCRIBER_EXPIRE = datetime.datetime.utcnow() - datetime.timedelta(days=settings.SUBSCRIBER_EXPIRE)
            if request.user.profile.last_seen_on < hour_ago:
                logging.user(
                    request, "~FG~BBRepeat visitor: ~SB%s (%s)" %
                    (request.user.profile.last_seen_on, ip))
                CleanupUser.delay(user_id=request.user.pk)
            elif settings.DEBUG:
                logging.user(
                    request, "~FG~BBRepeat visitor (ignored): ~SB%s (%s)" %
                    (request.user.profile.last_seen_on, ip))

            # if request.user.profile.last_seen_on < SUBSCRIBER_EXPIRE:
            # request.user.profile.refresh_stale_feeds()
            request.user.profile.last_seen_on = datetime.datetime.utcnow()
            request.user.profile.last_seen_ip = ip
            request.user.profile.save()

        return response
Beispiel #4
0
    def process_response(self, request, response):
        if ((request.path == '/'
             or request.path.startswith('/reader/refresh_feeds')
             or request.path.startswith('/reader/load_feeds')
             or request.path.startswith('/reader/feeds'))
                and hasattr(request, 'user')
                and request.user.is_authenticated):
            hour_ago = datetime.datetime.utcnow() - datetime.timedelta(
                minutes=60)
            ip = request.META.get('HTTP_X_FORWARDED_FOR',
                                  None) or request.META['REMOTE_ADDR']
            if request.user.profile.last_seen_on < hour_ago:
                logging.user(
                    request, "~FG~BBRepeat visitor: ~SB%s (%s)" %
                    (request.user.profile.last_seen_on, ip))
                from apps.profile.tasks import CleanupUser

                CleanupUser.delay(user_id=request.user.pk)
            elif settings.DEBUG:
                logging.user(
                    request,
                    "~FG~BBRepeat visitor (ignored): ~SB%s (%s)" %
                    (request.user.profile.last_seen_on, ip),
                )

            request.user.profile.last_seen_on = datetime.datetime.utcnow()
            request.user.profile.last_seen_ip = ip[-15:]
            request.user.profile.save()

        return response