Debian Codegraph @

libervia/backend/plugins/plugin_comp_ap_gateway/http_server.py

raw symbols SCIP
1 #!/usr/bin/env python3
2
3 # Libervia ActivityPub Gateway
4 # Copyright (C) 2009-2026 Jérôme Poisson ([email protected])
5
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
15
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 from collectionsscip-python python python-stdlib 3.11 collections/__init__: import dequescip-python python python-stdlib 3.11 collections/deque#
20 import htmlscip-python python python-stdlib 3.11 html/__init__:
21 import jsonscip-python python python-stdlib 3.11 json/__init__:
22 import timescip-python python python-stdlib 3.11 time/__init__:
23 from typingscip-python python python-stdlib 3.11 typing/__init__: import Anyscip-python python python-stdlib 3.11 typing/Any., Dictscip-python python python-stdlib 3.11 typing/Dict., Listscip-python python python-stdlib 3.11 typing/List., Optionalscip-python python python-stdlib 3.11 typing/Optional., TYPE_CHECKINGscip-python python python-stdlib 3.11 typing/TYPE_CHECKING.TYPE_CHECKING.
24 import unicodedatascip-python python python-stdlib 3.11 unicodedata/__init__:
25 from urllibscip-python python python-stdlib 3.11 urllib/__init__: import parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:
26
27 from twisted.internetscip-python python Twisted 26.4.0 `twisted.internet`/__init__: import deferscip-python python Twisted 26.4.0 `twisted.internet.defer`/__init__:
28 from twisted.pythonscip-python python Twisted 26.4.0 `twisted.python`/__init__: import failurescip-python python Twisted 26.4.0 `twisted.python.failure`/__init__:
29 from twisted.webscip-python python Twisted 26.4.0 `twisted.web`/__init__: import httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:, resource as web_resource, serverscip-python python Twisted 26.4.0 `twisted.web.server`/__init__:
30 from twisted.webscip-python python Twisted 26.4.0 `twisted.web`/__init__: import staticscip-python python Twisted 26.4.0 `twisted.web.static`/__init__:
31 from twisted.webscip-python python Twisted 26.4.0 `twisted.web`/__init__: import util as web_util
32 from twisted.words.protocols.jabberscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber`/__init__: import errorscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.error`/__init__:, jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:
33 from tx_xmppscip-python python libervia-backend 0.9.0.dev0 tx_xmpp/__init__: import pubsubscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.pubsub`/__init__:, rsmscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.rsm`/__init__:
34
35 from libervia.backend.corescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core`/__init__: import exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:
36 from libervia.backend.core.constantsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/__init__: import Const as Cscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#
37 from libervia.backend.core.core_typesscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/__init__: import SatXMPPEntityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#
38 from libervia.backend.core.i18nscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.i18n`/__init__: import _scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.i18n`/_.
39 from libervia.backend.core.logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/__init__: import getLoggerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/getLogger().
40 from libervia.backend.memory.sqla_mappingscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/__init__: import SubscriptionStatescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#
41 from libervia.backend.plugins.plugin_xep_0277scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/__init__: import MbDatascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/MbData#
42 from libervia.backend.tools.commonscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common`/__init__: import date_utilsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common.date_utils`/__init__:, uriscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common.uri`/__init__:
43
44 from .constantsscip-python python libervia-backend 0.9.0.dev0 constants/__init__: import (
45 ACTIVITY_TYPES_LOWERscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ACTIVITY_TYPES_LOWER.,
46 ACTIVIY_NO_ACCOUNT_ALLOWEDscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ACTIVIY_NO_ACCOUNT_ALLOWED.,
47 AP_REQUEST_TYPESscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/AP_REQUEST_TYPES.,
48 CONTENT_TYPE_APscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/CONTENT_TYPE_AP.,
49 CONTENT_TYPE_WEBFINGERscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/CONTENT_TYPE_WEBFINGER.,
50 HS2019scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/HS2019.,
51 MEDIA_TYPE_APscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/MEDIA_TYPE_AP.,
52 MEDIA_TYPE_AP_ALTscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/MEDIA_TYPE_AP_ALT.,
53 NS_APscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/NS_AP.,
54 PAGE_SIZEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/PAGE_SIZE.,
55 SIGN_EXPscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/SIGN_EXP.,
56 SIGN_HEADERSscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/SIGN_HEADERS.,
57 ST_AP_CACHEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ST_AP_CACHE.,
58 TYPE_ACTORscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ACTOR.,
59 TYPE_EVENTscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_EVENT.,
60 TYPE_FOLLOWERSscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_FOLLOWERS.,
61 TYPE_FOLLOWINGscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_FOLLOWING.,
62 TYPE_INBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_INBOX.,
63 TYPE_ITEMscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ITEM.,
64 TYPE_LIKEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_LIKE.,
65 TYPE_OUTBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_OUTBOX.,
66 TYPE_REACTIONscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_REACTION.,
67 TYPE_SHARED_INBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_SHARED_INBOX.,
68 )
69 from .regexscip-python python libervia-backend 0.9.0.dev0 regex/__init__: import RE_SIG_PARAMscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.regex`/RE_SIG_PARAM.
70
71 if TYPE_CHECKINGscip-python python python-stdlib 3.11 typing/TYPE_CHECKING.TYPE_CHECKING.:
72 from . import APGatewayscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#
73
74
75 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log. = getLoggerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/getLogger().(__name__scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/)
76
77 VERSIONscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/VERSION. = unicodedatascip-python python python-stdlib 3.11 unicodedata/__init__:.normalizescip-python python python-stdlib 3.11 unicodedata/normalize().(
78 "NFKD", f"{Cscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#.APP_NAMEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#APP_NAME.} ActivityPub Gateway {Cscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#.APP_VERSIONscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#APP_VERSION.}"
79 )
80
81
82 class HTTPAPGServerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#(web_resource.Resource):
83 """HTTP Server handling ActivityPub S2S protocol"""
84
85 isLeafscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#isLeaf. = True
86
87 def __init__scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#__init__().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#__init__().(self), ap_gatewayscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#__init__().(ap_gateway): "APGatewayscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#"):
88 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#__init__().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg. = ap_gatewayscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#__init__().(ap_gateway)
89 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#__init__().(self)._seen_digestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_seen_digest. = dequescip-python python python-stdlib 3.11 collections/deque#(maxlen=50)
90 superscip-python python python-stdlib 3.11 builtins/super#().__init__()
91
92 def response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
93 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#", http_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(http_code): intscip-python python python-stdlib 3.11 builtins/int#, msgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(msg): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#] = None
94 ) -> None:
95 """Log and set HTTP return code and associated message"""
96 if msgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(msg) is not None:
97 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(msgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(msg))
98 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(request).setResponseCode(http_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(http_code), None if msgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(msg) is None else msgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(msg).encodescip-python python python-stdlib 3.11 builtins/str#encode().())
99
100 def _on_request_errorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(
101 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(self), failure_scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(failure_): failurescip-python python Twisted 26.4.0 `twisted.python.failure`/__init__:.Failure, requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#"
102 ) -> None:
103 exc = failure_scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(failure_).value
104 if isinstance(exc, exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.NotFoundscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/NotFound#):
105 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(request), httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.NOT_FOUND, strscip-python python python-stdlib 3.11 builtins/str#(exc))
106 else:
107 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..exceptionscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#exception().(f"Internal error: {failure_scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(failure_).value}")
108 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
109 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(request), httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.INTERNAL_SERVER_ERROR, f"internal error: {failure_scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(failure_).value}"
110 )
111 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(request).finish()
112 raise failure_scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(failure_)
113
114 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(request).finish()
115
116 async def webfingerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(request)):
117 url_parsed = parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlparse(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(request).uri.decode())
118 query = parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.parse_qs(url_parsed.query)
119 resource = query.getscip-python python python-stdlib 3.11 builtins/dict#get().("resource", [""])[0]
120 account = resource[5:].stripscip-python python python-stdlib 3.11 builtins/str#strip().()
121 if not resource.startswithscip-python python python-stdlib 3.11 builtins/str#startswith().("acct:") or not account:
122 return web_resource.ErrorPage(
123 httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.BAD_REQUEST, "Bad Request", "Invalid webfinger resource"
124 ).render(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(request))
125
126 actor_url = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_ACTORscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ACTOR., account)
127
128 resp = {
129 "aliases": [actor_url],
130 "subject": resource,
131 "links": [
132 {"rel": "self", "type": "application/activity+json", "href": actor_url}
133 ],
134 }
135 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(request).setHeader("content-type", CONTENT_TYPE_WEBFINGERscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/CONTENT_TYPE_WEBFINGER.)
136 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(request).write(jsonscip-python python python-stdlib 3.11 json/__init__:.dumpsscip-python python python-stdlib 3.11 json/dumps().(resp).encodescip-python python python-stdlib 3.11 builtins/str#encode().())
137 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(request).finish()
138
139 async def handle_undo_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(
140 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self),
141 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
142 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
143 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
144 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
145 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
146 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(ap_account): strscip-python python python-stdlib 3.11 builtins/str#,
147 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
148 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
149 ) -> None:
150 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(node) is None:
151 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
152 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(signing_actor))
153 object_ = datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(data).getscip-python python python-stdlib 3.11 builtins/dict#get().("object")
154 if isinstance(object_, strscip-python python python-stdlib 3.11 builtins/str#):
155 # we check first if it's not a cached object
156 ap_cache_key = f"{ST_AP_CACHEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ST_AP_CACHE.}{object_}"
157 value = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.._ap_storage.get(ap_cache_key)
158 else:
159 value = None
160 if value is not None:
161 objects = [value]
162 # because we'll undo the activity, we can remove it from cache
163 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.._ap_storage.remove(ap_cache_key)
164 else:
165 objects = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_listscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_list().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(requestor_actor_id), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(data), "object")
166 for obj in objects:
167 type_ = obj.getscip-python python python-stdlib 3.11 builtins/dict#get().("type")
168 actor = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_sender_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_sender_actor().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(requestor_actor_id), obj)
169 if actor != signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(signing_actor):
170 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"ignoring object not attributed to signing actor: {datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(data)}")
171 continue
172
173 if type_ == "Follow":
174 try:
175 target_account = obj["object"]
176 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
177 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f'ignoring invalid object, missing "object" key: {datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(data)}')
178 continue
179 if not selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_local_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_local_url().(target_account):
180 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"ignoring unfollow request to non local actor: {datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(data)}")
181 continue
182 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_p..unsubscribe(
183 client,
184 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(account_jid),
185 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(node),
186 sender=client.jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#jid.,
187 )
188 elif type_ == "Announce":
189 # we can use directly the Announce object, as only the "id" field is
190 # needed
191 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..new_ap_delete_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#new_ap_delete_item().(client, None, nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(node), obj)
192 elif type_ == TYPE_LIKEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_LIKE.:
193 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client, obj, {"noticed": False})
194 elif type_ == TYPE_REACTIONscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_REACTION.:
195 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_undo_activity().(self).handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(
196 client,
197 obj,
198 {"reactions": {"operation": "update", "remove": [obj["content"]]}},
199 )
200 else:
201 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"Unmanaged undo type: {type_!r}")
202
203 async def handle_follow_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(
204 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self),
205 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
206 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
207 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
208 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
209 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
210 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(ap_account): strscip-python python python-stdlib 3.11 builtins/str#,
211 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
212 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
213 ) -> None:
214 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(node) is None:
215 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
216 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(signing_actor))
217 try:
218 subscription = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_p..subscribe(
219 client,
220 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(account_jid),
221 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(node),
222 # subscriptions from AP are always public
223 options=selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._ppsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_pps..set_public_opt(),
224 )
225 except pubsubscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.pubsub`/__init__:.SubscriptionPending:
226 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..infoscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#info().(f"subscription to node {nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(node)!r} of {account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(account_jid)} is pending")
227 # TODO: manage SubscriptionUnconfigured
228 else:
229 if subscription.state != "subscribed":
230 # other states should raise an Exception
231 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.InternalErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/InternalError#('"subscribed" state was expected')
232 inbox = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_ap_inbox_from_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_ap_inbox_from_id().(signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(signing_actor), use_sharedscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_ap_inbox_from_id().(use_shared)=False)
233 actor_id = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_ACTORscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ACTOR., ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(ap_account))
234 accept_data = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..create_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#create_activity().("Accept", actor_id, object_scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#create_activity().(object_)=datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(data))
235 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..sign_and_post(inbox, actor_id, accept_data)
236 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._cscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_c..synchronise(client, account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_follow_activity().(node), resync=False)
237
238 async def handle_accept_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(
239 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(self),
240 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
241 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
242 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
243 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
244 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
245 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(ap_account): strscip-python python python-stdlib 3.11 builtins/str#,
246 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
247 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
248 ) -> None:
249 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node) is None:
250 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
251 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(signing_actor))
252 objects = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_listscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_list().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(requestor_actor_id), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(data), "object")
253 for obj in objects:
254 type_ = obj.getscip-python python python-stdlib 3.11 builtins/dict#get().("type")
255 if type_ == "Follow":
256 follow_node = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..hostscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#host..memory.storage.get_pubsub_node(
257 client, client.jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#jid., nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node), with_subscriptions=True
258 )
259 if follow_node is None:
260 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(
261 f"Received a follow accept on an unknown node: {nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node)!r} at "
262 f"{client.jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#jid.}. Ignoring it"
263 )
264 continue
265 try:
266 sub = nextscip-python python python-stdlib 3.11 builtins/next().(
267 s
268 for s in follow_node.subscriptions
269 if s.subscriber == account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(account_jid)
270 )
271 except StopIterationscip-python python python-stdlib 3.11 builtins/StopIteration#:
272 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(
273 "Received a follow accept on a node without subscription: "
274 f"{nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node)!r} at {client.jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#jid.}. Ignoring it"
275 )
276 else:
277 if sub.state == SubscriptionStatescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#.SUBSCRIBEDscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#SUBSCRIBED.:
278 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"Already subscribed to {nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(node)!r} at {client.jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#jid.}")
279 elif sub.state == SubscriptionStatescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#.PENDINGscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#PENDING.:
280 follow_node.subscribed = True
281 sub.state = SubscriptionStatescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#.SUBSCRIBEDscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#SUBSCRIBED.
282 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_accept_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..hostscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#host..memory.storage.add(follow_node)
283 else:
284 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.InternalErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/InternalError#(
285 f"Unhandled subscription state {sub.state!r}"
286 )
287 else:
288 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"Unmanaged accept type: {type_!r}")
289
290 async def handle_delete_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(
291 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(self),
292 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
293 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
294 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
295 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
296 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
297 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
298 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
299 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
300 ):
301 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(node) is None:
302 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
303 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(signing_actor))
304 objects = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_listscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_list().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(requestor_actor_id), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(data), "object")
305 for obj in objects:
306 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..new_ap_delete_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#new_ap_delete_item().(client, account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_delete_activity().(node), obj)
307
308 async def handle_new_ap_itemsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(
309 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self),
310 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
311 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
312 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
313 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
314 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
315 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
316 repeatedscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(repeated): boolscip-python python python-stdlib 3.11 builtins/bool# = False,
317 ):
318 """Helper method to handle workflow for new AP items
319
320 accept globally the same parameter as for handle_create_activity
321 @param repeated: if True, the item is an item republished from somewhere else
322 """
323 if "_repeated" in datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(data):
324 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..errorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#error().(
325 '"_repeated" field already present in given AP item, this should not '
326 f"happen. Ignoring object from {signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(signing_actor)}\n{datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(data)}"
327 )
328 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#("unexpected field in item")
329 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(signing_actor))
330 objects = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_listscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_list().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(requestor_actor_id), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(data), "object")
331 for obj in objects:
332 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(node) is None:
333 if obj.getscip-python python python-stdlib 3.11 builtins/dict#get().("type") == TYPE_EVENTscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_EVENT.:
334 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._eventsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_events..namespace
335 else:
336 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
337 sender = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_sender_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_sender_actor().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(requestor_actor_id), obj)
338 if repeatedscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(repeated):
339 # we don't check sender when item is repeated, as it should be different
340 # from post author in this case
341 sender_jid = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_jid_from_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_jid_from_id().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(requestor_actor_id), sender)
342 repeater_jid = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_jid_from_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_jid_from_id().(
343 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(signing_actor)
344 )
345 repeated_item_id = obj["id"]
346 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_local_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_local_url().(repeated_item_id):
347 # the repeated object is from XMPP, we need to parse the URL to find
348 # the right ID
349 url_type, url_args = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..parse_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#parse_apurl().(repeated_item_id)
350 if url_type != "item":
351 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#(
352 "local URI is not an item: {repeated_id}"
353 )
354 try:
355 url_account, url_item_id = url_args
356 if not url_account or not url_item_id:
357 raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#
358 except (RuntimeErrorscip-python python python-stdlib 3.11 builtins/RuntimeError#, ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#):
359 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#("local URI is invalid: {repeated_id}")
360 else:
361 url_jid, url_node = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_jid_and_node().(url_account)
362 if (
363 url_jid != sender_jid
364 or url_node
365 and url_node != selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
366 ):
367 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#(
368 "announced ID doesn't match sender ({sender}): "
369 f"[repeated_item_id]"
370 )
371
372 repeated_item_id = url_item_id
373
374 obj["_repeated"] = {
375 "by": repeater_jid.full(),
376 "at": datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(data).getscip-python python python-stdlib 3.11 builtins/dict#get().("published"),
377 "uri": uriscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common.uri`/__init__:.build_xmpp_uriscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common.uri`/build_xmpp_uri().(
378 "pubsub",
379 path=sender_jid.full(),
380 node=selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.,
381 item=repeated_item_id,
382 ),
383 }
384 # we must use activity's id and targets, not the original item ones
385 for field in ("id", "to", "bto", "cc", "bcc"):
386 obj[field] = datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(data).getscip-python python python-stdlib 3.11 builtins/dict#get().(field)
387 else:
388 if sender != signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(signing_actor):
389 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().("Ignoring object not attributed to signing actor: {obj}")
390 continue
391
392 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..new_ap_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#new_ap_item().(client, account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(node), obj)
393
394 async def handle_create_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(
395 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(self),
396 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
397 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
398 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
399 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
400 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
401 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
402 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
403 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
404 ):
405 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(self).handle_new_ap_itemsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(
406 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(requestor_actor_id), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(request), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(data), account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(node), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_create_activity().(signing_actor)
407 )
408
409 async def handle_update_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(
410 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(self),
411 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
412 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
413 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
414 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
415 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
416 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
417 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
418 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
419 ):
420 # Update is the same as create: the item ID stays the same, thus the item will be
421 # overwritten
422 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(self).handle_new_ap_itemsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(
423 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(requestor_actor_id), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(request), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(data), account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(node), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_update_activity().(signing_actor)
424 )
425
426 async def handle_announce_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(
427 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(self),
428 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
429 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
430 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
431 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
432 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
433 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
434 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
435 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
436 ):
437 # we create a new item
438 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(self).handle_new_ap_itemsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(
439 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(requestor_actor_id),
440 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(request),
441 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(data),
442 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(account_jid),
443 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(node),
444 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_announce_activity().(signing_actor),
445 repeatedscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_new_ap_items().(repeated)=True,
446 )
447
448 async def handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(
449 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self), clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client): SatXMPPEntityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#, datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(data): dictscip-python python python-stdlib 3.11 builtins/dict#, attachment_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(attachment_data): dictscip-python python python-stdlib 3.11 builtins/dict#
450 ) -> None:
451 target_ids = datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(data).getscip-python python python-stdlib 3.11 builtins/dict#get().("object")
452 if not target_ids:
453 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#("object should be set")
454 elif isinstance(target_ids, listscip-python python python-stdlib 3.11 builtins/list#):
455 try:
456 target_ids = [o["id"] for o in target_ids]
457 except (KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#, TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#):
458 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#(f"invalid object: {target_ids!r}")
459 elif isinstance(target_ids, dictscip-python python python-stdlib 3.11 builtins/dict#):
460 obj_id = target_ids.getscip-python python python-stdlib 3.11 builtins/dict#get().("id")
461 if not obj_id or not isinstance(obj_id, strscip-python python python-stdlib 3.11 builtins/str#):
462 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#(f"invalid object: {target_ids!r}")
463 target_ids = [obj_id]
464 elif isinstance(target_ids, strscip-python python python-stdlib 3.11 builtins/str#):
465 target_ids = [target_ids]
466
467 # XXX: we have to cache AP items because some implementation (Pleroma notably)
468 # don't keep object accessible, and we need to be able to retrieve them for
469 # UNDO. Current implementation will grow, we need to add a way to flush it after
470 # a while.
471 # TODO: add a way to flush old cached AP items.
472 await clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client)._ap_storage.aset(f"{ST_AP_CACHEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ST_AP_CACHE.}{datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(data)['id']}", datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(data))
473
474 for target_id in target_ids:
475 if not selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_local_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_local_url().(target_id):
476 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..debugscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#debug().(f"ignoring non local target ID: {target_id}")
477 continue
478 url_type, url_args = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..parse_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#parse_apurl().(target_id)
479 if url_type != TYPE_ITEMscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ITEM.:
480 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"unexpected local URL for attachment on item {target_id}")
481 continue
482 try:
483 account, item_id = url_args
484 except ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#:
485 raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#(f"invalid URL: {target_id}")
486 author_jid, item_node = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_jid_and_node().(account)
487 if item_node is None:
488 item_node = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
489 attachment_node = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_pa..get_attachment_node_name(
490 author_jid, item_node, item_id
491 )
492 cached_node = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..hostscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#host..memory.storage.get_pubsub_node(
493 clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client), author_jid, attachment_node, with_subscriptions=True, create=True
494 )
495 found_items, __ = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..hostscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#host..memory.storage.get_items(
496 cached_node, item_ids=[clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client).jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.core_types`/SatXMPPEntity#jid..userhost()]
497 )
498 if not found_items:
499 old_item_elt = None
500 else:
501 found_item = found_items[0]
502 old_item_elt = found_item.data
503
504 item_elt = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_pa..apply_set_handler(
505 clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client), {"extra": attachment_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(attachment_data)}, old_item_elt, None
506 )
507 # we reparse the element, as there can be other attachments
508 attachments_data = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_pa..items_2_attachment_data(clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client), [item_elt])
509 # and we update the cache
510 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..hostscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#host..memory.storage.cache_pubsub_items(
511 clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client), cached_node, [item_elt], attachments_data or [{}]
512 )
513
514 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_virtual_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_virtual_jid().(author_jid):
515 # the attachment is on t a virtual pubsub service (linking to an AP item),
516 # we notify all subscribers
517 for subscription in cached_node.subscriptions:
518 if subscription.state != SubscriptionStatescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#.SUBSCRIBEDscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.memory.sqla_mapping`/SubscriptionState#SUBSCRIBED.:
519 continue
520 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..pubsub_servicescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#pubsub_service..notifyPublish(
521 author_jid,
522 attachment_node,
523 [(subscription.subscriber, None, [item_elt])],
524 )
525 else:
526 # the attachment is on an XMPP item, we publish it to the attachment node
527 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_p..send_items(
528 clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client), author_jid, attachment_node, [item_elt]
529 )
530
531 async def handle_like_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(
532 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(self),
533 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
534 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
535 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
536 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
537 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
538 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
539 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
540 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
541 ) -> None:
542 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(signing_actor))
543 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(self).handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client, datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_like_activity().(data), {"noticed": True})
544
545 async def handle_emojireact_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(
546 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(self),
547 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
548 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
549 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
550 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
551 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
552 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
553 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
554 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
555 ) -> None:
556 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(signing_actor))
557 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(self).handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(
558 client, datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(data), {"reactions": {"operation": "update", "add": [datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_emojireact_activity().(data)["content"]]}}
559 )
560
561 async def handle_join_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(
562 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(self),
563 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
564 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
565 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
566 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
567 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
568 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
569 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
570 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
571 ) -> None:
572 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(signing_actor))
573 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(self).handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client, datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_join_activity().(data), {"rsvp": {"attending": "yes"}})
574
575 async def handle_leave_activityscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(
576 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(self),
577 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
578 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
579 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(data): dictscip-python python python-stdlib 3.11 builtins/dict#,
580 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
581 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
582 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
583 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
584 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#,
585 ) -> None:
586 client = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_virtual_clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_virtual_client().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(requestor_actor_id), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(signing_actor))
587 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(self).handle_attachment_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_attachment_item().(client, datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#handle_leave_activity().(data), {"rsvp": {"attending": "no"}})
588
589 async def ap_actor_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(
590 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self),
591 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
592 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#],
593 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
594 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
595 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_account): strscip-python python python-stdlib 3.11 builtins/str#,
596 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
597 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(signing_actor): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
598 ) -> dictscip-python python python-stdlib 3.11 builtins/dict#:
599 inbox = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_INBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_INBOX., ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_account))
600 shared_inbox = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_SHARED_INBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_SHARED_INBOX.)
601 outbox = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_OUTBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_OUTBOX., ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_account))
602 followers = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_FOLLOWERSscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_FOLLOWERS., ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_account))
603 following = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_FOLLOWINGscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_FOLLOWING., ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_account))
604
605 # we have to use AP account as preferredUsername because it is used to retrieve
606 # actor handle (see https://socialhub.activitypub.rocks/t/how-to-retrieve-user-server-tld-handle-from-actors-url/2196)
607 preferred_username = ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_account).splitscip-python python python-stdlib 3.11 builtins/str#split().("@", 1)[0]
608
609 identity_data = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._iscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_i..get_identity(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client., account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(account_jid))
610 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(node) and nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(node).startswithscip-python python python-stdlib 3.11 builtins/str#startswith().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._eventsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_events..namespace):
611 events = outbox
612 else:
613 events_account = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_ap_account_from_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_ap_account_from_jid_and_node().(
614 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(account_jid), selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._eventsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_events..namespace
615 )
616 events = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_OUTBOXscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_OUTBOX., events_account)
617
618 actor_data = {
619 "@context": [
620 "https://www.w3.org/ns/activitystreams",
621 "https://w3id.org/security/v1",
622 ],
623 # XXX: Mastodon doesn't like percent-encode arobas, so we have to unescape it
624 # if it is escaped
625 "id": ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_url).replacescip-python python python-stdlib 3.11 builtins/str#replace().("%40", "@"),
626 "type": "Person",
627 "preferredUsername": preferred_username,
628 "inbox": inbox,
629 "outbox": outbox,
630 "events": events,
631 "followers": followers,
632 "following": following,
633 "publicKey": {
634 "id": f"{ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_url)}#main-key",
635 "owner": ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(ap_url),
636 "publicKeyPem": selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..public_key_pemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#public_key_pem.,
637 },
638 "endpoints": {
639 "sharedInbox": shared_inbox,
640 "events": events,
641 },
642 }
643
644 if identity_data.get("nicknames"):
645 actor_data["name"] = identity_data["nicknames"][0]
646 if identity_data.get("description"):
647 # description is plain text while summary expects HTML
648 actor_data["summary"] = htmlscip-python python python-stdlib 3.11 html/__init__:.escapescip-python python python-stdlib 3.11 html/escape().(identity_data["description"])
649 if identity_data.get("avatar"):
650 avatar_data = identity_data["avatar"]
651 try:
652 filename = avatar_data["filename"]
653 media_type = avatar_data["media_type"]
654 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
655 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..errorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#error().(f"incomplete avatar data: {identity_data!r}")
656 else:
657 avatar_url = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_actor_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().("avatar", filename)
658 actor_data["icon"] = {
659 "type": "Image",
660 "url": avatar_url,
661 "mediaType": media_type,
662 }
663
664 return actor_data
665
666 def get_canonical_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#") -> strscip-python python python-stdlib 3.11 builtins/str#:
667 return parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urljoin(
668 f"https://{selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..public_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#public_url.}",
669 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(request).path.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().().rstripscip-python python python-stdlib 3.11 builtins/str#rstrip().("/"),
670 # we unescape "@" for the same reason as in [ap_actor_request]
671 ).replacescip-python python python-stdlib 3.11 builtins/str#replace().("%40", "@")
672
673 def query_data_2_rsm_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(
674 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(self), query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(query_data): Dictscip-python python python-stdlib 3.11 typing/Dict.[strscip-python python python-stdlib 3.11 builtins/str#, Listscip-python python python-stdlib 3.11 typing/List.[strscip-python python python-stdlib 3.11 builtins/str#]]
675 ) -> rsmscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.rsm`/__init__:.RSMRequest:
676 """Get RSM kwargs to use with RSMRequest from query data"""
677 page = query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(query_data).getscip-python python python-stdlib 3.11 builtins/dict#get().("page")
678
679 if page == ["first"]:
680 return rsmscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.rsm`/__init__:.RSMRequest(max_=PAGE_SIZEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/PAGE_SIZE., before="")
681 elif page == ["last"]:
682 return rsmscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.rsm`/__init__:.RSMRequest(max_=PAGE_SIZEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/PAGE_SIZE.)
683 else:
684 for query_key in ("index", "before", "after"):
685 try:
686 kwargs = {query_key: query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(query_data)[query_key][0], "max_": PAGE_SIZEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/PAGE_SIZE.}
687 except (KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#, IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#, ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#):
688 pass
689 else:
690 return rsmscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.rsm`/__init__:.RSMRequest(**kwargs)
691 raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#(f"Invalid query data: {query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(query_data)!r}")
692
693 async def ap_outbox_page_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(
694 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self),
695 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
696 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#],
697 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
698 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
699 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(ap_account): strscip-python python python-stdlib 3.11 builtins/str#,
700 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
701 query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(query_data): Dictscip-python python python-stdlib 3.11 typing/Dict.[strscip-python python python-stdlib 3.11 builtins/str#, Listscip-python python python-stdlib 3.11 typing/List.[strscip-python python python-stdlib 3.11 builtins/str#]],
702 ) -> dictscip-python python python-stdlib 3.11 builtins/dict#:
703 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node) is None:
704 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
705 # we only keep useful keys, and sort to have consistent URL which can
706 # be used as ID
707 url_keys = sortedscip-python python python-stdlib 3.11 builtins/sorted().(setscip-python python python-stdlib 3.11 builtins/set#(query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(query_data)) & {"page", "index", "before", "after"})
708 query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(query_data) = {k: query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(query_data)[k] for k in url_keys}
709 try:
710 items, metadata = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_p..get_items(
711 client=selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.,
712 service=account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(account_jid),
713 node=nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node),
714 rsm_request=selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).query_data_2_rsm_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#query_data_2_rsm_request().(query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(query_data)),
715 extra={Cscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#.KEY_USE_CACHEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#KEY_USE_CACHE.: False},
716 )
717 except errorscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.error`/__init__:.StanzaError as e:
718 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"Can't get data from pubsub node {nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node)} at {account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(account_jid)}: {e}")
719 return {}
720
721 base_url = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).get_canonical_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(request))
722 url = f"{base_url}?{parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlencode(query_datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(query_data), True)}"
723 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node) and nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node).startswithscip-python python python-stdlib 3.11 builtins/str#startswith().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._eventsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_events..namespace):
724 ordered_items = [
725 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_eventsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_events..event_data_2_ap_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.events`/APEvents#event_data_2_ap_item().(
726 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._eventsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_events..event_elt_2_event_data(item), account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(account_jid)
727 )
728 for item in reversedscip-python python python-stdlib 3.11 builtins/reversed#(items)
729 ]
730 else:
731 ordered_items = [
732 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..mb_data_2_ap_itemscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#mb_data_2_ap_item().(
733 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.,
734 await MbDatascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/MbData#.from_elementscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/MbData#from_element().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client., item, account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(node)),
735 )
736 for item in reversedscip-python python python-stdlib 3.11 builtins/reversed#(items)
737 ]
738 ret_data = {
739 "@context": ["https://www.w3.org/ns/activitystreams"],
740 "id": url,
741 "type": "OrderedCollectionPage",
742 "partOf": base_url,
743 "orderedItems": ordered_items,
744 }
745
746 if "rsm" not in metadata:
747 # no RSM available, we return what we have
748 return ret_data
749
750 # AP OrderedCollection must be in reversed chronological order, thus the opposite
751 # of what we get with RSM (at least with Libervia Pubsub)
752 if not metadata["complete"]:
753 try:
754 last = metadata["rsm"]["last"]
755 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
756 last = None
757 ret_data["prev"] = f"{base_url}?{parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlencode({'after': last})}"
758 if metadata["rsm"]["index"] != 0:
759 try:
760 first = metadata["rsm"]["first"]
761 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
762 first = None
763 ret_data["next"] = f"{base_url}?{parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlencode({'before': first})}"
764
765 return ret_data
766
767 async def ap_outbox_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(
768 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(self),
769 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
770 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#],
771 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
772 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
773 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(ap_account): strscip-python python python-stdlib 3.11 builtins/str#,
774 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
775 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(signing_actor): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
776 ) -> dictscip-python python python-stdlib 3.11 builtins/dict#:
777 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node) is None:
778 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
779
780 parsed_url = parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlparse(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(request).uri.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().())
781 query_data = parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.parse_qs(parsed_url.query)
782 if query_data:
783 return await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(self).ap_outbox_page_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_page_request().(
784 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(request), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(data), account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node), ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(ap_account), ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(ap_url), query_data
785 )
786
787 # XXX: we can't use disco#info here because this request won't work on a bare jid
788 # due to security considerations of XEP-0030 (we don't have presence
789 # subscription).
790 # The current workaround is to do a request as if RSM was available, and actually
791 # check its availability according to result.
792 try:
793 __, metadata = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._pscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_p..get_items(
794 client=selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.,
795 service=account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(account_jid),
796 node=nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node),
797 max_items=0,
798 rsm_request=rsmscip-python python libervia-backend 0.9.0.dev0 `tx_xmpp.rsm`/__init__:.RSMRequest(max_=0),
799 extra={Cscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#.KEY_USE_CACHEscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.constants`/Const#KEY_USE_CACHE.: False},
800 )
801 except errorscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.error`/__init__:.StanzaError as e:
802 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"Can't get data from pubsub node {nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node)} at {account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(account_jid)}: {e}")
803 return {}
804 try:
805 items_count = metadata["rsm"]["count"]
806 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
807 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(
808 f"No RSM metadata found when requesting pubsub node {nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(node)} at "
809 f"{account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(account_jid)}, defaulting to items_count=20"
810 )
811 items_count = 20
812
813 url = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(self).get_canonical_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_outbox_request().(request))
814 url_first_page = f"{url}?{parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlencode({'page': 'first'})}"
815 url_last_page = f"{url}?{parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlencode({'page': 'last'})}"
816 return {
817 "@context": ["https://www.w3.org/ns/activitystreams"],
818 "id": url,
819 "totalItems": items_count,
820 "type": "OrderedCollection",
821 "first": url_first_page,
822 "last": url_last_page,
823 }
824
825 async def ap_inbox_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(
826 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(self),
827 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#,
828 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
829 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#],
830 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(account_jid): Optionalscip-python python python-stdlib 3.11 typing/Optional.[jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID],
831 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
832 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
833 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
834 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(signing_actor): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
835 ) -> None:
836 assert datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(data) is not None
837 if signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(signing_actor) is None:
838 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.InternalErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/InternalError#("signing_actor must be set for inbox requests")
839 await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(self).check_signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(requestor_actor_id), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(data), signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(signing_actor))
840 activity_type = (datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(data).getscip-python python python-stdlib 3.11 builtins/dict#get().("type") or "").lowerscip-python python python-stdlib 3.11 builtins/str#lower().()
841 if not activity_type in ACTIVITY_TYPES_LOWERscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ACTIVITY_TYPES_LOWER.:
842 return selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
843 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(request),
844 httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.UNSUPPORTED_MEDIA_TYPE,
845 f"request is not an activity, ignoring",
846 )
847
848 if account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(account_jid) is None and activity_type not in ACTIVIY_NO_ACCOUNT_ALLOWEDscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/ACTIVIY_NO_ACCOUNT_ALLOWED.:
849 return selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
850 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(request),
851 httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.UNSUPPORTED_MEDIA_TYPE,
852 f"{activity_type.titlescip-python python python-stdlib 3.11 builtins/str#title().()!r} activity must target an account",
853 )
854
855 try:
856 method = getattrscip-python python python-stdlib 3.11 builtins/getattr().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(self), f"handle_{activity_type}_activity")
857 except AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#:
858 return selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
859 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(request),
860 httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.UNSUPPORTED_MEDIA_TYPE,
861 f"{activity_type.titlescip-python python python-stdlib 3.11 builtins/str#title().()} activity is not yet supported",
862 )
863 else:
864 await method(
865 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(requestor_actor_id),
866 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(request),
867 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(data),
868 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(account_jid),
869 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(node),
870 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(ap_account),
871 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(ap_url),
872 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(signing_actor),
873 )
874
875 async def ap_followers_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(
876 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self),
877 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
878 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#],
879 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
880 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
881 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
882 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
883 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(signing_actor): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
884 ) -> dictscip-python python python-stdlib 3.11 builtins/dict#:
885 if nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(node) is None:
886 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(node) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
887 client = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.
888 subscribers = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._ppsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_pps..get_public_node_subscriptions(
889 client, account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(node)
890 )
891 followers = []
892 for subscriber in subscribers.keys():
893 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_virtual_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_virtual_jid().(subscriber):
894 # the subscriber is an AP user subscribed with this gateway
895 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(ap_account) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._escip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_e..unescape(subscriber.user)
896 else:
897 # regular XMPP user
898 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(ap_account) = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_ap_account_from_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_ap_account_from_jid_and_node().(
899 subscriber, nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(node)
900 )
901 followers.appendscip-python python python-stdlib 3.11 builtins/list#append().(ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(ap_account))
902
903 url = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(self).get_canonical_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_followers_request().(request))
904 return {
905 "@context": ["https://www.w3.org/ns/activitystreams"],
906 "type": "OrderedCollection",
907 "id": url,
908 "totalItems": len(subscribers),
909 "first": {
910 "type": "OrderedCollectionPage",
911 "id": url,
912 "orderedItems": followers,
913 },
914 }
915
916 async def ap_following_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(
917 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self),
918 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
919 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#],
920 account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(account_jid): jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID,
921 nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(node): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
922 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(ap_account): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
923 ap_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(ap_url): strscip-python python python-stdlib 3.11 builtins/str#,
924 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(signing_actor): Optionalscip-python python python-stdlib 3.11 typing/Optional.[strscip-python python python-stdlib 3.11 builtins/str#],
925 ) -> dictscip-python python python-stdlib 3.11 builtins/dict#[strscip-python python python-stdlib 3.11 builtins/str#, Anyscip-python python python-stdlib 3.11 typing/Any.]:
926 client = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..clientscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#client.
927 subscriptions = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._ppsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_pps..subscriptions(client, account_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(account_jid), nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(node))
928 following = []
929 for sub_dict in subscriptions:
930 service = jidscip-python python Twisted 26.4.0 `twisted.words.protocols.jabber.jid`/__init__:.JID(sub_dict["service"])
931 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_virtual_jidscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_virtual_jid().(service):
932 # the subscription is to an AP actor with this gateway
933 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(ap_account) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._escip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_e..unescape(service.user)
934 else:
935 # regular XMPP user
936 ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(ap_account) = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_ap_account_from_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_ap_account_from_jid_and_node().(
937 service, sub_dict["node"]
938 )
939 following.appendscip-python python python-stdlib 3.11 builtins/list#append().(ap_accountscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(ap_account))
940
941 url = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(self).get_canonical_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_canonical_url().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_following_request().(request))
942 return {
943 "@context": ["https://www.w3.org/ns/activitystreams"],
944 "type": "OrderedCollection",
945 "id": url,
946 "totalItems": len(subscriptions),
947 "first": {
948 "type": "OrderedCollectionPage",
949 "id": url,
950 "orderedItems": following,
951 },
952 }
953
954 def _get_to_logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(
955 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(self),
956 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
957 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(data): Optionalscip-python python python-stdlib 3.11 typing/Optional.[dictscip-python python python-stdlib 3.11 builtins/dict#] = None,
958 ) -> Listscip-python python python-stdlib 3.11 typing/List.[strscip-python python python-stdlib 3.11 builtins/str#]:
959 """Get base data to logs in verbose mode"""
960 from pprintscip-python python python-stdlib 3.11 pprint/__init__: import pformatscip-python python python-stdlib 3.11 pprint/pformat().
961
962 to_log = [
963 "",
964 f"<<< got {requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(request).method.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().()} request - {requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(request).uri.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().()}",
965 ]
966 if datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(data) is not None:
967 to_log.appendscip-python python python-stdlib 3.11 builtins/list#append().(pformatscip-python python python-stdlib 3.11 pprint/pformat().(datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(data)))
968 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..verbosescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#verbose. >= 3:
969 headers = "\n".joinscip-python python python-stdlib 3.11 builtins/str#join().(
970 f" {k.decode()}: {v.decode()}"
971 for k, v in requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(request).getAllHeaders().itemsscip-python python python-stdlib 3.11 builtins/dict#items().()
972 )
973 to_log.appendscip-python python python-stdlib 3.11 builtins/list#append().(f" headers:\n{headers}")
974 return to_log
975
976 def get_requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(
977 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(data): dictscip-python python python-stdlib 3.11 builtins/dict# | None = None, uri_extra_argsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(uri_extra_args): listscip-python python python-stdlib 3.11 builtins/list#[strscip-python python python-stdlib 3.11 builtins/str#] | None = None
978 ) -> strscip-python python python-stdlib 3.11 builtins/str#:
979 """Find the actor ID of the requestor.
980
981 The requestor here is actually the local actor which will do the requests to
982 achieve the task (e.g. retrieve external actor data), not the requestor of the
983 received AP request.
984
985 It will notably be used as requestor actor ID to sign HTTP requests. We need to
986 sign GET request too to access instance checking HTTP GET signature (e.g. Mastodon
987 instances set in "secure mode").
988
989 We look for the destinee of the request and check if it's a local actor, and
990 default to a generic one if we can't find it.
991
992 Destinee is first checked in data if any, otherwise in request URI.
993
994 @param data: parsed JSON data of original AP request, if any.
995 @param uri_extra_args: arguments of the AP request as returned by
996 [self.apg.parse_apurl]. It is most of time the destinee of the request.
997 @return: requestor_actor_id to use to sign HTTP request needed to answer the
998 original request.
999 """
1000 # We first check for destinee in data.
1001 if datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(data):
1002 try:
1003 for to_ in datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(data)["to"]:
1004 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..is_local_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#is_local_url().(to_):
1005 url_type, url_args = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..parse_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#parse_apurl().(to_)
1006 if url_type != TYPE_ACTORscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ACTOR. or not url_args:
1007 continue
1008 ap_account = url_args[0]
1009 if (
1010 not ap_account.endswithscip-python python python-stdlib 3.11 builtins/str#endswith().(f"@{selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..public_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#public_url.}")
1011 or ap_account.countscip-python python python-stdlib 3.11 builtins/str#count().("@") != 1
1012 ):
1013 continue
1014 return to_
1015 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
1016 pass
1017
1018 # If nothing relevant, we try URI arguments.
1019 if uri_extra_argsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(uri_extra_args):
1020 ap_account = uri_extra_argsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(uri_extra_args)[0]
1021 if (
1022 ap_account.endswithscip-python python python-stdlib 3.11 builtins/str#endswith().(f"@{selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..public_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#public_url.}")
1023 and ap_account.countscip-python python python-stdlib 3.11 builtins/str#count().("@") == 1
1024 ):
1025 return selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_ACTORscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ACTOR., ap_account)
1026
1027 # Still nothing, we'll have to use a generic actor.
1028 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(
1029 'Can\'t find destinee in "to" field, using generic requestor for signature.'
1030 )
1031 return selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..build_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#build_apurl().(TYPE_ACTORscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/TYPE_ACTOR., f"libervia@{selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..public_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#public_url.}")
1032
1033 async def ap_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(
1034 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self),
1035 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#",
1036 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(data): dictscip-python python python-stdlib 3.11 builtins/dict# | None = None,
1037 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str# | None = None,
1038 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str# | None = None,
1039 ) -> None:
1040 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..verbosescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#verbose.:
1041 to_log = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self)._get_to_logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(data))
1042
1043 path = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).path.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().()
1044 ap_url = parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urljoin(f"https://{selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..public_urlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#public_url.}", path)
1045 request_type, extra_args = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..parse_apurlscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#parse_apurl().(ap_url)
1046
1047 header_accept = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).getHeader("accept") or ""
1048 if (
1049 MEDIA_TYPE_APscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/MEDIA_TYPE_AP. not in header_accept
1050 and MEDIA_TYPE_AP_ALTscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/MEDIA_TYPE_AP_ALT. not in header_accept
1051 and request_type in selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..html_redirectscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#html_redirect.
1052 ):
1053 # this is not a AP request, and we have a redirections for it
1054 kw = {}
1055 if extra_args:
1056 kw["jid"], kw["node"] = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_jid_and_node().(extra_args[0])
1057 kw["jid_user"] = kw["jid"].user
1058 if kw["node"] is None:
1059 kw["node"] = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg.._mscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#_m..namespacescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_xep_0277`/XEP_0277#namespace.
1060 if len(extra_args) > 1:
1061 kw["item"] = extra_args[1]
1062 else:
1063 kw["item"] = ""
1064 else:
1065 kw["jid"], kw["jid_user"], kw["node"], kw["item"] = "", "", "", ""
1066
1067 redirections = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..html_redirectscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#html_redirect.[request_type]
1068 for redirection in redirections:
1069 filters = redirection.filters
1070 if not filters:
1071 break
1072 # if we have filter, they must all match
1073 elif all(v in kw[k] for k, v in filters.items()):
1074 break
1075 else:
1076 # no redirection is matching
1077 redirection = None
1078
1079 if redirection is not None:
1080 kw = {k: parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.quote(strscip-python python python-stdlib 3.11 builtins/str#(v), safe="") for k, v in kw.itemsscip-python python python-stdlib 3.11 builtins/dict#items().()}
1081 target_url = redirection.url.format(**kw)
1082 content = web_util.redirectToscip-python python Twisted 26.4.0 `twisted.web._template_util`/redirectTo().(target_url.encode(), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request))
1083 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).write(content)
1084 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).finish()
1085 return
1086
1087 if requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestor_actor_id) is None:
1088 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestor_actor_id) = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).get_requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(data), extra_args)
1089 if len(extra_args) == 0:
1090 if request_type != "shared_inbox":
1091 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#(f"Invalid request type: {request_type!r}")
1092 ret_data = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).ap_inbox_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_inbox_request().(
1093 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestor_actor_id), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(data), None, None, None, ap_url, signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(signing_actor)
1094 )
1095 elif request_type == "avatar":
1096 if len(extra_args) != 1:
1097 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#("avatar argument expected in URL")
1098 avatar_filename = extra_args[0]
1099 avatar_path = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..hostscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#host..common_cache.get_path(avatar_filename)
1100 return staticscip-python python Twisted 26.4.0 `twisted.web.static`/__init__:.File(strscip-python python python-stdlib 3.11 builtins/str#(avatar_path)).render(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request))
1101 elif request_type == "item":
1102 ret_data = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_local_objectscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_local_object().(ap_url)
1103 if "@context" not in ret_data:
1104 ret_data["@context"] = [NS_APscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/NS_AP.]
1105 else:
1106 if len(extra_args) > 1:
1107 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"unexpected extra arguments: {extra_args!r}")
1108 ap_account = extra_args[0]
1109 account_jid, node = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_jid_and_nodescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_jid_and_node().(ap_account)
1110 if request_type not in AP_REQUEST_TYPESscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/AP_REQUEST_TYPES..getscip-python python python-stdlib 3.11 builtins/dict#get().(
1111 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).method.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().().upperscip-python python python-stdlib 3.11 builtins/str#upper().(), []
1112 ):
1113 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.DataErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/DataError#(f"Invalid request type: {request_type!r}")
1114 method = getattrscip-python python python-stdlib 3.11 builtins/getattr().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self), f"ap_{request_type}_request")
1115 ret_data = await method(
1116 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestor_actor_id),
1117 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request),
1118 datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(data),
1119 account_jid,
1120 node,
1121 ap_account,
1122 ap_url,
1123 signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(signing_actor),
1124 )
1125 if ret_data is not None:
1126 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).setHeader("content-type", CONTENT_TYPE_APscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/CONTENT_TYPE_AP.)
1127 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).write(jsonscip-python python python-stdlib 3.11 json/__init__:.dumpsscip-python python python-stdlib 3.11 json/dumps().(ret_data).encodescip-python python python-stdlib 3.11 builtins/str#encode().())
1128 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..verbosescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#verbose.:
1129 to_log.appendscip-python python python-stdlib 3.11 builtins/list#append().(f"--- RET (code: {requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).code})---")
1130 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..verbosescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#verbose. >= 2:
1131 if ret_data is not None:
1132 from pprintscip-python python python-stdlib 3.11 pprint/__init__: import pformatscip-python python python-stdlib 3.11 pprint/pformat().
1133
1134 to_log.appendscip-python python python-stdlib 3.11 builtins/list#append().(f"{pformatscip-python python python-stdlib 3.11 pprint/pformat().(ret_data)}")
1135 to_log.appendscip-python python python-stdlib 3.11 builtins/list#append().("---")
1136 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..infoscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#info().("\n".joinscip-python python python-stdlib 3.11 builtins/str#join().(to_log))
1137 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(request).finish()
1138
1139 async def ap_post_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#") -> None:
1140 try:
1141 data = jsonscip-python python python-stdlib 3.11 json/__init__:.loadscip-python python python-stdlib 3.11 json/load().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).content)
1142 if not isinstance(data, dictscip-python python python-stdlib 3.11 builtins/dict#):
1143 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(f"JSON data should be an object (uri={requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).uri.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().()})")
1144 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
1145 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request),
1146 httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.BAD_REQUEST,
1147 f"invalid body, was expecting a JSON object",
1148 )
1149 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).finish()
1150 return
1151 except (jsonscip-python python python-stdlib 3.11 json/__init__:.JSONDecodeErrorscip-python python libervia-backend 0.9.0.dev0 `json.decoder`/JSONDecodeError#, ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#) as e:
1152 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
1153 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request), httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.BAD_REQUEST, f"invalid json in inbox request: {e}"
1154 )
1155 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).finish()
1156 return
1157 else:
1158 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).content.seek(0)
1159
1160 requestor_actor_id = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).get_requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#get_requestor_actor_id().(data)
1161
1162 try:
1163 if data["type"] == "Delete" and data["actor"] == data["object"]:
1164 # we don't handle actor deletion
1165 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).setResponseCode(httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.ACCEPTED)
1166 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..debugscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#debug().(f"ignoring actor deletion ({data['actor']})")
1167 # TODO: clean data in cache coming from this actor, maybe with a tombstone
1168 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).finish()
1169 return
1170 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
1171 pass
1172
1173 try:
1174 signing_actor = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).check_signaturescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(requestor_actor_id, requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request))
1175 except exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError# as e:
1176 if selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..verbosescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#verbose.:
1177 to_log = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self)._get_to_logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_get_to_log().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request))
1178 to_log.appendscip-python python python-stdlib 3.11 builtins/list#append().(f" body: {requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).content.read()!r}")
1179 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).content.seek(0)
1180 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..infoscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#info().("\n".joinscip-python python python-stdlib 3.11 builtins/str#join().(to_log))
1181 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request), httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.FORBIDDEN, f"invalid signature: {e}")
1182 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).finish()
1183 return
1184 except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as e:
1185 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).response_codescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#response_code().(
1186 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request), httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.INTERNAL_SERVER_ERROR, f"Can't check signature: {e}"
1187 )
1188 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).finish()
1189 return
1190
1191 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).setResponseCode(httpscip-python python Twisted 26.4.0 `twisted.web.http`/__init__:.ACCEPTED)
1192
1193 digest = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).getHeader("digest")
1194 if digest in selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self)._seen_digestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_seen_digest.:
1195 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..debugscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#debug().(f"Ignoring duplicated request (digest: {digest!r})")
1196 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request).finish()
1197 return
1198 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self)._seen_digestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_seen_digest..appendscip-python python python-stdlib 3.11 collections/deque#append().(digest)
1199
1200 # default response code, may be changed, e.g. in case of exception
1201 try:
1202 return await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self).ap_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(
1203 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request), data, signing_actor, requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestor_actor_id)=requestor_actor_id
1204 )
1205 except Exceptionscip-python python python-stdlib 3.11 builtins/Exception# as e:
1206 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(self)._on_request_errorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error().(failurescip-python python Twisted 26.4.0 `twisted.python.failure`/__init__:.Failure(e), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(request))
1207
1208 async def check_signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(
1209 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(self), requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#, datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(data): dictscip-python python python-stdlib 3.11 builtins/dict#, signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(signing_actor): strscip-python python python-stdlib 3.11 builtins/str#
1210 ) -> None:
1211 """That that signing actor correspond to actor declared in data
1212
1213 @param requestor_actor_id: ID of the actor doing the request.
1214 @param data: request payload
1215 @param signing_actor: actor ID of the signing entity, as returned by
1216 check_signature
1217 @raise exceptions.NotFound: no actor found in data
1218 @raise exceptions.EncryptionError: signing actor doesn't match actor in data
1219 """
1220 actor = await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_get_sender_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_get_sender_actor().(requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(requestor_actor_id), datascip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(data))
1221
1222 if signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(signing_actor) != actor:
1223 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1224 f"signing actor ({signing_actorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signing_actor().(signing_actor)}) doesn't match actor in data ({actor})"
1225 )
1226
1227 async def check_signaturescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(
1228 selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(self), requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(requestor_actor_id): strscip-python python python-stdlib 3.11 builtins/str#, requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request): "HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#"
1229 ) -> strscip-python python python-stdlib 3.11 builtins/str#:
1230 """Check and validate HTTP signature
1231
1232 @param requestor_actor_id: ID of the actor doing the request.
1233 @return: id of the signing actor
1234
1235 @raise exceptions.EncryptionError: signature is not present or doesn't match
1236 """
1237 signature = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).getHeader("Signature")
1238 if signature is None:
1239 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#("No signature found")
1240 sign_data = {
1241 m["key"]: m["uq_value"] or m["quoted_value"][1:-1]
1242 for m in RE_SIG_PARAMscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.regex`/RE_SIG_PARAM..finditerscip-python python python-stdlib 3.11 re/Pattern#finditer().(signature)
1243 }
1244 try:
1245 key_id = sign_data["keyId"]
1246 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
1247 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#('"keyId" is missing from signature')
1248 algorithm = sign_data.getscip-python python python-stdlib 3.11 builtins/dict#get().("algorithm", HS2019scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/HS2019.)
1249 signed_headers = (
1250 sign_data.getscip-python python python-stdlib 3.11 builtins/dict#get().("headers", "(created)" if algorithm == HS2019scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/HS2019. else "date")
1251 .lowerscip-python python python-stdlib 3.11 builtins/str#lower().()
1252 .splitscip-python python python-stdlib 3.11 builtins/str#split().()
1253 )
1254 try:
1255 headers_to_check = SIGN_HEADERSscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/SIGN_HEADERS.[None] + SIGN_HEADERSscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/SIGN_HEADERS.[requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).method]
1256 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
1257 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.InternalErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/InternalError#(
1258 f"there should be a list of headers for {requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).method} method"
1259 )
1260 if not headers_to_check:
1261 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.InternalErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/InternalError#("headers_to_check must not be empty")
1262
1263 for header in headers_to_check:
1264 if isinstance(header, tuplescip-python python python-stdlib 3.11 builtins/tuple#):
1265 if len(setscip-python python python-stdlib 3.11 builtins/set#(header).intersectionscip-python python python-stdlib 3.11 builtins/set#intersection().(signed_headers)) == 0:
1266 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1267 f"at least one of following header must be signed: {header}"
1268 )
1269 elif header not in signed_headers:
1270 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(f"the {header!r} header must be signed")
1271
1272 body = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).content.read()
1273 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).content.seek(0)
1274 headers = {}
1275 for to_sign in signed_headers:
1276 if to_sign == "(request-target)":
1277 method = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).method.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().().lowerscip-python python python-stdlib 3.11 builtins/str#lower().()
1278 uri = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).uri.decodescip-python python python-stdlib 3.11 builtins/bytes#decode().()
1279 headers[to_sign] = f"{method} /{uri.lstripscip-python python python-stdlib 3.11 builtins/str#lstrip().('/')}"
1280 elif to_sign in ("(created)", "(expires)"):
1281 if algorithm != HS2019scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/HS2019.:
1282 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1283 f"{to_sign!r} pseudo-header can only be used with {HS2019scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/HS2019.} "
1284 "algorithm"
1285 )
1286 key = to_sign[1:-1]
1287 value = sign_data.getscip-python python python-stdlib 3.11 builtins/dict#get().(key)
1288 if not value:
1289 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1290 "{key!r} parameter is missing from signature"
1291 )
1292 try:
1293 if floatscip-python python python-stdlib 3.11 builtins/float#(value) < 0:
1294 raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#
1295 except ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#:
1296 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1297 f"{to_sign} must be a Unix timestamp"
1298 )
1299 headers[to_sign] = value
1300 else:
1301 value = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).getHeader(to_sign)
1302 if not value:
1303 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1304 f"value of header {to_sign!r} is missing!"
1305 )
1306 elif to_sign == "host":
1307 # we check Forwarded/X-Forwarded-Host headers
1308 # as we need original host if a proxy has modified the header
1309 forwarded = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).getHeader("forwarded")
1310 if forwarded is not None:
1311 try:
1312 host = [
1313 f[5:]
1314 for f in forwarded.splitscip-python python python-stdlib 3.11 builtins/str#split().(";")
1315 if f.startswithscip-python python python-stdlib 3.11 builtins/str#startswith().("host=")
1316 ][0] or None
1317 except IndexErrorscip-python python python-stdlib 3.11 builtins/IndexError#:
1318 host = None
1319 else:
1320 host = None
1321 if host is None:
1322 host = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(request).getHeader("x-forwarded-host")
1323 if host:
1324 value = host
1325 elif to_sign == "digest":
1326 hashes = {
1327 algo.lowerscip-python python python-stdlib 3.11 builtins/str#lower().(): hash_
1328 for algo, hash_ in (
1329 digest.splitscip-python python python-stdlib 3.11 builtins/str#split().("=", 1) for digest in value.splitscip-python python python-stdlib 3.11 builtins/str#split().(",")
1330 )
1331 }
1332 try:
1333 given_digest = hashes["sha-256"]
1334 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
1335 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1336 "Only SHA-256 algorithm is currently supported for digest"
1337 )
1338 __, computed_digest = selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..get_digestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#get_digest().(body)
1339 if given_digest != computed_digest:
1340 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#(
1341 f"SHA-256 given and computed digest differ:\n"
1342 f"given: {given_digest!r}\ncomputed: {computed_digest!r}"
1343 )
1344 headers[to_sign] = value
1345
1346 # date check
1347 limit_ts = timescip-python python python-stdlib 3.11 time/__init__:.timescip-python python python-stdlib 3.11 time/time().() + SIGN_EXPscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.constants`/SIGN_EXP.
1348 if "(created)" in headers:
1349 created = floatscip-python python python-stdlib 3.11 builtins/float#(headers["created"])
1350 else:
1351 created = date_utilsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common.date_utils`/__init__:.date_parsescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.tools.common.date_utils`/date_parse().(headers["date"])
1352
1353 try:
1354 expires = floatscip-python python python-stdlib 3.11 builtins/float#(headers["expires"])
1355 except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#:
1356 pass
1357 else:
1358 if expires < created:
1359 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..warningscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#warning().(
1360 f"(expires) [{expires}] set in the past of (created) [{created}] "
1361 "ignoring it according to specs"
1362 )
1363 else:
1364 limit_ts = minscip-python python python-stdlib 3.11 builtins/min().(limit_ts, expires)
1365
1366 if created > limit_ts:
1367 raise exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#("Signature has expired")
1368
1369 try:
1370 return await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..check_signaturescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#check_signature().(
1371 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(requestor_actor_id), sign_data["signature"], key_id, headers
1372 )
1373 except exceptionsscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/__init__:.EncryptionErrorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.exceptions`/EncryptionError#:
1374 method, url = headers["(request-target)"].rsplit(" ", 1)
1375 headers["(request-target)"] = f"{method} {parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.unquote(url)}"
1376 logscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/log..debugscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.core.log`/Logger#debug().(
1377 "Using workaround for (request-target) encoding bug in signature, "
1378 "see https://github.com/mastodon/mastodon/issues/18871"
1379 )
1380 return await selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..check_signaturescip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#check_signature().(
1381 requestor_actor_idscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#check_signature().(requestor_actor_id), sign_data["signature"], key_id, headers
1382 )
1383
1384 def renderscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render().(request)):
1385 requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render().(request).setHeader("server", VERSIONscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/VERSION.)
1386 return superscip-python python python-stdlib 3.11 builtins/super#().render(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render().(request))
1387
1388 def render_GETscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(request)):
1389 path = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(request).path.decode().lstrip("/")
1390 if path.startswith(".well-known/webfinger"):
1391 deferscip-python python Twisted 26.4.0 `twisted.internet.defer`/__init__:.ensureDeferred(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(self).webfingerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#webfinger().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(request)))
1392 return serverscip-python python Twisted 26.4.0 `twisted.web.server`/__init__:.NOT_DONE_YET
1393 elif path.startswith(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_pathscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_path.):
1394 d = deferscip-python python Twisted 26.4.0 `twisted.internet.defer`/__init__:.ensureDeferred(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(self).ap_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_request().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(request)))
1395 d.addErrback(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(self)._on_request_errorscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#_on_request_error()., requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(request))
1396 return serverscip-python python Twisted 26.4.0 `twisted.web.server`/__init__:.NOT_DONE_YET
1397
1398 return web_resource.NoResource().render(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_GET().(request))
1399
1400 def render_POSTscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(self), requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(request)):
1401 path = requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(request).path.decode().lstrip("/")
1402 if not path.startswith(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(self).apgscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#apg..ap_pathscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway`/APGateway#ap_path.):
1403 return web_resource.NoResource().render(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(request))
1404 deferscip-python python Twisted 26.4.0 `twisted.internet.defer`/__init__:.ensureDeferred(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(self).ap_post_requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#ap_post_request().(requestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#render_POST().(request)))
1405 return serverscip-python python Twisted 26.4.0 `twisted.web.server`/__init__:.NOT_DONE_YET
1406
1407
1408 class HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#(serverscip-python python Twisted 26.4.0 `twisted.web.server`/__init__:.Request):
1409 pass
1410
1411
1412 class HTTPServerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPServer#(serverscip-python python Twisted 26.4.0 `twisted.web.server`/__init__:.Site):
1413 requestFactoryscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPServer#requestFactory. = HTTPRequestscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPRequest#
1414
1415 def __init__scip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPServer#__init__().(selfscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPServer#__init__().(self), ap_gatewayscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPServer#__init__().(ap_gateway)):
1416 superscip-python python python-stdlib 3.11 builtins/super#().__init__(HTTPAPGServerscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPAPGServer#(ap_gatewayscip-python python libervia-backend 0.9.0.dev0 `libervia.backend.plugins.plugin_comp_ap_gateway.http_server`/HTTPServer#__init__().(ap_gateway)))