Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0060.py @ 3911:8289ac1b34f4
plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
- support for both (modern) OMEMO under the `urn:xmpp:omemo:2` namespace and (legacy) OMEMO under the `eu.siacs.conversations.axolotl` namespace
- maintains one identity across both versions of OMEMO
- migrates data from the old plugin
- includes more features for protocol stability
- uses SCE for modern OMEMO
- fully type-checked, linted and format-checked
- added type hints to various pieces of backend code used by the plugin
- added stubs for some Twisted APIs used by the plugin under stubs/ (use `export MYPYPATH=stubs/` before running mypy)
- core (xmpp): enabled `send` trigger and made it an asyncPoint
fix 375
author | Syndace <me@syndace.dev> |
---|---|
date | Tue, 23 Aug 2022 21:06:24 +0200 |
parents | 1e64f1ed3ebd |
children | cecf45416403 |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py Thu Sep 22 12:03:12 2022 +0200 +++ b/sat/plugins/plugin_xep_0060.py Tue Aug 23 21:06:24 2022 +0200 @@ -19,7 +19,7 @@ from collections import namedtuple from functools import reduce -from typing import Any, Dict, List, Optional, Tuple, Union, Callable +from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, Callable import urllib.error import urllib.parse import urllib.request @@ -39,6 +39,7 @@ from sat.core.core_types import SatXMPPEntity from sat.core.i18n import _ from sat.core.log import getLogger +from sat.core.xmpp import SatXMPPClient from sat.tools import utils from sat.tools import sat_defer from sat.tools import xml_tools @@ -538,17 +539,22 @@ )) async def sendItem( - self, client, service, nodeIdentifier, payload, item_id=None, extra=None - ): + self, + client: SatXMPPClient, + service: Union[jid.JID, None], + nodeIdentifier: str, + payload: domish.Element, + item_id: Optional[str] = None, + extra: Optional[Dict[str, Any]] = None + ) -> Optional[str]: """High level method to send one item - @param service(jid.JID, None): service to send the item to - None to use PEP - @param NodeIdentifier(unicode): PubSub node to use - @param payload(domish.Element): payload of the item to send - @param item_id(unicode, None): id to use or None to create one - @param extra(dict, None): extra option, not used yet - @return (unicode, None): id of the created item + @param service: service to send the item to None to use PEP + @param NodeIdentifier: PubSub node to use + @param payload: payload of the item to send + @param item_id: id to use or None to create one + @param extra: extra options + @return: id of the created item """ assert isinstance(payload, domish.Element) item_elt = domish.Element((pubsub.NS_PUBSUB, 'item')) @@ -1090,7 +1096,12 @@ client, jid.JID(service_s) if service_s else None, nodeIdentifier ) - def deleteNode(self, client, service, nodeIdentifier): + def deleteNode( + self, + client: SatXMPPClient, + service: jid.JID, + nodeIdentifier: str + ) -> defer.Deferred: return client.pubsub_client.deleteNode(service, nodeIdentifier) def _addWatch(self, service_s, node, profile_key): @@ -1132,12 +1143,12 @@ def retractItems( self, - client, - service, - nodeIdentifier, - itemIdentifiers, - notify=True, - ): + client: SatXMPPClient, + service: jid.JID, + nodeIdentifier: str, + itemIdentifiers: Iterable[str], + notify: bool = True, + ) -> defer.Deferred: return client.pubsub_client.retractItems( service, nodeIdentifier, itemIdentifiers, notify=notify )