annotate libervia/backend/plugins/plugin_xep_0103.py @ 4351:6a0a081485b8

plugin autocrypt: Autocrypt protocol implementation: Implementation of autocrypt: `autocrypt` header is checked, and if present and no public key is known for the peer, the key is imported. `autocrypt` header is also added to outgoing message (only if an email gateway is detected). For the moment, the JID is use as identifier, but the real email used by gateway should be used in the future. rel 456
author Goffi <goffi@goffi.org>
date Fri, 28 Feb 2025 09:23:35 +0100
parents 111dce64dcb5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Copyright (C) 2009-2022 Jérôme Poisson (goffi@goffi.org)
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # This program is free software: you can redistribute it and/or modify
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # it under the terms of the GNU Affero General Public License as published by
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # the Free Software Foundation, either version 3 of the License, or
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # (at your option) any later version.
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # GNU Affero General Public License for more details.
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # You should have received a copy of the GNU Affero General Public License
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
18 from typing import Self
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
20 from pydantic import BaseModel, Field
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.xish import domish
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
23 from libervia.backend.core import exceptions
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
24 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
25 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
26 from libervia.backend.core.log import getLogger
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 log = getLogger(__name__)
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 PLUGIN_INFO = {
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 C.PI_NAME: "URL Address Information",
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 C.PI_IMPORT_NAME: "XEP-0103",
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 C.PI_TYPE: "XEP",
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 C.PI_MODES: C.PLUG_MODE_BOTH,
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 C.PI_PROTOCOLS: ["XEP-0103"],
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 C.PI_MAIN: "XEP_0103",
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_HANDLER: "no",
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_DESCRIPTION: _("""Implementation of XEP-0103 (URL Address Information)"""),
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 }
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
40 NS_URL_DATA = "http://jabber.org/protocol/url-data"
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
42
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
43 class Desc(BaseModel):
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
44 """
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
45 Model for the <desc/> element.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
46 """
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
47
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
48 content: str
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
49 xml_lang: str | None = None
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
50
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
51
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
52 class URLData(BaseModel):
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
53 """
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
54 Model for the <url-data/> element.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
55 """
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
56
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
57 url: str
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
58 desc: list[Desc] = Field(default_factory=list)
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
59
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
60 @classmethod
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
61 def from_element(cls, element: domish.Element) -> Self:
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
62 """Create a URLData instance from a <url-data> element or its parent.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
63
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
64 @param url_data_elt: The <url-data> element or a parent element.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
65 @return: URLData instance.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
66 @raise exceptions.NotFound: If the <url-data> element is not found.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
67 """
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
68 if element.uri != NS_URL_DATA or element.name != "url-data":
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
69 child_url_data_elt = next(element.elements(NS_URL_DATA, "url-data"), None)
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
70 if child_url_data_elt is None:
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
71 raise exceptions.NotFound("<url-data> element not found")
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
72 else:
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
73 element = child_url_data_elt
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
74 kwargs = {
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
75 "url": element["target"],
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
76 "desc": [
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
77 Desc(content=str(desc_elt), xml_lang=desc_elt.getAttribute("xml:lang"))
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
78 for desc_elt in element.elements(NS_URL_DATA, "desc")
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
79 ],
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
80 }
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
81 return cls(**kwargs)
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
82
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
83 def to_element(self) -> domish.Element:
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
84 """Build the <url-data> element from this instance's data.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
85
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
86 @return: <url-data> element.
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
87 """
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
88 url_data_elt = domish.Element((NS_URL_DATA, "url-data"))
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
89 url_data_elt["target"] = self.url
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
90 for desc in self.desc:
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
91 desc_elt = url_data_elt.addElement((NS_URL_DATA, "desc"))
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
92 if desc.xml_lang:
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
93 desc_elt["xml:lang"] = desc.xml_lang
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
94 desc_elt.addContent(desc.content)
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
95 return url_data_elt
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
96
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 class XEP_0103:
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 namespace = NS_URL_DATA
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def __init__(self, host):
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
102 log.info(f"plugin {PLUGIN_INFO[C.PI_NAME]!r} initialization")
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3895
diff changeset
103 host.register_namespace("url-data", NS_URL_DATA)
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
105 def generate_url_data(self, url: str, **kwargs) -> URLData:
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 """Generate the element describing the URL
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 @param url: URL to use
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 @param extra: extra metadata describing how to access the URL
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 @return: ``<url-data/>`` element
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 """
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
112 url_data = URLData(url=url, **kwargs)
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
113 return url_data
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
114
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
115 def parse_url_data_elt(self, url_data_elt: domish.Element) -> URLData:
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 """Parse <url-data/> element
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 @param url_data_elt: <url-data/> element
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 a parent element can also be used
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
120 @return: URLData instance
3895
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 @raise exceptions.NotFound: no <url-data/> element has been found
eb0a77bea363 plugin XEP-0103: URL Address Information implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 """
4334
111dce64dcb5 plugins XEP-0300, XEP-0446, XEP-0447, XEP0448 and others: Refactoring to use Pydantic:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
123 return URLData.from_element(url_data_elt)