UserSetSettings, UserGetSettings Websocket API commands

This commit is contained in:
shortcutme 2017-07-10 02:41:01 +02:00
parent 1384da4691
commit efbef25c76
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 14 additions and 1 deletions

View file

@ -818,13 +818,20 @@ class UiWebsocket(object):
self.cmd("notification", ["done", _["Site cloned"] + "<script>window.top.location = '/%s'</script>" % new_address])
gevent.spawn(new_site.announce)
def actionSiteSetLimit(self, to, size_limit):
self.site.settings["size_limit"] = int(size_limit)
self.site.saveSettings()
self.response(to, "ok")
self.site.download(blind_includes=True)
def actionUserGetSettings(self, to):
settings = self.user.sites[self.site.address].get("settings", {})
self.response(to, settings)
def actionUserSetSettings(self, to, settings):
self.user.setSettings(self.site.address, settings)
self.response(to, "ok")
def actionServerUpdate(self, to):
self.cmd("updating")
sys.modules["main"].update_after_shutdown = True

View file

@ -67,6 +67,12 @@ class User(object):
self.save()
self.log.debug("Deleted site: %s" % address)
def setSettings(self, address, settings):
site_data = self.getSiteData(address)
site_data["settings"] = settings
self.save()
return site_data
# Get data for a new, unique site
# Return: [site_address, bip32_index, {"auth_address": "xxx", "auth_privatekey": "xxx", "privatekey": "xxx"}]
def getNewSiteData(self):