MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / actionFileRules

Method actionFileRules

src/Ui/UiWebsocket.py:708–727  ·  view source on GitHub ↗
(self, to, inner_path, use_my_cert=False, content=None)

Source from the content-addressed store, hash-verified

706 return self.response(to, "ok")
707
708 def actionFileRules(self, to, inner_path, use_my_cert=False, content=None):
709 if not content: # No content defined by function call
710 content = self.site.content_manager.contents.get(inner_path)
711
712 if not content: # File not created yet
713 cert = self.user.getCert(self.site.address)
714 if cert and cert["auth_address"] in self.site.content_manager.getValidSigners(inner_path):
715 # Current selected cert if valid for this site, add it to query rules
716 content = {}
717 content["cert_auth_type"] = cert["auth_type"]
718 content["cert_user_id"] = self.user.getCertUserId(self.site.address)
719 content["cert_sign"] = cert["cert_sign"]
720
721 rules = self.site.content_manager.getRules(inner_path, content)
722 if inner_path.endswith("content.json") and rules:
723 if content:
724 rules["current_size"] = len(json.dumps(content)) + sum([file["size"] for file in list(content.get("files", {}).values())])
725 else:
726 rules["current_size"] = 0
727 return self.response(to, rules)
728
729 # Add certificate to user
730 def actionCertAdd(self, to, domain, auth_type, auth_user_name, cert):

Callers

nothing calls this directly

Calls 8

responseMethod · 0.95
sumFunction · 0.85
getCertMethod · 0.80
getValidSignersMethod · 0.80
getCertUserIdMethod · 0.80
getRulesMethod · 0.80
valuesMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected