comparison sat/core/sat_main.py @ 3777:001ea5f4a2f9

core: method to know if a profile/entity is an admin: the new `is_admin` SatXMPPEntity property tell if it's an administrator. Admin JIDs are retrieve on init, so they can be looked after when profle is not available (notably when a component handle a request and has only a JID available). The new `memory.isAdminJID` method is then used.
author Goffi <goffi@goffi.org>
date Sun, 15 May 2022 14:14:52 +0200
parents 16e36f0dd1cb
children 89b13b405b93
comparison
equal deleted inserted replaced
3776:4d333f249625 3777:001ea5f4a2f9
937 raise exceptions.ProfileUnknownError(profile_key) 937 raise exceptions.ProfileUnknownError(profile_key)
938 if profile not in self.profiles: 938 if profile not in self.profiles:
939 return False 939 return False
940 return self.profiles[profile].isConnected() 940 return self.profiles[profile].isConnected()
941 941
942 def isAdmin(self, client: xmpp.SatXMPPEntity) -> bool:
943 """Tells if a client is an administrator with extra privileges"""
944 return client.profile in self.memory.admins
945
942 ## Encryption ## 946 ## Encryption ##
943 947
944 def registerEncryptionPlugin(self, *args, **kwargs): 948 def registerEncryptionPlugin(self, *args, **kwargs):
945 return encryption.EncryptionHandler.registerPlugin(*args, **kwargs) 949 return encryption.EncryptionHandler.registerPlugin(*args, **kwargs)
946 950