comparison sat/plugins/plugin_comp_file_sharing.py @ 3778:7b90d7c474fa

comp file sharing: handle `admins` in quotas
author Goffi <goffi@goffi.org>
date Sun, 15 May 2022 14:15:24 +0200
parents 75f8d206e551
children 3ef988734869
comparison
equal deleted inserted replaced
3777:001ea5f4a2f9 3778:7b90d7c474fa
408 if not os.path.exists(path): 408 if not os.path.exists(path):
409 os.makedirs(path) 409 os.makedirs(path)
410 410
411 def getQuota(self, client, entity): 411 def getQuota(self, client, entity):
412 """Return maximum size allowed for all files for entity""" 412 """Return maximum size allowed for all files for entity"""
413 # TODO: handle special entities like admins
414 quotas = self.host.memory.getConfig("component file-sharing", "quotas_json", {}) 413 quotas = self.host.memory.getConfig("component file-sharing", "quotas_json", {})
415 entity_bare_s = entity.userhost() 414 if self.host.memory.isAdminJID(entity):
416 try: 415 quota = quotas.get("admins")
417 quota = quotas["jids"][entity_bare_s] 416 else:
418 except KeyError: 417 try:
419 quota = quotas.get("users") 418 quota = quotas["jids"][entity.userhost()]
419 except KeyError:
420 quota = quotas.get("users")
420 return None if quota is None else utils.parseSize(quota) 421 return None if quota is None else utils.parseSize(quota)
421 422
422 async def generate_thumbnails(self, extra: dict, image_path: Path): 423 async def generate_thumbnails(self, extra: dict, image_path: Path):
423 thumbnails = extra.setdefault(C.KEY_THUMBNAILS, []) 424 thumbnails = extra.setdefault(C.KEY_THUMBNAILS, [])
424 for max_thumb_size in self._t.SIZES: 425 for max_thumb_size in self._t.SIZES: