peer pending clients on pullChanges

This commit is contained in:
j 2016-01-30 11:40:55 +05:30
parent aac0a069d2
commit 142f3bcc6e

View file

@ -25,6 +25,7 @@ import db
import settings
import state
import user
from websocket import trigger_event
from . import nodeapi
from .sslsocket import fileobject
@ -77,6 +78,10 @@ class NodeServer(ThreadingMixIn, TLSTCPServer):
def api_call(action, user_id, args):
with db.session():
u = user.models.User.get(user_id)
if action in ('pullChanges', ) and not u.peered and u.pending == 'sent':
u.update_peering(True)
state.nodes.queue('add', user.id, True)
trigger_event('peering.accept', user.json())
if action in (
'requestPeering', 'acceptPeering', 'rejectPeering',
'removePeering', 'cancelPeering'