Пример #1
0
        public bool IsSpam(SpamShield command)
        {
            if (command.Tick.IsNullOrWhitespace() || command.Hash.IsNullOrWhitespace())
            {
                return(true);
            }

            var spamHash = _spamCol.AsQueryable().FirstOrDefault(w => w.Id == command.Tick);

            if (spamHash == null || spamHash.Pass || spamHash.Hash != command.Hash)
            {
                return(true);
            }

            spamHash.Pass = true;
            _spamCol.Save(spamHash);
            return(false);
        }
Пример #2
0
        public bool IsSpam(SpamShield command)
        {
            if (command.Tick.IsNullOrWhitespace() || command.Hash.IsNullOrWhitespace())
            {
                return(true);
            }

            var spamHash = _db.SelectKey <SpamHash>(DBTableNames.SpamHashes, command.Tick);

            if (spamHash == null || spamHash.Pass || spamHash.Hash != command.Hash)
            {
                return(true);
            }

            spamHash.Pass = true;
            _db.Update(DBTableNames.SpamHashes, spamHash);
            return(false);
        }
Пример #3
0
        public bool IsSpam(SpamShield command)
        {
            using (var db = new LiteDatabase(_dbConfig.DbPath))
            {
                if (command.Tick.IsNullOrWhitespace() || command.Hash.IsNullOrWhitespace())
                {
                    return(true);
                }

                var cols  = db.GetCollection <SpamHash>(DBTableNames.SpamHashes);
                var entry = cols.FindOne(x => x.Id == command.Tick);

                if (entry == null || entry.Pass || entry.Hash != command.Hash)
                {
                    return(true);
                }

                entry.Pass = true;
                cols.Update(entry);
                return(false);
            }
        }
Пример #4
0
        public bool IsSpam(SpamShield command)
        {
            if (command.Tick.IsNullOrWhitespace() || command.Hash.IsNullOrWhitespace())
                return true;

            var spamHash = _db.SelectKey<SpamHash>(DBTableNames.SpamHashes, command.Tick);

            if (spamHash == null || spamHash.Pass || spamHash.Hash != command.Hash)
                return true;

            spamHash.Pass = true;
            _db.Update(DBTableNames.SpamHashes, spamHash);
            return false;
        }
Пример #5
0
        public bool IsSpam(SpamShield command)
        {
            using (var _db = new LiteDatabase(_dbConfig.DbPath))
            {
                if (command.Tick.IsNullOrWhitespace() || command.Hash.IsNullOrWhitespace())
                    return true;

                var spamHashCol = _db.GetCollection<SpamHash>(DBTableNames.SpamHashes);
                var spamHash = spamHashCol.FindOne(x => x.PostKey == command.Tick);

                if (spamHash == null || spamHash.Pass || spamHash.Hash != command.Hash)
                    return true;

                spamHash.Pass = true;
                spamHashCol.Update(spamHash);
                return false;
            }
        }