annotate libervia/backend/plugins/plugin_xep_0422.py @ 4215:31c84a32c897

docker: modernisation and fixes: - fix geckodriver version used following `backend-dev-e2e` base image update - use Prosody image `prosodyim/prosody:0.12` instead of a deprecated one - update `pubsub` image with base image update and use of new repos names
author Goffi <goffi@goffi.org>
date Tue, 05 Mar 2024 16:43:45 +0100
parents 4b842c1fb686
children 0d7bb4df2343
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Copyright (C) 2009-2022 Jérôme Poisson (goffi@goffi.org)
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # This program is free software: you can redistribute it and/or modify
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # it under the terms of the GNU Affero General Public License as published by
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # the Free Software Foundation, either version 3 of the License, or
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # (at your option) any later version.
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # GNU Affero General Public License for more details.
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # You should have received a copy of the GNU Affero General Public License
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 from typing import Optional, List, Tuple, Union, NamedTuple
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from collections import namedtuple
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.protocols.jabber import xmlstream
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.xish import domish
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from wokkel import disco
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from zope.interface import implementer
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
26 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
27 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
28 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
29 from libervia.backend.core.core_types import SatXMPPEntity
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
30 from libervia.backend.memory.sqla_mapping import History
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
31 from libervia.backend.tools.common.async_utils import async_lru
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 log = getLogger(__name__)
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
34
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 PLUGIN_INFO = {
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_NAME: "Message Fastening",
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_IMPORT_NAME: "XEP-0422",
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_TYPE: "XEP",
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_MODES: C.PLUG_MODE_BOTH,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_PROTOCOLS: ["XEP-0359", "XEP-0422"],
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_MAIN: "XEP_0422",
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 C.PI_HANDLER: "yes",
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 C.PI_DESCRIPTION: _("""Implementation Message Fastening"""),
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 }
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 NS_FASTEN = "urn:xmpp:fasten:0"
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 class FastenMetadata(NamedTuple):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 elements: List[domish.Element]
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 id: str
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 history: Optional[History]
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 clear: bool
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 shell: bool
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 class XEP_0422(object):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 def __init__(self, host):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 log.info(_("XEP-0422 (Message Fastening) plugin initialization"))
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 self.host = host
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3799
diff changeset
63 host.register_namespace("fasten", NS_FASTEN)
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3799
diff changeset
65 def get_handler(self, __):
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 return XEP_0422_handler()
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3799
diff changeset
68 def apply_to_elt(
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 message_elt: domish.Element,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 origin_id: str,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 clear: Optional[bool] = None,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 shell: Optional[bool] = None,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 children: Optional[List[domish.Element]] = None,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 external: Optional[List[Union[str, Tuple[str, str]]]] = None
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 ) -> domish.Element:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 """Generate, add and return <apply-to> element
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 @param message_elt: wrapping <message> element
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 @param origin_id: origin ID of the target message
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 @param clear: set to True to remove a fastening
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 @param shell: set to True when using e2ee shell
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 cf. https://xmpp.org/extensions/xep-0422.html#encryption
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 @param children: element to fasten to the target message
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 <apply-to> element is returned, thus children can also easily be added
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 afterwards
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 @param external: <external> element to add
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 cf. https://xmpp.org/extensions/xep-0422.html#external-payloads
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 the list items can either be a str with only the element name,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 or a tuple which must then be (namespace, name)
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 @return: <apply-to> element, which is already added to the wrapping message_elt
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 """
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 apply_to_elt = message_elt.addElement((NS_FASTEN, "apply-to"))
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 apply_to_elt["id"] = origin_id
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 if clear is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3799
diff changeset
96 apply_to_elt["clear"] = C.bool_const(clear)
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 if shell is not None:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3799
diff changeset
98 apply_to_elt["shell"] = C.bool_const(shell)
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 if children is not None:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 for child in children:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 apply_to_elt.addChild(child)
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 if external is not None:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 for ext in external:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 external_elt = apply_to_elt.addElement("external")
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 if isinstance(ext, str):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 external_elt["name"] = ext
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 else:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 ns, name = ext
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 external_elt["name"] = name
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 external_elt["element-namespace"] = ns
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 return apply_to_elt
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
112
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 @async_lru(maxsize=5)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3799
diff changeset
114 async def get_fastened_elts(
3799
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 self,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 client: SatXMPPEntity,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 message_elt: domish.Element
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 ) -> Optional[FastenMetadata]:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 """Get fastened elements
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 if the message contains no <apply-to> element, None is returned
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 """
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 try:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 apply_to_elt = next(message_elt.elements(NS_FASTEN, "apply-to"))
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 except StopIteration:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 return None
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 else:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 origin_id = apply_to_elt.getAttribute("id")
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 if not origin_id:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 log.warning(
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 f"Received invalid fastening message: {message_elt.toXml()}"
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 )
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 return None
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 elements = apply_to_elt.children
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 if not elements:
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 log.warning(f"No element to fasten: {message_elt.toXml()}")
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 return None
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 history = await self.host.memory.storage.get(
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 client,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 History,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 History.origin_id,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 origin_id,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 (History.messages, History.subjects, History.thread)
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 )
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 return FastenMetadata(
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 elements,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 origin_id,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 history,
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 C.bool(apply_to_elt.getAttribute("clear", C.BOOL_FALSE)),
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 C.bool(apply_to_elt.getAttribute("shell", C.BOOL_FALSE)),
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 )
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 @implementer(disco.IDisco)
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 class XEP_0422_handler(xmlstream.XMPPHandler):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 def getDiscoInfo(self, __, target, nodeIdentifier=""):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 return [disco.DiscoFeature(NS_FASTEN)]
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
60724ff3f273 plugin XEP-0422: Message Fastening implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 return []