dont add local peers to db, just show them in user dialog
This commit is contained in:
parent
eeae402218
commit
444c357e54
2 changed files with 15 additions and 6 deletions
|
@ -141,12 +141,13 @@ class LocalNodesBase(Thread):
|
||||||
if can_connect(data):
|
if can_connect(data):
|
||||||
self._nodes[data['id']] = data
|
self._nodes[data['id']] = data
|
||||||
with db.session():
|
with db.session():
|
||||||
u = user.models.User.get_or_create(data['id'])
|
u = user.models.User.get(data['id'])
|
||||||
u.info['username'] = data['username']
|
if u:
|
||||||
u.info['local'] = data
|
u.info['username'] = data['username']
|
||||||
u.update_name()
|
u.info['local'] = data
|
||||||
u.save()
|
u.update_name()
|
||||||
state.nodes.queue('add', u.id)
|
u.save()
|
||||||
|
state.nodes.queue('add', u.id)
|
||||||
self.send()
|
self.send()
|
||||||
|
|
||||||
def get_ip(self):
|
def get_ip(self):
|
||||||
|
|
|
@ -83,8 +83,16 @@ def getUsers(data):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
users = []
|
users = []
|
||||||
|
ids = set()
|
||||||
for u in models.User.query.filter(models.User.id!=settings.USER_ID).all():
|
for u in models.User.query.filter(models.User.id!=settings.USER_ID).all():
|
||||||
users.append(u.json())
|
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 '')))
|
users.sort(key=lambda u: ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or '')))
|
||||||
return {
|
return {
|
||||||
"users": users
|
"users": users
|
||||||
|
|
Loading…
Reference in a new issue