comparison libervia/web/pages/chat/page_meta.py @ 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 61449c5ddd70
children
comparison
equal deleted inserted replaced
1630:1d1b1f360b75 1631:d4dd4c94463c
56 ) 56 )
57 57
58 disco = await self.host.bridge_call( 58 disco = await self.host.bridge_call(
59 "disco_infos", target_jid.domain, "", True, profile 59 "disco_infos", target_jid.domain, "", True, profile
60 ) 60 )
61 if "conference" in [i[0] for i in disco[1]]: 61 categories = {i[0] for i in disco[1]}
62
63 if "gateway" in categories:
64 data_policy = data_format.deserialise(await self.host.bridge_call(
65 "data_policy_get", target_jid.domain, profile
66 ))
67 # TODO: Handle services data policies.
68 template_data["data_policy"] = data_policy["main"]
69 dp_score = data_policy["main"]["score"]
70 dp_min = dp_score["minimum"]
71 score = (dp_score["score"] - dp_min) / (dp_score["maximum"] - dp_min) * 10
72
73 template_data["data_policy_score"] = score
74
75 self.expose_to_scripts(
76 request,
77 data_policy=data_policy["main"],
78 data_policy_score=score
79 )
80 if "conference" in categories:
62 chat_type = C.CHAT_GROUP 81 chat_type = C.CHAT_GROUP
63 join_ret = await self.host.bridge_call( 82 join_ret = await self.host.bridge_call(
64 "muc_join", target_jid.bare, "", "", profile 83 "muc_join", target_jid.bare, "", "", profile
65 ) 84 )
66 (already_joined, 85 (already_joined,