Mercurial > libervia-backend
diff 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 |
line wrap: on
line diff
--- a/sat/core/xmpp.py Sat May 14 23:00:35 2022 +0200 +++ b/sat/core/xmpp.py Sun May 15 14:14:52 2022 +0200 @@ -600,6 +600,11 @@ post_xml_treatments.callback(data) return data + @property + def is_admin(self) -> bool: + """True if a client is an administrator with extra privileges""" + return self.host_app.memory.isAdmin(self.profile) + def addPostXmlCallbacks(self, post_xml_treatments): """Used to add class level callbacks at the end of the workflow @@ -1009,6 +1014,10 @@ # FIXME: not the best way to get server jid, maybe use config option? return jid.JID(self.jid.host.split(".", 1)[-1]) + @property + def is_admin(self) -> bool: + return False + def _buildDependencies(self, current, plugins, required=True): """build recursively dependencies needed for a plugin