Mercurial > libervia-backend
diff sat/plugins/plugin_comp_ap_gateway/http_server.py @ 3833:381340b9a9ee
component AP gateway: convert XMPP mentions to AP:
When a XEP-0372 mention is received, the linked pubsub item is looked after in cache, and
if found, it is send to mentioned entity with `mention` tag added.
However, this doesn't work in some cases (see incoming doc for details). To work around
that, `@user@server.tld` type mention are also scanned in body, and mentions are added
when found (this can be disabled with `auto_mentions` setting).
Mention are only scanned in "public" messages, i.e. for pubsub items, and not direct
messages.
rel 369
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 10 Jul 2022 16:15:06 +0200 |
parents | 81c79b7cafa7 |
children | 65e5718e7710 |
line wrap: on
line diff
--- a/sat/plugins/plugin_comp_ap_gateway/http_server.py Sun Jul 10 15:16:15 2022 +0200 +++ b/sat/plugins/plugin_comp_ap_gateway/http_server.py Sun Jul 10 16:15:06 2022 +0200 @@ -23,13 +23,11 @@ from urllib import parse from collections import deque import unicodedata -from pathlib import Path -from pprint import pformat from twisted.web import http, resource as web_resource, server from twisted.web import static from twisted.python import failure -from twisted.internet import reactor, defer +from twisted.internet import defer from twisted.words.protocols.jabber import jid, error from wokkel import pubsub, rsm @@ -37,7 +35,6 @@ from sat.core.constants import Const as C from sat.core.i18n import _ from sat.core.log import getLogger -from sat.tools import utils from sat.tools.common import date_utils from sat.memory.sqla_mapping import SubscriptionState @@ -73,7 +70,8 @@ msg: Optional[str] = None ) -> None: """Log and set HTTP return code and associated message""" - log.warning(msg) + if msg is not None: + log.warning(msg) request.setResponseCode(http_code, None if msg is None else msg.encode()) def _onRequestError(self, failure_: failure.Failure, request: "HTTPRequest") -> None: @@ -683,7 +681,7 @@ return # default response code, may be changed, e.g. in case of exception - self.responseCode(request, http.ACCEPTED) + request.setResponseCode(http.ACCEPTED) try: return await self.APRequest(request, signing_actor) except Exception as e: