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 not self.validUser(user, new_user): 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: log.debug(traceback.print_exc())
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)
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 not self.validUser(user, new_user): 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 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 transfer_users(self, spam_protection=False, reprocess_username=None): """ Process new transfer from the webapp """ counter = 0 self.registrar_server.reset_flag() for new_user in self.exports.find(no_cursor_timeout=True): user = get_db_user_from_id(new_user, self.users) if user is None: continue # add spam protection here # mode for reprocessing a single user, ignore others if reprocess_username is not None: if user['username'] != reprocess_username: continue fqu = user['username'] + "." + DEFAULT_NAMESPACE transfer_address = new_user['recipient_address'] try: encrypted_privkey = new_user['encrypted_private_key'] hex_privkey = bip38_decrypt(str(encrypted_privkey), WALLET_SECRET) except: log.debug("no private key") #self.exports.remove({"user_id": new_user['user_id']}) else: log.debug("To export: %s to %s" % (fqu, transfer_address)) if nameRegistered(fqu): if ownerName(fqu, transfer_address): log.debug("Name transferred, removing: %s" % fqu) self.exports.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, transfer_address=transfer_address, nameop='transfer', profile="") #except Exception as e: # log.debug(e) else: log.debug("Not registered: %s" % fqu)
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)
def transfer_users(self, spam_protection=False, reprocess_username=None): """ Process new transfer from the webapp """ counter = 0 self.registrar_server.reset_flag() for new_user in self.exports.find(no_cursor_timeout=True): user = get_db_user_from_id(new_user, self.users) if user is None: continue # add spam protection here # mode for reprocessing a single user, ignore others if reprocess_username is not None: if user['username'] != reprocess_username: continue fqu = user['username'] + "." + DEFAULT_NAMESPACE transfer_address = new_user['recipient_address'] try: encrypted_privkey = new_user['encrypted_private_key'] hex_privkey = bip38_decrypt(str(encrypted_privkey), WALLET_SECRET) except: log.debug("no private key") #self.exports.remove({"user_id": new_user['user_id']}) else: log.debug("To export: %s to %s" % (fqu, transfer_address)) if nameRegistered(fqu): if ownerName(fqu, transfer_address): log.debug("Name transferred, removing: %s" % fqu) self.exports.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, transfer_address=transfer_address, nameop='transfer', profile="") #except Exception as e: # log.debug(e) else: log.debug("Not registered: %s" % fqu)
def process_new_users(self, nameop=None, spam_protection=False, live_delete=False): """ Process new registrations coming in on the webapp """ counter = 0 self.registrar_server.reset_flag() self.populate_email_list() for new_user in self.registrations.find(no_cursor_timeout=True): user = get_db_user_from_id(new_user, self.users) if not self.validUser(user, new_user): live_delete = False if live_delete: log.debug("Removing %s" % user['username']) self.registrations.remove({"user_id": new_user['user_id']}) continue if whiteListedUser(user['email'], user['profile']): log.debug("White-listed: %s" % user['email']) else: log.debug("Not registering: %s" % user['email']) #continue fqu = user['username'] + "." + DEFAULT_NAMESPACE transfer_address = nmc_to_btc_address(user['namecoin_address']) data_value = convert_profile_format(user) log.debug("Processing: %s" % fqu) if registrationComplete(fqu, data_value, 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, data_value, transfer_address, nameop=nameop) except: log.debug(traceback.print_exc())