New UiWebsocket API command to run commands as other site

This commit is contained in:
shortcutme 2017-12-15 12:13:19 +01:00
parent 8a331e7400
commit 1ac69ae315
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import hashlib
import os
import shutil
import re
import copy
import gevent
@ -321,6 +322,16 @@ class UiWebsocket(object):
# - Actions -
def actionAs(self, to, address, cmd, params=[]):
if not self.hasSitePermission(address):
return self.response(to, "No permission for site %s" % address)
req_self = copy.copy(self)
req_self.site = self.server.sites.get(address)
req_self.hasCmdPermission = self.hasCmdPermission # Use the same permissions as current site
req_obj = super(UiWebsocket, req_self)
req = {"id": to, "cmd": cmd, "params": params}
req_obj.handleRequest(req)
# Do callback on response {"cmd": "response", "to": message_id, "result": result}
def actionResponse(self, to, result):
if to in self.waiting_cb: