Пример #1
0
    def update_users(self, spam_protection=False, reprocess_username=None):
        """
            Process new profile updates from the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.updates.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                continue

            # for spam protection
            if check_banned_email(user['email']):
                if spam_protection:
                    log.debug("Deleting spam: %s, %s" %
                              (user['email'], user['username']))
                    self.updates.remove({"user_id": new_user['user_id']})
                else:
                    log.debug("Need to delete %s, %s" %
                              (user['email'], user['username']))
                continue

            # mode for reprocessing a single user, ignore others
            if reprocess_username is not None:
                if user['username'] != reprocess_username:
                    #log.debug("Ignoring: %s" % user['username'])
                    continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            btc_address = nmc_to_btc_address(user['namecoin_address'])

            data_value = convert_profile_format(user)

            encrypted_privkey = new_user['encrypted_private_key']
            hex_privkey = bip38_decrypt(str(encrypted_privkey), WALLET_SECRET)

            if nameRegistered(fqu):

                if profilePublished(fqu, data_value):
                    log.debug("Profile match, removing: %s" % fqu)
                    self.updates.remove({"user_id": new_user['user_id']})

                    refresh_resolver(user['username'])
                else:
                    log.debug("Processing: %s, %s" % (fqu, user['email']))
                    try:
                        self.registrar_server.process_subsidized_nameop(
                            fqu,
                            owner_privkey=hex_privkey,
                            profile=data_value,
                            nameop='update')
                    except Exception as e:
                        log.debug(e)
            else:

                log.debug("Not registered: %s" % fqu)
Пример #2
0
    def validUser(self, user, new_user):
        """
            Check if the given @user should be processed or ignored

            Returns True or False
        """

        if user is None:
            log.debug("No such user, need to remove: %s" % new_user)
            #self.registrations.remove({'_id': new_user['_id']})
            return False

        # for spam protection
        if check_banned_email(user['email']):
            log.debug("SPAM: Need to delete %s, %s" %
                      (user['email'], user['username']))
            #self.remove_registration_entry(user['username'])
            return False

        # test for minimum name length
        if len(user['username']) < MINIMUM_LENGTH_NAME:
            log.debug("Expensive name %s. Skipping." % user['username'])
            return False

        # test for ignoring names starting with certain patterns
        if ignoreRegistration(user['username'], IGNORE_NAMES_STARTING_WITH):
            log.debug("Ignoring: %s" % user['username'])
            return False

        if not validRegistrationEmail(user['email'], self.email_list):
            log.debug("Email rejected by filter: %s" % user['email'])
            #self.remove_registration_entry(user['username'])
            return True

        return True
Пример #3
0
    def validUser(self, user, new_user):
        """
            Check if the given @user should be processed or ignored

            Returns True or False
        """

        if user is None:
            log.debug("No such user, need to remove: %s" % new_user['_id'])
            #self.registrations.remove({'_id': user['_id']})
            return False

        # for spam protection
        if check_banned_email(user['email']):
            log.debug("SPAM: Need to delete %s, %s" % (user['email'], user['username']))
            return False

        # test for minimum name length
        if len(user['username']) < MINIMUM_LENGTH_NAME:
            log.debug("Expensive name %s. Skipping." % user['username'])
            return False

        # test for ignoring names starting with certain patterns
        if ignoreRegistration(user['username'], IGNORE_NAMES_STARTING_WITH):
            log.debug("Ignoring: %s" % user['username'])
            return False

        return True
Пример #4
0
    def process_new_users(self, nameop=None, spam_protection=False):
        """
            Process new registrations coming in on the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                log.debug("No such user, need to remove: %s" % new_user['_id'])
                self.registrations.remove({'_id': new_user['_id']})
                continue

            # for spam protection
            if check_banned_email(user['email']):

                if spam_protection:
                    log.debug("Deleting spam %s, %s" %
                              (user['email'], user['username']))
                    self.users.remove({"email": user['email']})
                else:
                    log.debug("Need to delete %s, %s" %
                              (user['email'], user['username']))
                continue

            # test for minimum name length
            if len(user['username']) < MINIMUM_LENGTH_NAME:
                log.debug("Expensive name %s. Skipping." % user['username'])
                continue

            # test for ignoring names starting with certain patterns
            if ignoreRegistration(user['username'],
                                  IGNORE_NAMES_STARTING_WITH):
                log.debug("Ignoring: %s" % user['username'])
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']

            log.debug("Processing: %s" % fqu)

            if registrationComplete(fqu, profile, transfer_address):
                log.debug("Registration complete %s. Removing." % fqu)
                self.registrations.remove({"user_id": new_user['user_id']})

                refresh_resolver(user['username'])
            else:
                try:
                    self.registrar_server.process_nameop(fqu,
                                                         profile,
                                                         transfer_address,
                                                         nameop=nameop)
                except Exception as e:
                    log.debug(e)
    def update_users(self, spam_protection=False, reprocess_username=None):
        """
            Process new profile updates from the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.updates.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                continue

            # for spam protection
            if check_banned_email(user['email']):
                if spam_protection:
                    log.debug("Deleting spam: %s, %s" % (user['email'], user['username']))
                    self.updates.remove({"user_id": new_user['user_id']})
                else:
                    log.debug("Need to delete %s, %s" % (user['email'], user['username']))
                continue

            # mode for reprocessing a single user, ignore others
            if reprocess_username is not None:
                if user['username'] != reprocess_username:
                    #log.debug("Ignoring: %s" % user['username'])
                    continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            btc_address = nmc_to_btc_address(user['namecoin_address'])

            data_value = convert_profile_format(user)

            encrypted_privkey = new_user['encrypted_private_key']
            hex_privkey = bip38_decrypt(str(encrypted_privkey), WALLET_SECRET)

            if nameRegistered(fqu):

                if profilePublished(fqu, data_value):
                    log.debug("Profile match, removing: %s" % fqu)
                    self.updates.remove({"user_id": new_user['user_id']})

                    refresh_resolver(user['username'])
                else:
                    log.debug("Processing: %s, %s" % (fqu, user['email']))
                    try:
                        self.registrar_server.process_subsidized_nameop(fqu,
                                                                owner_privkey=hex_privkey,
                                                                profile=data_value,
                                                                nameop='update')
                    except Exception as e:
                        log.debug(e)
            else:

                log.debug("Not registered: %s" % fqu)
Пример #6
0
    def process_new_users(self, nameop=None, spam_protection=False):
        """
            Process new registrations coming in on the webapp
        """

        counter = 0
        self.registrar_server.reset_flag()

        for new_user in self.registrations.find(no_cursor_timeout=True):

            user = get_db_user_from_id(new_user, self.users)

            if user is None:
                log.debug("No such user, need to remove: %s" % new_user['_id'])
                self.registrations.remove({'_id': new_user['_id']})
                continue

            # for spam protection
            if check_banned_email(user['email']):

                if spam_protection:
                    log.debug("Deleting spam %s, %s" % (user['email'], user['username']))
                    self.users.remove({"email": user['email']})
                else:
                    log.debug("Need to delete %s, %s" % (user['email'], user['username']))
                continue

            # test for minimum name length
            if len(user['username']) < MINIMUM_LENGTH_NAME:
                log.debug("Expensive name %s. Skipping." % user['username'])
                continue

            # test for ignoring names starting with certain patterns
            if ignoreRegistration(user['username'], IGNORE_NAMES_STARTING_WITH):
                log.debug("Ignoring: %s" % user['username'])
                continue

            fqu = user['username'] + "." + DEFAULT_NAMESPACE
            transfer_address = nmc_to_btc_address(user['namecoin_address'])
            profile = user['profile']

            log.debug("Processing: %s" % fqu)

            if registrationComplete(fqu, profile, transfer_address):
                log.debug("Registration complete %s. Removing." % fqu)
                self.registrations.remove({"user_id": new_user['user_id']})

                refresh_resolver(user['username'])
            else:
                try:
                    self.registrar_server.process_nameop(fqu, profile,
                                                         transfer_address,
                                                         nameop=nameop)
                except Exception as e:
                    log.debug(e)