Mercurial > libervia-web
changeset 1631:d4dd4c94463c
pages (chat): Retrieve Data Policy and generate score:
If we're talking to a gateway, get Data Policy from backend, and calculate a score on 10.
Values are then exposed to template and scripts.
rel 460
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 26 Jun 2025 17:10:41 +0200 |
parents | 1d1b1f360b75 |
children | 8400d3b58515 |
files | libervia/web/pages/chat/page_meta.py |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/web/pages/chat/page_meta.py Thu Jun 26 17:07:55 2025 +0200 +++ b/libervia/web/pages/chat/page_meta.py Thu Jun 26 17:10:41 2025 +0200 @@ -58,7 +58,26 @@ disco = await self.host.bridge_call( "disco_infos", target_jid.domain, "", True, profile ) - if "conference" in [i[0] for i in disco[1]]: + categories = {i[0] for i in disco[1]} + + if "gateway" in categories: + data_policy = data_format.deserialise(await self.host.bridge_call( + "data_policy_get", target_jid.domain, profile + )) + # TODO: Handle services data policies. + template_data["data_policy"] = data_policy["main"] + dp_score = data_policy["main"]["score"] + dp_min = dp_score["minimum"] + score = (dp_score["score"] - dp_min) / (dp_score["maximum"] - dp_min) * 10 + + template_data["data_policy_score"] = score + + self.expose_to_scripts( + request, + data_policy=data_policy["main"], + data_policy_score=score + ) + if "conference" in categories: chat_type = C.CHAT_GROUP join_ret = await self.host.bridge_call( "muc_join", target_jid.bare, "", "", profile