comp file sharing: handle admins in quotas

This commit is contained in:
Goffi 2022-05-15 14:15:24 +02:00
commit f4fa679e9c

View file

@ -410,13 +410,14 @@ class FileSharing:
def getQuota(self, client, entity): def getQuota(self, client, entity):
"""Return maximum size allowed for all files for entity""" """Return maximum size allowed for all files for entity"""
# TODO: handle special entities like admins
quotas = self.host.memory.getConfig("component file-sharing", "quotas_json", {}) quotas = self.host.memory.getConfig("component file-sharing", "quotas_json", {})
entity_bare_s = entity.userhost() if self.host.memory.isAdminJID(entity):
try: quota = quotas.get("admins")
quota = quotas["jids"][entity_bare_s] else:
except KeyError: try:
quota = quotas.get("users") quota = quotas["jids"][entity.userhost()]
except KeyError:
quota = quotas.get("users")
return None if quota is None else utils.parseSize(quota) return None if quota is None else utils.parseSize(quota)
async def generate_thumbnails(self, extra: dict, image_path: Path): async def generate_thumbnails(self, extra: dict, image_path: Path):