only add peers with new id

This commit is contained in:
j 2015-11-29 15:56:25 +01:00
parent a44aba7b7d
commit 8756e51090

View file

@ -14,7 +14,7 @@ import settings
import state import state
import logging import logging
logger = logging.getLogger('oml.changelog') logger = logging.getLogger(__name__)
class Changelog(db.Model): class Changelog(db.Model):
''' '''
@ -242,16 +242,17 @@ class Changelog(db.Model):
return True return True
def action_addpeer(self, user, timestamp, peerid, username): def action_addpeer(self, user, timestamp, peerid, username):
from user.models import User if len(peerid) == 16:
if not 'users' in user.info: from user.models import User
user.info['users'] = {} if not 'users' in user.info:
user.info['users'][peerid] = username user.info['users'] = {}
user.save() user.info['users'][peerid] = username
peer = User.get_or_create(peerid) user.save()
if not 'username' in peer.info: peer = User.get_or_create(peerid)
peer.info['username'] = username if not 'username' in peer.info:
peer.update_name() peer.info['username'] = username
peer.save() peer.update_name()
peer.save()
return True return True
def action_removepeer(self, user, timestamp, peerid): def action_removepeer(self, user, timestamp, peerid):