예제 #1
0
        /// <summary>
        /// Checks if they are black listed or have submitted more than 20 locations in 5 minutes
        /// </summary>
        private bool IsSpam(string userHostAddress, string userAgent)
        {
            if (_mongoService.IsBlacklisted(userHostAddress, userAgent, 60))
            {
                return(true);
            }

            var records = _mongoService.GetRecentSightingsCountByIP(userAgent, userHostAddress, 5);

            if (records >= 20)
            {
                _mongoService.AddUserRequestData(new UserRequestObject()
                {
                    Timestamp = DateTime.UtcNow,
                    IpAddress = userHostAddress,
                    UserAgent = userAgent
                });
                _mongoService.DeleteRecentLocationsByIp(userHostAddress, userAgent, 6);
                return(true);
            }

            return(false);
        }