ping on action

This commit is contained in:
j 2019-02-02 17:36:11 +05:30
parent 4033958341
commit 431dc8e194

View file

@ -539,9 +539,10 @@ class Nodes(Thread):
def peer_queue(self, peer, action, *args): def peer_queue(self, peer, action, *args):
if peer not in self._nodes: if peer not in self._nodes:
self._add(peer) self._add(peer)
elif not self._nodes[peer].is_online():
self._nodes[peer].ping()
self._nodes[peer].queue(action, *args) self._nodes[peer].queue(action, *args)
def is_online(self, id): def is_online(self, id):
return id in self._nodes and self._nodes[id].is_online() return id in self._nodes and self._nodes[id].is_online()
@ -557,7 +558,12 @@ class Nodes(Thread):
if target == 'all': if target == 'all':
nodes = list(self._nodes.values()) nodes = list(self._nodes.values())
elif target == 'peered': elif target == 'peered':
nodes = [n for n in list(self._nodes.values()) if n.user.peered] ids = []
with db.session():
from user.models import User
for u in User.query.filter(User.id != settings.USER_ID).filter_by(peered=True).all():
ids.append(u.id)
nodes = [n for n in list(self._nodes.values()) if n.user_id in ids]
elif target == 'online': elif target == 'online':
nodes = [n for n in list(self._nodes.values()) if n.online] nodes = [n for n in list(self._nodes.values()) if n.online]
else: else: