comparison sat/core/xmpp.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 9581098b64f0
children efc34a89e70b
comparison
equal deleted inserted replaced
3776:4d333f249625 3777:001ea5f4a2f9
598 598
599 if post_xml_treatments is not None: 599 if post_xml_treatments is not None:
600 post_xml_treatments.callback(data) 600 post_xml_treatments.callback(data)
601 return data 601 return data
602 602
603 @property
604 def is_admin(self) -> bool:
605 """True if a client is an administrator with extra privileges"""
606 return self.host_app.memory.isAdmin(self.profile)
607
603 def addPostXmlCallbacks(self, post_xml_treatments): 608 def addPostXmlCallbacks(self, post_xml_treatments):
604 """Used to add class level callbacks at the end of the workflow 609 """Used to add class level callbacks at the end of the workflow
605 610
606 @param post_xml_treatments(D): the same Deferred as in sendMessage trigger 611 @param post_xml_treatments(D): the same Deferred as in sendMessage trigger
607 """ 612 """
1006 1011
1007 @property 1012 @property
1008 def server_jid(self): 1013 def server_jid(self):
1009 # FIXME: not the best way to get server jid, maybe use config option? 1014 # FIXME: not the best way to get server jid, maybe use config option?
1010 return jid.JID(self.jid.host.split(".", 1)[-1]) 1015 return jid.JID(self.jid.host.split(".", 1)[-1])
1016
1017 @property
1018 def is_admin(self) -> bool:
1019 return False
1011 1020
1012 def _buildDependencies(self, current, plugins, required=True): 1021 def _buildDependencies(self, current, plugins, required=True):
1013 """build recursively dependencies needed for a plugin 1022 """build recursively dependencies needed for a plugin
1014 1023
1015 this method build list of plugin needed for a component and raises 1024 this method build list of plugin needed for a component and raises