Coverage for slidge/slixfix/xep_0490/mds.py: 85%
26 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-07 05:11 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-07 05:11 +0000
1from slixmpp import Iq
2from slixmpp.plugins import BasePlugin
3from slixmpp.plugins.xep_0004 import Form
4from slixmpp.types import JidStr
6from . import stanza
9class XEP_0490(BasePlugin):
10 """
11 XEP-0490: Message Displayed Synchronization
12 """
14 name = "xep_0490"
15 description = "XEP-0490: Message Displayed Synchronization"
16 dependencies = {"xep_0060", "xep_0163", "xep_0359"}
17 stanza = stanza
19 def plugin_init(self):
20 stanza.register_plugin()
21 self.xmpp.plugin["xep_0163"].register_pep(
22 "message_displayed_synchronization",
23 stanza.Displayed,
24 )
26 def flag_chat(self, chat: JidStr, stanza_id: str, **kwargs) -> Iq:
27 displayed = stanza.Displayed()
28 displayed["stanza_id"]["id"] = stanza_id
29 return self.xmpp.plugin["xep_0163"].publish(
30 displayed, node=stanza.NS, options=PUBLISH_OPTIONS, id=str(chat), **kwargs
31 )
33 def catch_up(self, **kwargs):
34 return self.xmpp.plugin["xep_0060"].get_items(
35 self.xmpp.boundjid.bare, stanza.NS, **kwargs
36 )
39PUBLISH_OPTIONS = Form()
40PUBLISH_OPTIONS["type"] = "submit"
41PUBLISH_OPTIONS.add_field(
42 "FORM_TYPE", "hidden", value="http://jabber.org/protocol/pubsub#publish-options"
43)
44PUBLISH_OPTIONS.add_field("pubsub#persist_items", value="true")
45PUBLISH_OPTIONS.add_field("pubsub#max_items", value="max")
46PUBLISH_OPTIONS.add_field("pubsub#send_last_published_item", value="never")
47PUBLISH_OPTIONS.add_field("pubsub#access_model", value="whitelist")