dont add local peers to db, just show them in user dialog

This commit is contained in:
j 2015-11-29 16:39:26 +01:00
parent eeae402218
commit 444c357e54
2 changed files with 15 additions and 6 deletions

View File

@ -141,12 +141,13 @@ class LocalNodesBase(Thread):
if can_connect(data):
self._nodes[data['id']] = data
with db.session():
u = user.models.User.get_or_create(data['id'])
u.info['username'] = data['username']
u.info['local'] = data
u.update_name()
u.save()
state.nodes.queue('add', u.id)
u = user.models.User.get(data['id'])
if u:
u.info['username'] = data['username']
u.info['local'] = data
u.update_name()
u.save()
state.nodes.queue('add', u.id)
self.send()
def get_ip(self):

View File

@ -83,8 +83,16 @@ def getUsers(data):
}
'''
users = []
ids = set()
for u in models.User.query.filter(models.User.id!=settings.USER_ID).all():
users.append(u.json())
ids.add(u.id)
for id in state.nodes._local._nodes:
if id not in ids:
n = state.nodes._local._nodes[id].copy()
n['online'] = True
n['name'] = n['username']
users.append(n)
users.sort(key=lambda u: ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or '')))
return {
"users": users