Esempio n. 1
0
        protected override void Check(TransitAccountMessage t_instance, ManagedSecurityContext sec)
        {
            base.Check(t_instance, sec);

            // existing instance doesn't need to be rechecked
            if (t_instance.Id != 0)
            {
                return;
            }

            // verified e-mail required
            sec.CheckVerified();

            // is the sender a friend of the receiver?
            int            sender_id = t_instance.GetOwner(Session, t_instance.SenderAccountId, sec).Id;
            ManagedAccount sender    = new ManagedAccount(Session, sender_id);

            if (sender.HasFriend(t_instance.RecepientAccountId))
            {
                return;
            }

            // how many messages within the last hour?
            new ManagedQuota(DefaultHourlyLimit).Check <AccountMessage, ManagedAccount.QuotaExceededException>(
                GetAcountMessages(Session, sender_id, DateTime.UtcNow.AddHours(-1)));
            // how many messages within the last 24 hours?
            ManagedQuota.GetDefaultEnabledQuota().Check <AccountMessage, ManagedAccount.QuotaExceededException>(
                GetAcountMessages(Session, sender_id, DateTime.UtcNow.AddDays(-1)));

            // check whether the sender was flagged
            new ManagedQuota(ManagedAccountFlag.DefaultAccountFlagThreshold).Check <AccountFlag, ManagedAccountFlag.AccountFlaggedException>(
                ManagedAccountFlag.GetAccountFlagsByFlaggedAccountId(Session, sender_id));
        }
Esempio n. 2
0
        protected override void Check(TransitMadLibInstance t_instance, ManagedSecurityContext sec)
        {
            base.Check(t_instance, sec);

            if (t_instance.Id != 0)
            {
                return;
            }

            sec.CheckVerified();

            // check whether the sender was flagged
            new ManagedQuota(ManagedAccountFlag.DefaultAccountFlagThreshold).Check <AccountFlag, ManagedAccountFlag.AccountFlaggedException>(
                ManagedAccountFlag.GetAccountFlagsByFlaggedAccountId(Session, sec.Account.Id));
        }
        protected override void Check(TransitAccountFriendRequest t_instance, ManagedSecurityContext sec)
        {
            base.Check(t_instance, sec);
            if (t_instance.Id == 0)
            {
                sec.CheckVerified();

                // check number of account friend requests
                GetQuota(sec).Check <AccountFriendRequest, ManagedAccount.QuotaExceededException>(
                    Session.CreateQuery(string.Format("SELECT COUNT(*) FROM AccountFriendRequest instance WHERE instance.Account.Id = {0}",
                                                      mInstance.Account.Id)).UniqueResult <int>());

                // check whether the sender was flagged
                new ManagedQuota(ManagedAccountFlag.DefaultAccountFlagThreshold).Check <AccountFlag, ManagedAccountFlag.AccountFlaggedException>(
                    ManagedAccountFlag.GetAccountFlagsByFlaggedAccountId(Session, sec.Account.Id));
            }
        }
        protected override void Check(TransitAccountGroupAccountRequest t_instance, ManagedSecurityContext sec)
        {
            base.Check(t_instance, sec);

            if (t_instance.Id == 0)
            {
                sec.CheckVerified();

                // check number of account friend requests
                GetQuota(sec).Check <AccountGroupAccountRequest, ManagedAccount.QuotaExceededException>(
                    mInstance.Account.AccountGroupAccountRequests);

                // check whether the sender was flagged
                new ManagedQuota(ManagedAccountFlag.DefaultAccountFlagThreshold).Check <AccountFlag, ManagedAccountFlag.AccountFlaggedException>(
                    ManagedAccountFlag.GetAccountFlagsByFlaggedAccountId(Session, sec.Account.Id));
            }
        }
Esempio n. 5
0
        protected override void Check(TransitDiscussionPost t_instance, ManagedSecurityContext sec)
        {
            base.Check(t_instance, sec);

            if (t_instance.Id != 0)
            {
                return;
            }

            sec.CheckVerified();

            int account_id = t_instance.GetOwner(Session, t_instance.AccountId, sec).Id;

            // how many posts within the last hour?
            new ManagedQuota(DefaultHourlyLimit).Check <DiscussionPost, ManagedAccount.QuotaExceededException>(
                GetDiscussionPosts(Session, account_id, DateTime.UtcNow.AddHours(-1)));
            // how many messages within the last 24 hours?
            ManagedQuota.GetDefaultEnabledQuota().Check <DiscussionPost, ManagedAccount.QuotaExceededException>(
                GetDiscussionPosts(Session, account_id, DateTime.UtcNow.AddDays(-1)));

            // check whether the sender was flagged
            new ManagedQuota(ManagedAccountFlag.DefaultAccountFlagThreshold).Check <AccountFlag, ManagedAccountFlag.AccountFlaggedException>(
                ManagedAccountFlag.GetAccountFlagsByFlaggedAccountId(Session, sec.Account.Id));
        }