trigger peering.accept if peering in requestPeering

This commit is contained in:
j 2016-04-05 10:40:57 +02:00
parent 0b2db6fd80
commit 876f511f45

View file

@ -26,6 +26,7 @@ def api_pullChanges(remote_id, user_id=None, from_=None, to=None):
return Changelog.aggregated_changes(from_) return Changelog.aggregated_changes(from_)
def api_requestPeering(user_id, username, message): def api_requestPeering(user_id, username, message):
event = 'peering.request'
user = User.get_or_create(user_id) user = User.get_or_create(user_id)
if not user.peered: if not user.peered:
pref = settings.preferences.get('receivedRequests') pref = settings.preferences.get('receivedRequests')
@ -35,13 +36,14 @@ def api_requestPeering(user_id, username, message):
user.info['message'] = message user.info['message'] = message
user.update_peering(True, username) user.update_peering(True, username)
user.update_name() user.update_name()
event = 'peering.accept'
else: else:
user.pending = 'received' user.pending = 'received'
user.info['username'] = username user.info['username'] = username
user.info['message'] = message user.info['message'] = message
user.update_name() user.update_name()
user.save() user.save()
trigger_event('peering.request', user.json()) trigger_event(event, user.json())
if user.peered: if user.peered:
state.nodes.queue('add', user.id, True) state.nodes.queue('add', user.id, True)
return True return True