core: Replace legacy INI config system with Pydantic-based TOML configuration.
This is a huge configuration refactoring. The configuration system now uses Pydantic settings, with better validation, better support for environment variables and other goodies. The main config files now use TOML instead of INI, this allow for better handling of complex types, notably dict. Plugins, components and frontends can declare their config settings in a class which will be imported dynamically.
This commit is contained in:
parent
f3f40848b3
commit
6a7b7bc36a
22 changed files with 1392 additions and 1011 deletions
|
|
@ -54,14 +54,14 @@ override:
|
|||
PEERTUBE_WEBSERVER_HOSTNAME: !libervia_conf ["application peertube", "hostname"]
|
||||
PEERTUBE_TRUST_PROXY: '["127.0.0.1", "loopback", "172.18.0.0/16"]'
|
||||
PEERTUBE_SECRET: !libervia_generate_pwd {name: secret}
|
||||
PEERTUBE_SMTP_HOSTNAME: !libervia_conf ["", "email_server"]
|
||||
PEERTUBE_SMTP_USERNAME: !libervia_conf ["", "email_username"]
|
||||
PEERTUBE_SMTP_PASSWORD: !libervia_conf ["", "email_password"]
|
||||
PEERTUBE_SMTP_DISABLE_STARTTLS: !libervia_conf ["", "email_starttls", "false", "not"]
|
||||
PEERTUBE_SMTP_PORT: !libervia_conf ["", "email_port"]
|
||||
PEERTUBE_SMTP_HOSTNAME: !libervia_conf ["email", "server"]
|
||||
PEERTUBE_SMTP_USERNAME: !libervia_conf ["email", "username"]
|
||||
PEERTUBE_SMTP_PASSWORD: !libervia_conf ["email", "password"]
|
||||
PEERTUBE_SMTP_DISABLE_STARTTLS: !libervia_conf ["email", "starttls", "false", "not"]
|
||||
PEERTUBE_SMTP_PORT: !libervia_conf ["email", "port"]
|
||||
PEERTUBE_SMTP_FROM: !libervia_conf ["application peertube", "email_from", "peertube@example.com"]
|
||||
PEERTUBE_SMTP_TLS: "false"
|
||||
PEERTUBE_ADMIN_EMAIL: !libervia_conf ["", "email_admins_list", "", "first"]
|
||||
PEERTUBE_ADMIN_EMAIL: !libervia_conf ["common", "email_admins_list", "", "first"]
|
||||
PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PUBLIC: "public-read"
|
||||
PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PRIVATE: "private"
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ override:
|
|||
WEBLATE_DEFAULT_FROM_EMAIL: !libervia_conf ["application weblate", "email_from", "weblate@example.com"]
|
||||
WEBLATE_SITE_DOMAIN: !libervia_conf ["application weblate", "public_url"]
|
||||
WEBLATE_ADMIN_PASSWORD: !libervia_generate_pwd {name: admin}
|
||||
WEBLATE_ADMIN_EMAIL: !libervia_conf ["", "email_admins_list", "", "first"]
|
||||
WEBLATE_ADMIN_EMAIL: !libervia_conf ["common", "email_admins_list", "", "first"]
|
||||
WEBLATE_ENABLE_HTTPS: !libervia_conf ["application weblate", "enable_https", "1"]
|
||||
volumes:
|
||||
- ./settings-override.py:/app/data/settings-override.py:ro
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ from twisted.words.protocols.jabber import error, jid
|
|||
from twisted.words.xish import domish
|
||||
from wokkel import pubsub, rsm
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.core_types import SatXMPPEntity
|
||||
|
|
@ -66,14 +67,15 @@ from libervia.backend.tools.common import data_format, tls, uri
|
|||
from libervia.backend.tools.common.async_utils import async_lru
|
||||
|
||||
from .ad_hoc import APAdHocService
|
||||
from .events import APEvents
|
||||
# We import PLUGIN_INFO as it's needed for the plugin, and we put it in .constants because
|
||||
# it's necessary to create the ComponentSettings subclass.
|
||||
from .constants import PLUGIN_INFO
|
||||
from .constants import (
|
||||
ACTIVITY_OBJECT_MANDATORY,
|
||||
ACTIVITY_TARGET_MANDATORY,
|
||||
ACTIVITY_TYPES,
|
||||
ACTIVITY_TYPES_LOWER,
|
||||
COMMENTS_MAX_PARENTS,
|
||||
CONF_SECTION,
|
||||
IMPORT_NAME,
|
||||
LRU_MAX_SIZE,
|
||||
MEDIA_TYPE_AP,
|
||||
|
|
@ -84,55 +86,23 @@ from .constants import (
|
|||
TYPE_EVENT,
|
||||
TYPE_FOLLOWERS,
|
||||
TYPE_ITEM,
|
||||
TYPE_JOIN,
|
||||
TYPE_LEAVE,
|
||||
TYPE_LIKE,
|
||||
TYPE_MENTION,
|
||||
TYPE_REACTION,
|
||||
TYPE_TOMBSTONE,
|
||||
TYPE_JOIN,
|
||||
TYPE_LEAVE,
|
||||
)
|
||||
from .events import APEvents
|
||||
from .http_server import HTTPServer
|
||||
from .pubsub_service import APPubsubService
|
||||
from .regex import RE_MENTION
|
||||
|
||||
from .settings import APGatewaySettings
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
IMPORT_NAME = "ap-gateway"
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: "ActivityPub Gateway component",
|
||||
C.PI_IMPORT_NAME: IMPORT_NAME,
|
||||
C.PI_MODES: [C.PLUG_MODE_COMPONENT],
|
||||
C.PI_TYPE: C.PLUG_TYPE_ENTRY_POINT,
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: [
|
||||
"XEP-0050",
|
||||
"XEP-0054",
|
||||
"XEP-0060",
|
||||
"XEP-0084",
|
||||
"XEP-0106",
|
||||
"XEP-0277",
|
||||
"XEP-0292",
|
||||
"XEP-0329",
|
||||
"XEP-0372",
|
||||
"XEP-0424",
|
||||
"XEP-0465",
|
||||
"XEP-0470",
|
||||
"XEP-0447",
|
||||
"XEP-0471",
|
||||
"PUBSUB_CACHE",
|
||||
"TEXT_SYNTAXES",
|
||||
"IDENTITY",
|
||||
],
|
||||
C.PI_RECOMMENDATIONS: [],
|
||||
C.PI_MAIN: "APGateway",
|
||||
C.PI_HANDLER: C.BOOL_TRUE,
|
||||
C.PI_DESCRIPTION: _(
|
||||
"Gateway for bidirectional communication between XMPP and ActivityPub."
|
||||
),
|
||||
}
|
||||
|
||||
HEXA_ENC = r"(?P<hex>[0-9a-fA-f]{2})"
|
||||
RE_PERIOD_ENC = re.compile(f"\\.{HEXA_ENC}")
|
||||
RE_PERCENT_ENC = re.compile(f"%{HEXA_ENC}")
|
||||
|
|
@ -181,6 +151,7 @@ class APGateway:
|
|||
self.pubsub_service = APPubsubService(self)
|
||||
self.ad_hoc = APAdHocService(self)
|
||||
self.ap_events = APEvents(self)
|
||||
self.html_redirect: HTMLRedirectDict = {}
|
||||
host.trigger.add_with_check(
|
||||
"message_received", self, self._message_received_trigger, priority=-1000
|
||||
)
|
||||
|
|
@ -242,14 +213,19 @@ class APGateway:
|
|||
|
||||
# params
|
||||
# URL and port
|
||||
self.public_url = self.host.memory.config_get(
|
||||
CONF_SECTION, "public_url"
|
||||
) or self.host.memory.config_get(CONF_SECTION, "xmpp_domain")
|
||||
# Get component settings
|
||||
ap_settings = G.config.get_settings(APGatewaySettings)
|
||||
|
||||
self.public_url = (
|
||||
ap_settings.public_url
|
||||
or ap_settings.xmpp_domain
|
||||
or G.config.common.xmpp_domain
|
||||
)
|
||||
if self.public_url is None:
|
||||
log.error(
|
||||
'"public_url" not set in configuration, this is mandatory to have'
|
||||
"ActivityPub Gateway running. Please set this option it to public facing "
|
||||
f"url in {CONF_SECTION!r} configuration section."
|
||||
f"url in {IMPORT_NAME!r} configuration section."
|
||||
)
|
||||
return
|
||||
if parse.urlparse(self.public_url).scheme:
|
||||
|
|
@ -258,65 +234,34 @@ class APGateway:
|
|||
'"public_url" configuration option. ActivityPub Gateway won\'t be run.'
|
||||
)
|
||||
return
|
||||
self.http_port = int(self.host.memory.config_get(CONF_SECTION, "http_port", 8123))
|
||||
connection_type = self.host.memory.config_get(
|
||||
CONF_SECTION, "http_connection_type", "https"
|
||||
)
|
||||
self.http_port = ap_settings.http_port
|
||||
connection_type = ap_settings.http_connection_type
|
||||
if connection_type not in ("http", "https"):
|
||||
raise exceptions.ConfigError(
|
||||
'bad ap-gateay http_connection_type, you must use one of "http" or '
|
||||
'"https"'
|
||||
)
|
||||
self.http_sign_get = C.bool(
|
||||
self.host.memory.config_get(CONF_SECTION, "http_sign_get", C.BOOL_TRUE)
|
||||
)
|
||||
self.max_items = int(
|
||||
self.host.memory.config_get(CONF_SECTION, "new_node_max_items", 50)
|
||||
)
|
||||
self.comments_max_depth = int(
|
||||
self.host.memory.config_get(CONF_SECTION, "comments_max_depth", 0)
|
||||
)
|
||||
self.ap_path = self.host.memory.config_get(CONF_SECTION, "ap_path", "_ap")
|
||||
self.http_sign_get = ap_settings.http_sign_get
|
||||
self.max_items = ap_settings.new_node_max_items
|
||||
self.comments_max_depth = ap_settings.comments_max_depth
|
||||
self.ap_path = ap_settings.ap_path
|
||||
self.base_ap_url = parse.urljoin(f"https://{self.public_url}", f"{self.ap_path}/")
|
||||
# True (default) if we provide gateway only to entities/services from our server
|
||||
self.local_only = C.bool(
|
||||
self.host.memory.config_get(CONF_SECTION, "local_only", C.BOOL_TRUE)
|
||||
)
|
||||
self.local_only = ap_settings.local_only
|
||||
# if True (default), mention will be parsed in non-private content coming from
|
||||
# XMPP. This is necessary as XEP-0372 are coming separately from item where the
|
||||
# mention is done, which is hard to impossible to translate to ActivityPub (where
|
||||
# mention specified inside the item directly). See documentation for details.
|
||||
self.auto_mentions = C.bool(
|
||||
self.host.memory.config_get(CONF_SECTION, "auto_mentions", C.BOOL_TRUE)
|
||||
)
|
||||
self.auto_mentions = ap_settings.auto_mentions
|
||||
|
||||
html_redirect: Dict[str, Union[str, dict]] = self.host.memory.config_get(
|
||||
CONF_SECTION, "html_redirect_dict", {}
|
||||
)
|
||||
self.html_redirect: Dict[str, List[dict]] = {}
|
||||
for url_type, target in html_redirect.items():
|
||||
if isinstance(target, str):
|
||||
target = {"url": target}
|
||||
elif not isinstance(target, dict):
|
||||
raise exceptions.ConfigError(
|
||||
f"html_redirect target must be a URL or a dict, not {target!r}"
|
||||
)
|
||||
filters = target.setdefault("filters", {})
|
||||
if "url" not in target:
|
||||
log.warning(f"invalid HTML redirection, missing target URL: {target}")
|
||||
continue
|
||||
# a slash in the url_type is a syntactic shortcut to have a node filter
|
||||
if "/" in url_type:
|
||||
url_type, node_filter = url_type.split("/", 1)
|
||||
filters["node"] = node_filter
|
||||
self.html_redirect.setdefault(url_type, []).append(target)
|
||||
self.html_redirect = ap_settings.html_redirect
|
||||
|
||||
# HTTP server launch
|
||||
self.server = HTTPServer(self)
|
||||
if connection_type == "http":
|
||||
reactor.listenTCP(self.http_port, self.server)
|
||||
else:
|
||||
options = tls.get_options_from_config(self.host.memory.config, CONF_SECTION)
|
||||
options = tls.get_options_from_config(ap_settings.tls)
|
||||
tls.tls_options_check(options)
|
||||
context_factory = tls.get_tls_context_factory(options)
|
||||
reactor.listenSSL(self.http_port, self.server, context_factory)
|
||||
|
|
@ -1596,8 +1541,10 @@ class APGateway:
|
|||
elif start_index > 5000:
|
||||
raise error.StanzaError(
|
||||
"feature-not-implemented",
|
||||
text="Maximum limit for previous_index has been reached, this limit"
|
||||
"is set to avoid DoS",
|
||||
text=(
|
||||
"Maximum limit for previous_index has been reached, this limit"
|
||||
"is set to avoid DoS"
|
||||
),
|
||||
)
|
||||
else:
|
||||
# we'll convert "start_index" to "after_id", thus we need the item just
|
||||
|
|
@ -1972,7 +1919,7 @@ class APGateway:
|
|||
except StopIteration:
|
||||
# no item corresponding to this author, we use ap_account
|
||||
log.warning(
|
||||
"Can't find a single cached item for parent item " f"{parent_item!r}"
|
||||
f"Can't find a single cached item for parent item {parent_item!r}"
|
||||
)
|
||||
parent_ap_account = ap_account
|
||||
else:
|
||||
|
|
@ -2419,7 +2366,7 @@ class APGateway:
|
|||
if parsed_anchor["type"] != "pubsub":
|
||||
log.warning(
|
||||
f"ignoring reference with non pubsub anchor, this is not supported: "
|
||||
"{reference_data!r}"
|
||||
f"{{reference_data!r}}"
|
||||
)
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,10 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
|
||||
IMPORT_NAME = "ap-gateway"
|
||||
CONF_SECTION = f"component {IMPORT_NAME}"
|
||||
CONTENT_TYPE_WEBFINGER = "application/jrd+json; charset=utf-8"
|
||||
CONTENT_TYPE_AP = "application/activity+json; charset=utf-8"
|
||||
TYPE_ACTOR = "actor"
|
||||
|
|
@ -129,3 +131,36 @@ MAX_AVATAR_SIZE = 1024 * 1024 * 5
|
|||
# storage prefixes
|
||||
ST_AVATAR = "[avatar]"
|
||||
ST_AP_CACHE = "[AP_item_cache]"
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: "ActivityPub Gateway component",
|
||||
C.PI_IMPORT_NAME: IMPORT_NAME,
|
||||
C.PI_MODES: [C.PLUG_MODE_COMPONENT],
|
||||
C.PI_TYPE: C.PLUG_TYPE_ENTRY_POINT,
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: [
|
||||
"XEP-0050",
|
||||
"XEP-0054",
|
||||
"XEP-0060",
|
||||
"XEP-0084",
|
||||
"XEP-0106",
|
||||
"XEP-0277",
|
||||
"XEP-0292",
|
||||
"XEP-0329",
|
||||
"XEP-0372",
|
||||
"XEP-0424",
|
||||
"XEP-0465",
|
||||
"XEP-0470",
|
||||
"XEP-0447",
|
||||
"XEP-0471",
|
||||
"PUBSUB_CACHE",
|
||||
"TEXT_SYNTAXES",
|
||||
"IDENTITY",
|
||||
],
|
||||
C.PI_RECOMMENDATIONS: [],
|
||||
C.PI_MAIN: "APGateway",
|
||||
C.PI_HANDLER: C.BOOL_TRUE,
|
||||
C.PI_DESCRIPTION: _(
|
||||
"Gateway for bidirectional communication between XMPP and ActivityPub."
|
||||
),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import time
|
||||
import html
|
||||
from typing import Optional, Dict, List, Any
|
||||
from typing import TYPE_CHECKING, Optional, Dict, List, Any
|
||||
import json
|
||||
from urllib import parse
|
||||
from collections import deque
|
||||
|
|
@ -40,6 +40,9 @@ from libervia.backend.core.log import getLogger
|
|||
from libervia.backend.tools.common import date_utils, uri
|
||||
from libervia.backend.memory.sqla_mapping import SubscriptionState
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import APGateway
|
||||
|
||||
from .constants import (
|
||||
NS_AP,
|
||||
MEDIA_TYPE_AP,
|
||||
|
|
@ -80,7 +83,7 @@ class HTTPAPGServer(web_resource.Resource):
|
|||
|
||||
isLeaf = True
|
||||
|
||||
def __init__(self, ap_gateway):
|
||||
def __init__(self, ap_gateway: "APGateway"):
|
||||
self.apg = ap_gateway
|
||||
self._seen_digest = deque(maxlen=50)
|
||||
super().__init__()
|
||||
|
|
@ -1064,7 +1067,7 @@ class HTTPAPGServer(web_resource.Resource):
|
|||
|
||||
redirections = self.apg.html_redirect[request_type]
|
||||
for redirection in redirections:
|
||||
filters = redirection["filters"]
|
||||
filters = redirection.filters
|
||||
if not filters:
|
||||
break
|
||||
# if we have filter, they must all match
|
||||
|
|
@ -1076,7 +1079,7 @@ class HTTPAPGServer(web_resource.Resource):
|
|||
|
||||
if redirection is not None:
|
||||
kw = {k: parse.quote(str(v), safe="") for k, v in kw.items()}
|
||||
target_url = redirection["url"].format(**kw)
|
||||
target_url = redirection.url.format(**kw)
|
||||
content = web_util.redirectTo(target_url.encode(), request)
|
||||
request.write(content)
|
||||
request.finish()
|
||||
|
|
|
|||
226
libervia/backend/plugins/plugin_comp_ap_gateway/settings.py
Normal file
226
libervia/backend/plugins/plugin_comp_ap_gateway/settings.py
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# Libervia ActivityPub Gateway
|
||||
# Copyright (C) 2009-2025 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
|
||||
from libervia.backend.tools.config import ComponentSettings, TLSSettings
|
||||
|
||||
from .constants import PLUGIN_INFO
|
||||
|
||||
HTMLRedirectDict = dict[
|
||||
Literal["actor", "item", "followers", "following"], list["HTMLRedictData"]
|
||||
]
|
||||
|
||||
|
||||
class HTMLRedictData(BaseModel):
|
||||
|
||||
url: str = Field(description="Target URL for the redirect")
|
||||
filters: dict[Literal["jid", "jid_user", "node", "item"], str] = Field(
|
||||
default_factory=dict,
|
||||
description=("Filters to apply when matching redirection rules."),
|
||||
)
|
||||
|
||||
|
||||
class APGatewaySettings(ComponentSettings, plugin_info=PLUGIN_INFO):
|
||||
# HTTP server configuration
|
||||
http_port: int = Field(
|
||||
default=8123,
|
||||
description="""
|
||||
port where the HTTP server should listen. Port ``80`` is not used directly as it would
|
||||
require root privileges, and it is strongly recommended against launching Libervia
|
||||
under a privileged account. An HTTP Proxy or a port redirection should be set to
|
||||
redirect the ``80`` port to the port specified here.
|
||||
""",
|
||||
)
|
||||
http_connection_type: Literal["http", "https"] = Field(
|
||||
default="https",
|
||||
description="""
|
||||
either ``http`` or ``https``. If you have a HTTP proxy such as Apache or NGINX which
|
||||
already handles HTTPS, you may want to use ``http``.
|
||||
|
||||
Note that the HTTP server should always use ``https`` with end-user, the ``http``
|
||||
option is only to be used with an HTTPS proxy.
|
||||
""",
|
||||
)
|
||||
http_sign_get: bool = Field(
|
||||
default=True,
|
||||
description="""
|
||||
A boolean value indicating if HTTP ``GET`` request made to AP implementations must be
|
||||
signed. Some AP implementations require those requests to be signed, notably Mastodon
|
||||
when "secure mode" is activated.
|
||||
""",
|
||||
)
|
||||
|
||||
# TLS
|
||||
tls: TLSSettings | None = None
|
||||
|
||||
# ActivityPub configuration
|
||||
public_url: str | None = Field(
|
||||
default=None,
|
||||
description=""""
|
||||
Main user-facing domain of the HTTP server, this will be used to construct all AP URLs
|
||||
|
||||
**default**: if not set, ``xmpp_domain`` is used. If ``xmpp_domain`` is not set
|
||||
either, an error is raised.
|
||||
""",
|
||||
)
|
||||
xmpp_domain: str | None = Field(
|
||||
default=None, description="XMPP domain. Default to ``common.xmpp_domain``."
|
||||
)
|
||||
ap_path: str = Field(
|
||||
default="_ap",
|
||||
description="""
|
||||
Path prefix to use for ActivityPub request. It's usually not necessary to change the
|
||||
default value.
|
||||
""",
|
||||
)
|
||||
local_only: bool = Field(
|
||||
default=True,
|
||||
description="""
|
||||
A boolean value indicating if the gateway is allowed to convert pubsub node from
|
||||
external XMPP service or not. A JID is considered external if its domain part doesn't
|
||||
end with the gateway's server. For instance, if a gateway ``ap.example.org`` is set on
|
||||
the server ``example.org``, the JIDs ``pierre@example.org`` or
|
||||
``some-node@pubsub.example.org`` will be considered local, but
|
||||
``buenaventura@example.net`` won't (note the different domain).
|
||||
|
||||
Most of time, ``local_only`` should be used.
|
||||
""",
|
||||
)
|
||||
auto_mentions: bool = Field(
|
||||
default=True,
|
||||
description="""
|
||||
A boolean value indicating if received XMPP pubsub blog items bodies must be scanned
|
||||
to find ``@user@server.tld`` type mentions. If mentions are found, they'll be added to
|
||||
the resulting AP items.
|
||||
""",
|
||||
)
|
||||
|
||||
# PubSub configuration
|
||||
new_node_max_items: int = Field(
|
||||
default=50, description="Maximum items for new pubsub nodes"
|
||||
)
|
||||
comments_max_depth: int = Field(
|
||||
default=0,
|
||||
description="""
|
||||
An integer value indicating the maximum number of comment nodes that can be created.
|
||||
See :ref:`ap-xmpp-threads-conversion`
|
||||
""",
|
||||
)
|
||||
|
||||
# HTML redirection configuration
|
||||
html_redirect: HTMLRedirectDict = Field(
|
||||
default_factory=HTMLRedirectDict,
|
||||
description="""
|
||||
A dictionary used to redirect HTTP requests when it's not an ActivityPub request (i.e.
|
||||
when the ``Accept`` header is not set to ``application/json``). Several ActivityPub
|
||||
implementations link to original server when clicking on some links such as post
|
||||
author or item ID, and this result in a request to the corresponding ActivityPub
|
||||
endpoint, but made to retrieve HTML instead of ActivityPub JSON data.
|
||||
|
||||
By default, this request is showing the corresponding AP JSON data, but if you set
|
||||
HTML redirection, you can redirect the page to your XMPP client web frontend (or
|
||||
anything making sense), which results in better user experience.
|
||||
|
||||
The expected dictionary is a mapping URL request types to destination URL.
|
||||
|
||||
The URL request types is the first path element after ``ap_path``, it can be:
|
||||
|
||||
``actor``
|
||||
Actor information. It should link to the profile page of the corresponding XMPP
|
||||
entity
|
||||
|
||||
``item``
|
||||
A specific publication. It should link to the rendered item
|
||||
|
||||
``followers``
|
||||
Entities publicly subscribed to the actor. It is usually not used for redirection.
|
||||
|
||||
``following``
|
||||
Entities that the actor is publicly subscribed to. It is usually not used for
|
||||
redirection.
|
||||
|
||||
In the target URL you can uses template values in curly braces (something like
|
||||
``{item}``). The values that you can use are:
|
||||
|
||||
``jid``
|
||||
Full JID corresponding to the AP actor.
|
||||
|
||||
``jid_user``
|
||||
Only the user part of the JID (what is before the ``@``)
|
||||
|
||||
``node``
|
||||
Name of the pubsub node corresponding to the AP actor.
|
||||
|
||||
``item``
|
||||
ID of the XMPP pubsub item.
|
||||
|
||||
You can use a slash ``/`` followed by a part of a node name to filter only on specific
|
||||
nodes. For instance, if you want to redirect microblog items to a different URL that
|
||||
event items, you can use ``item/urn:xmpp:microblog:0`` and ``item/urn:xmpp:events:0``,
|
||||
the first redirection to match will be used. Note that anything containing the filter
|
||||
value will match, thus you can also use ``item/microblog`` (but it then would match an
|
||||
event which has ``microblog`` in is node name).
|
||||
|
||||
You can also use a dictionary as value instead of the target URL. This can be useful
|
||||
to filter on an other value than the node name, if you want to make specific
|
||||
redirection for a particular user for instance. If you use a dictionary, you must use
|
||||
a ``url`` key with the target URL (which may have template values as usual), and you
|
||||
may use a ``filters`` key mapping to an other dictionary where each key is a filter on
|
||||
a specific template value (in other words: key is the template value, like ``jid`` or
|
||||
``node``, and value is the filter to match).
|
||||
|
||||
*examples*
|
||||
|
||||
Redirect actor page to ``/profile/<JID user part>``, blogs items to ``/blog/<full
|
||||
JID>/<node name>/<item id>`` and events items to ``/event/<full JID>/<node name>/<item
|
||||
id>`` ::
|
||||
|
||||
[components.ap_gateway]
|
||||
html_redirect.actor = "/profile/{jid_user}"
|
||||
html_redirect.item = [
|
||||
{node="microblog", url="/blog/{jid}/{node}/{item}"},
|
||||
{node="events", url="/event/{jid}/{node}/{item}"},
|
||||
]
|
||||
|
||||
Redirect items of user ``louise@example.org`` to ``/b/<item>``::
|
||||
|
||||
[components.ap_gateway]
|
||||
html_redirect.item = {url = "/b/{item}", filters = { jid = "louise@example.org" }}
|
||||
""",
|
||||
)
|
||||
|
||||
@field_validator(
|
||||
"html_redirect",
|
||||
mode="before",
|
||||
json_schema_input_type=str | HTMLRedictData | list[HTMLRedictData],
|
||||
)
|
||||
@classmethod
|
||||
def html_redirect_parse_simple_syntax(cls, html_redirect: Any) -> Any:
|
||||
if isinstance(html_redirect, dict):
|
||||
for key, value in html_redirect.items():
|
||||
if isinstance(value, str):
|
||||
html_redirect[key] = [HTMLRedictData(url=value)]
|
||||
elif isinstance(value, HTMLRedictData):
|
||||
html_redirect[key] = [value]
|
||||
elif isinstance(value, dict):
|
||||
html_redirect[key] = [HTMLRedictData(**value)]
|
||||
return html_redirect
|
||||
|
|
@ -19,9 +19,11 @@
|
|||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Self
|
||||
from urllib.parse import quote
|
||||
|
||||
from autobahn.twisted.websocket import WebSocketClientFactory, WebSocketClientProtocol
|
||||
from pydantic import Field
|
||||
from shortuuid import uuid
|
||||
import treq
|
||||
from twisted.internet import defer, reactor
|
||||
|
|
@ -36,6 +38,7 @@ from twisted.words.xish import domish
|
|||
from wokkel import disco, iwokkel
|
||||
from zope.interface import implementer
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.core_types import SatXMPPEntity
|
||||
|
|
@ -47,7 +50,7 @@ from libervia.backend.plugins.plugin_xep_0167 import XEP_0167, mapping, NS_AV_CO
|
|||
from libervia.backend.plugins.plugin_xep_0176 import XEP_0176
|
||||
from libervia.backend.plugins.plugin_xep_0298 import XEP_0298
|
||||
from libervia.backend.tools.common import async_process, regex
|
||||
|
||||
from libervia.backend.tools.config import ComponentSettings, ExecutableFilePath
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
|
@ -70,7 +73,21 @@ PLUGIN_INFO = {
|
|||
),
|
||||
}
|
||||
|
||||
CONF_SECTION = f"component {IMPORT_NAME}"
|
||||
|
||||
class ConferenceSettings(ComponentSettings, plugin_info=PLUGIN_INFO):
|
||||
galene_path: ExecutableFilePath | None = Field(
|
||||
default_factory=lambda: ConferenceSettings._find_galene_exec()
|
||||
)
|
||||
http_port: int = Field(
|
||||
default=9443, description="Port to use for Galène HTTP server."
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _find_galene_exec() -> Path | None:
|
||||
try:
|
||||
return Path(which("galene")[0])
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
|
||||
class Conference:
|
||||
|
|
@ -386,21 +403,16 @@ class ConferencesComponent:
|
|||
self.client.identities.append(
|
||||
disco.DiscoIdentity("conference", "audio-video", NAME)
|
||||
)
|
||||
settings = G.config.get_settings(ConferenceSettings)
|
||||
galene_path = settings.galene_path
|
||||
|
||||
try:
|
||||
galene_path = Path(
|
||||
self.host.memory.config_get(CONF_SECTION, "galene_path")
|
||||
or which("galene")[0]
|
||||
)
|
||||
except IndexError:
|
||||
if galene_path is None:
|
||||
raise exceptions.NotFound(
|
||||
'Can\'t find "galene" executable, "conferences" component can\'t be '
|
||||
"started without it. Please install it in location accessible in PATH, "
|
||||
'or use "galene_path" setting.'
|
||||
f'Can\'t find "galene" executable, "PLUGIN_INFO[C.PI_NAME]" component'
|
||||
f" can't be started without it. Please install it in location accessible"
|
||||
f' in PATH, or use "galene_path" setting.'
|
||||
)
|
||||
self.galene_http_port = self.host.memory.config_get(
|
||||
CONF_SECTION, "http_port", "9443"
|
||||
)
|
||||
self.galene_http_port = settings.http_port
|
||||
galene_data_path = self.host.memory.get_cache_path(IMPORT_NAME, "galene")
|
||||
galene_static_path = galene_path.parent / "static"
|
||||
self.galene_group_path = galene_data_path / "groups"
|
||||
|
|
@ -460,7 +472,7 @@ class ConferencesComponent:
|
|||
}
|
||||
with data_file.open("w") as f:
|
||||
json.dump(group_data, f)
|
||||
log.debug(f"Conference data for {group_name!r} created at " f"{data_file} .")
|
||||
log.debug(f"Conference data for {group_name!r} created at {data_file} .")
|
||||
|
||||
url = f"http://localhost:{self.galene_http_port}/group/{quote(stem)}"
|
||||
status_url = f"{url}/.status"
|
||||
|
|
|
|||
|
|
@ -21,29 +21,33 @@ import os.path
|
|||
import mimetypes
|
||||
import tempfile
|
||||
from functools import partial
|
||||
from typing import Any
|
||||
from pydantic import Field, field_validator
|
||||
import shortuuid
|
||||
import unicodedata
|
||||
from urllib.parse import urljoin, urlparse, quote, unquote
|
||||
from pathlib import Path
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _, D_
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.log import getLogger
|
||||
from libervia.backend.tools import stream
|
||||
from libervia.backend.tools import video
|
||||
from libervia.backend.tools.config import ComponentSettings, ConfigOptions, TLSSettings
|
||||
from libervia.backend.tools.utils import ensure_deferred
|
||||
from libervia.backend.tools.common import regex
|
||||
from libervia.backend.tools.common import uri
|
||||
from libervia.backend.tools.common import files_utils
|
||||
from libervia.backend.tools.common import utils
|
||||
from libervia.backend.tools.common import tls
|
||||
from libervia.backend.models.types import JIDType
|
||||
from twisted.internet import defer, reactor
|
||||
from twisted.words.protocols.jabber import error
|
||||
from twisted.words.protocols.jabber import error, jid
|
||||
from twisted.web import server, resource, static, http
|
||||
from wokkel import pubsub
|
||||
from wokkel import generic
|
||||
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -85,6 +89,66 @@ OVER_QUOTA_TXT = D_(
|
|||
HTTP_VERSION = unicodedata.normalize("NFKD", f"{C.APP_NAME} file sharing {C.APP_VERSION}")
|
||||
|
||||
|
||||
class QuotasSettings(ConfigOptions):
|
||||
"""Configuration settings for file sharing quotas.
|
||||
|
||||
All quota values should be specified in bytes or using human-readable format
|
||||
like "100MB", "2GB", etc.
|
||||
"""
|
||||
|
||||
admins: int | None = Field(
|
||||
default=None,
|
||||
description="Quota for administrators. If no set, no limit applies.",
|
||||
)
|
||||
users: int | None = Field(
|
||||
default=None,
|
||||
description="Default quota for regular users. If not set, no limit applies.",
|
||||
)
|
||||
jids: dict[JIDType, int] = Field(
|
||||
default_factory=dict,
|
||||
description="Mapping of specific JIDs to their quotas.",
|
||||
)
|
||||
|
||||
@field_validator(
|
||||
"admins", "users", mode="before", json_schema_input_type=int | str | None
|
||||
)
|
||||
@classmethod
|
||||
def parse_quotas(cls, value: Any) -> Any:
|
||||
"""Parse string sizes to int"""
|
||||
if isinstance(value, str):
|
||||
return utils.parse_size(value)
|
||||
return value
|
||||
|
||||
@field_validator(
|
||||
"jids", mode="before", json_schema_input_type=dict[str, int | str]
|
||||
)
|
||||
@classmethod
|
||||
def parse_jid_quotas(cls, value: Any) -> Any:
|
||||
"""Parse string sizes to int for ``jids``."""
|
||||
if isinstance(value, dict):
|
||||
for k, v in value.items():
|
||||
if isinstance(v, str):
|
||||
value[k] = utils.parse_size(v)
|
||||
return value
|
||||
|
||||
|
||||
class FileSharingSettings(ComponentSettings, plugin_info=PLUGIN_INFO):
|
||||
public_url: str | None = Field(default=None, description="")
|
||||
http_upload_port: int = Field(default=8888, description="Port for HTTP file upload")
|
||||
http_upload_connection_type: str = Field(
|
||||
default="https", description="Connection type for HTTP upload (http or https)"
|
||||
)
|
||||
quotas: QuotasSettings = QuotasSettings()
|
||||
http_upload_allowed_hosts: list[str] = Field(
|
||||
default_factory=list,
|
||||
description=(
|
||||
"List of XMPP domain which can upload on this component. Default to"
|
||||
" component's host."
|
||||
),
|
||||
)
|
||||
tls: TLSSettings | None = None
|
||||
|
||||
|
||||
class HTTPFileServer(resource.Resource):
|
||||
isLeaf = True
|
||||
|
||||
|
|
@ -310,8 +374,9 @@ class FileSharingRequest(server.Request):
|
|||
|
||||
if upload_request.filename != filename:
|
||||
log.warning(
|
||||
f"invalid filename for PUT (upload id: {upload_id!r}, URL: {self.channel._path.decode()}). Original "
|
||||
f"{upload_request.filename!r} doesn't match {filename!r}"
|
||||
f"invalid filename for PUT (upload id: {upload_id!r}, URL:"
|
||||
f" {self.channel._path.decode()}). Original"
|
||||
f" {upload_request.filename!r} doesn't match {filename!r}"
|
||||
)
|
||||
return self.refuse_request()
|
||||
|
||||
|
|
@ -356,6 +421,7 @@ class FileSharing:
|
|||
if self.initialised:
|
||||
return
|
||||
self.initialised = True
|
||||
self.settings = G.config.get_settings(FileSharingSettings)
|
||||
log.info(_("File Sharing initialization"))
|
||||
self._f = self.host.plugins["FILE"]
|
||||
self._jf = self.host.plugins["XEP-0234"]
|
||||
|
|
@ -390,14 +456,8 @@ class FileSharing:
|
|||
"XEP-0329_parseResult_directory", self, self._get_directory_metadata_elts
|
||||
)
|
||||
self.files_path = self.host.get_local_path(None, C.FILES_DIR)
|
||||
self.http_port = int(
|
||||
self.host.memory.config_get(
|
||||
"component file-sharing", "http_upload_port", 8888
|
||||
)
|
||||
)
|
||||
connection_type = self.host.memory.config_get(
|
||||
"component file-sharing", "http_upload_connection_type", "https"
|
||||
)
|
||||
self.http_port = self.settings.http_upload_port
|
||||
connection_type = self.settings.http_upload_connection_type
|
||||
if connection_type not in ("http", "https"):
|
||||
raise exceptions.ConfigError(
|
||||
'bad http_upload_connection_type, you must use one of "http" or "https"'
|
||||
|
|
@ -407,9 +467,7 @@ class FileSharing:
|
|||
if connection_type == "http":
|
||||
reactor.listenTCP(self.http_port, self.server)
|
||||
else:
|
||||
options = tls.get_options_from_config(
|
||||
self.host.memory.config, "component file-sharing"
|
||||
)
|
||||
options = tls.get_options_from_config(self.settings.tls)
|
||||
tls.tls_options_check(options)
|
||||
context_factory = tls.get_tls_context_factory(options)
|
||||
reactor.listenSSL(self.http_port, self.server, context_factory)
|
||||
|
|
@ -422,32 +480,32 @@ class FileSharing:
|
|||
client.enabled_features.add("XEP-0363")
|
||||
|
||||
self.init()
|
||||
public_base_url = self.host.memory.config_get(
|
||||
"component file-sharing", "http_upload_public_facing_url"
|
||||
)
|
||||
public_base_url = self.settings.public_url
|
||||
if public_base_url is None:
|
||||
client._file_sharing_base_url = f"https://{client.host}:{self.http_port}"
|
||||
else:
|
||||
client._file_sharing_base_url = public_base_url
|
||||
path = client.file_tmp_dir = os.path.join(
|
||||
self.host.memory.config_get("", "local_dir"),
|
||||
G.config.common.local_dir,
|
||||
C.FILES_TMP_DIR,
|
||||
regex.path_escape(client.profile),
|
||||
)
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
def get_quota(self, client, entity):
|
||||
"""Return maximum size allowed for all files for entity"""
|
||||
quotas = self.host.memory.config_get("component file-sharing", "quotas_json", {})
|
||||
if self.host.memory.is_admin_jid(entity):
|
||||
quota = quotas.get("admins")
|
||||
else:
|
||||
try:
|
||||
quota = quotas["jids"][entity.userhost()]
|
||||
except KeyError:
|
||||
quota = quotas.get("users")
|
||||
return None if quota is None else utils.parse_size(quota)
|
||||
def get_quota(self, entity: jid.JID) -> int | None:
|
||||
"""Get the maximum file storage quota for a given entity.
|
||||
|
||||
@param entity: The JID to check quota for.
|
||||
@return: The maximum allowed size in bytes, or None if no quota is set.
|
||||
"""
|
||||
entity_bare = entity.userhostJID()
|
||||
quotas = self.settings.quotas
|
||||
quota = quotas.jids.get(entity_bare)
|
||||
if not quota:
|
||||
is_admin = G.host.memory.is_admin_jid(entity_bare)
|
||||
quota = quotas.admins if is_admin else quotas.users
|
||||
return quota
|
||||
|
||||
async def generate_thumbnails(self, extra: dict, image_path: Path):
|
||||
thumbnails = extra.setdefault(C.KEY_THUMBNAILS, [])
|
||||
|
|
@ -552,7 +610,7 @@ class FileSharing:
|
|||
assert C.KEY_PROGRESS_ID in file_data
|
||||
filename = file_data["name"]
|
||||
assert filename and not "/" in filename
|
||||
quota = self.get_quota(client, peer_jid)
|
||||
quota = self.get_quota(peer_jid)
|
||||
if quota is not None:
|
||||
used_space = await self.host.memory.file_get_used_space(client, peer_jid)
|
||||
|
||||
|
|
@ -676,7 +734,7 @@ class FileSharing:
|
|||
if request.from_.host not in client._file_sharing_allowed_hosts:
|
||||
raise error.StanzaError("forbidden")
|
||||
|
||||
quota = self.get_quota(client, request.from_)
|
||||
quota = self.get_quota(request.from_)
|
||||
if quota is not None:
|
||||
used_space = await self.host.memory.file_get_used_space(client, request.from_)
|
||||
|
||||
|
|
@ -786,7 +844,9 @@ class Comments_handler(pubsub.PubSubService):
|
|||
self.plugin_parent = plugin_parent
|
||||
self.discoIdentity = {
|
||||
"category": "pubsub",
|
||||
"type": "virtual", # FIXME: non standard, here to avoid this service being considered as main pubsub one
|
||||
"type": (
|
||||
"virtual"
|
||||
), # FIXME: non standard, here to avoid this service being considered as main pubsub one
|
||||
"name": "files commenting service",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pydantic import Field
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
|
@ -26,6 +28,8 @@ from twisted.internet import reactor, protocol, defer
|
|||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.conch.manhole import ColoredManhole
|
||||
|
||||
from libervia.backend.tools.config import PluginSettings
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
PLUGIN_INFO = {
|
||||
|
|
@ -40,11 +44,18 @@ PLUGIN_INFO = {
|
|||
}
|
||||
|
||||
|
||||
class PluginManholeSettings(PluginSettings, plugin_info=PLUGIN_INFO):
|
||||
dangerous_manhole_debug_port: int = Field(
|
||||
default=0, description="Debug port for manhole"
|
||||
)
|
||||
|
||||
|
||||
class Manhole(object):
|
||||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
port = int(host.memory.config_get(None, "manhole_debug_dangerous_port_int", 0))
|
||||
settings = G.config.get_settings(PluginManholeSettings)
|
||||
port = settings.dangerous_manhole_debug_port
|
||||
if port:
|
||||
self.start_manhole(port)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import cast
|
||||
from pydantic import Field
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _, D_
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
||||
|
|
@ -24,11 +27,11 @@ from libervia.backend.tools import xml_tools
|
|||
from libervia.backend.memory.memory import Sessions
|
||||
from libervia.backend.memory.crypto import PasswordHasher
|
||||
from libervia.backend.core.constants import Const as C
|
||||
import configparser
|
||||
from twisted.internet import defer
|
||||
from twisted.python.failure import Failure
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from libervia.backend.tools.common import email as sat_email
|
||||
from libervia.backend.tools.config import EmailSettings, PluginSettings
|
||||
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
|
@ -40,7 +43,7 @@ log = getLogger(__name__)
|
|||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: "Account Plugin",
|
||||
C.PI_IMPORT_NAME: "MISC-ACCOUNT",
|
||||
C.PI_IMPORT_NAME: "account",
|
||||
C.PI_TYPE: "MISC",
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: ["XEP-0077"],
|
||||
|
|
@ -69,11 +72,14 @@ default_conf = {
|
|||
"admin_email": "",
|
||||
"new_account_server": "localhost",
|
||||
"new_account_domain": "", # use xmpp_domain if not found
|
||||
"reserved_list": ["libervia"], # profiles which can't be used
|
||||
}
|
||||
|
||||
# profiles which can't be used for accound creation. Must be lowercase.
|
||||
RESERVED_LIST: list[str] = ["libervia"]
|
||||
|
||||
|
||||
WELCOME_MSG = D_(
|
||||
"""Welcome to Libervia, the web interface of Salut à Toi.
|
||||
"""Welcome to Libervia.
|
||||
|
||||
Your account on {domain} has been successfully created.
|
||||
This is a demonstration version to show you the current status of the project.
|
||||
|
|
@ -91,16 +97,23 @@ In the beginning, you have nobody to talk to. To find some contacts, you may use
|
|||
|
||||
Any feedback welcome. Thank you!
|
||||
|
||||
Salut à Toi association
|
||||
https://www.salut-a-toi.org
|
||||
The Libervia team.
|
||||
https://www.libervia.org
|
||||
"""
|
||||
)
|
||||
|
||||
DEFAULT_DOMAIN = "example.net"
|
||||
|
||||
class PluginsAccountSettings(PluginSettings, plugin_info=PLUGIN_INFO):
|
||||
# Use global email settings by default.
|
||||
email: EmailSettings | None = Field(
|
||||
default=None,
|
||||
description="Email settings, default to settings from ``email`` section, use "
|
||||
"this if you want different ones for account creation.",
|
||||
)
|
||||
|
||||
|
||||
class MiscAccount(object):
|
||||
"""Account plugin: create a SàT + XMPP account, used by Libervia"""
|
||||
"""Account plugin: create a Libervia + XMPP account."""
|
||||
|
||||
# XXX: This plugin was initialy a Q&D one used for the demo.
|
||||
# TODO: cleaning, separate email handling, more configuration/tests, fixes
|
||||
|
|
@ -121,7 +134,7 @@ class MiscAccount(object):
|
|||
".plugin",
|
||||
in_sign="",
|
||||
out_sign="s",
|
||||
method=self.account_domain_new_get,
|
||||
method=lambda: G.config.common.new_account_domain,
|
||||
async_=False,
|
||||
)
|
||||
host.bridge.add_method(
|
||||
|
|
@ -141,7 +154,6 @@ class MiscAccount(object):
|
|||
async_=True,
|
||||
)
|
||||
|
||||
self.fix_email_admins()
|
||||
self._sessions = Sessions()
|
||||
|
||||
self.__account_cb_id = host.register_callback(
|
||||
|
|
@ -170,46 +182,16 @@ class MiscAccount(object):
|
|||
self.__delete_account_cb, with_data=True
|
||||
)
|
||||
|
||||
# FIXME: remove this after some time, when the deprecated parameter is really abandoned
|
||||
def fix_email_admins(self):
|
||||
"""Handle deprecated config option "admin_email" to fix the admin emails list"""
|
||||
admin_email = self.config_get("admin_email")
|
||||
if not admin_email:
|
||||
return
|
||||
log.warning(
|
||||
"admin_email parameter is deprecated, please use email_admins_list instead"
|
||||
)
|
||||
param_name = "email_admins_list"
|
||||
try:
|
||||
section = ""
|
||||
value = self.host.memory.config_get(section, param_name, Exception)
|
||||
except (configparser.NoOptionError, configparser.NoSectionError):
|
||||
section = CONFIG_SECTION
|
||||
value = self.host.memory.config_get(
|
||||
section, param_name, default_conf[param_name]
|
||||
)
|
||||
def get_email_conf(self) -> EmailSettings:
|
||||
"""Return settings to send an email.
|
||||
|
||||
value = set(value)
|
||||
value.add(admin_email)
|
||||
self.host.memory.config.set(section, param_name, ",".join(value))
|
||||
|
||||
def config_get(self, name, section=CONFIG_SECTION):
|
||||
if name.startswith("email_"):
|
||||
# XXX: email_ parameters were first in [plugin account] section
|
||||
# but as it make more sense to have them in common with other plugins,
|
||||
# they can now be in [DEFAULT] section
|
||||
try:
|
||||
value = self.host.memory.config_get(None, name, Exception)
|
||||
except (configparser.NoOptionError, configparser.NoSectionError):
|
||||
pass
|
||||
else:
|
||||
return value
|
||||
|
||||
if section == CONFIG_SECTION:
|
||||
default = default_conf[name]
|
||||
Will use settings of this plugins is set, otherwise global ones.
|
||||
"""
|
||||
plugin_settings = G.config.get_settings(PluginsAccountSettings)
|
||||
if plugin_settings.email is not None:
|
||||
return plugin_settings.email
|
||||
else:
|
||||
default = None
|
||||
return self.host.memory.config_get(section, name, default)
|
||||
return G.config.email
|
||||
|
||||
def _register_account(self, email, password, profile):
|
||||
return self.registerAccount(email, password, None, profile)
|
||||
|
|
@ -244,7 +226,7 @@ class MiscAccount(object):
|
|||
if not password or not profile:
|
||||
raise exceptions.DataError
|
||||
|
||||
if profile.lower() in self.config_get("reserved_list"):
|
||||
if profile.lower() in RESERVED_LIST:
|
||||
return defer.fail(Failure(exceptions.ConflictError))
|
||||
|
||||
d = self.host.memory.create_profile(profile, password)
|
||||
|
|
@ -265,7 +247,7 @@ class MiscAccount(object):
|
|||
d = defer.succeed(None)
|
||||
jid_ = jid.JID(jid_s)
|
||||
else:
|
||||
jid_s = profile + "@" + self.account_domain_new_get()
|
||||
jid_s = f"{profile}@{G.config.common.new_account_domain}"
|
||||
jid_ = jid.JID(jid_s)
|
||||
d = self.host.plugins["XEP-0077"].register_new_account(jid_, password)
|
||||
|
||||
|
|
@ -299,10 +281,10 @@ class MiscAccount(object):
|
|||
def send_emails(self, email, profile):
|
||||
# time to send the email
|
||||
|
||||
domain = self.account_domain_new_get()
|
||||
domain = G.config.common.new_account_domain
|
||||
|
||||
# email to the administrators
|
||||
admins_emails = self.config_get("email_admins_list")
|
||||
admins_emails = G.config.common.email_admins_list
|
||||
if not admins_emails:
|
||||
log.warning(
|
||||
"No known admin email, we can't send email to administrator(s).\n"
|
||||
|
|
@ -314,7 +296,11 @@ class MiscAccount(object):
|
|||
# there is no email when an existing XMPP account is used
|
||||
body = f"New account created on {domain}: {profile} [{email or '<no email>'}]"
|
||||
d_admin = sat_email.send_email(
|
||||
self.host.memory.config, admins_emails, subject, body
|
||||
self.get_email_conf(),
|
||||
self.host.memory.config,
|
||||
admins_emails,
|
||||
subject,
|
||||
body,
|
||||
)
|
||||
|
||||
admins_emails_txt = ", ".join(["<" + addr + ">" for addr in admins_emails])
|
||||
|
|
@ -343,7 +329,7 @@ class MiscAccount(object):
|
|||
# XXX: this will not fail when the email address doesn't exist
|
||||
# FIXME: check email reception to validate email given by the user
|
||||
# FIXME: delete the profile if the email could not been sent?
|
||||
d_user = sat_email.send_email(self.host.memory.config, [email], subject, body)
|
||||
d_user = sat_email.send_email(self.get_email_conf, [email], subject, body)
|
||||
d_user.addCallbacks(
|
||||
lambda __: log.debug(
|
||||
"Account creation confirmation sent to <{}>".format(email)
|
||||
|
|
@ -353,21 +339,6 @@ class MiscAccount(object):
|
|||
)
|
||||
return defer.DeferredList([d_user, d_admin])
|
||||
|
||||
def account_domain_new_get(self):
|
||||
"""get the domain that will be set to new account"""
|
||||
|
||||
domain = self.config_get("new_account_domain") or self.config_get(
|
||||
"xmpp_domain", None
|
||||
)
|
||||
if not domain:
|
||||
log.warning(
|
||||
_(
|
||||
'xmpp_domain needs to be set in sat.conf. Using "{default}" meanwhile'
|
||||
).format(default=DEFAULT_DOMAIN)
|
||||
)
|
||||
return DEFAULT_DOMAIN
|
||||
return domain
|
||||
|
||||
def _get_account_dialog_ui(self, profile):
|
||||
"""Get the main dialog to manage your account
|
||||
@param menu_data
|
||||
|
|
@ -540,7 +511,7 @@ class MiscAccount(object):
|
|||
return d
|
||||
|
||||
def __delete_account(self, profile):
|
||||
"""Ask for a confirmation before deleting the XMPP account and SàT profile
|
||||
"""Ask for a confirmation before deleting the XMPP account and Libervia profile
|
||||
@param profile
|
||||
"""
|
||||
form_ui = xml_tools.XMLUI(
|
||||
|
|
@ -558,9 +529,8 @@ class MiscAccount(object):
|
|||
)
|
||||
form_ui.addText(
|
||||
D_(
|
||||
"All your data stored on %(server)s, including your %(target)s will be erased."
|
||||
)
|
||||
% {"server": self.account_domain_new_get(), "target": target}
|
||||
"All your data stored on {server}, including your {target} will be erased."
|
||||
).format(server=G.config.common.new_account_domain, target=target)
|
||||
)
|
||||
form_ui.addText(
|
||||
D_(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# SAT plugin for file tansfer
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
|
|
@ -30,6 +28,7 @@ from twisted.internet import protocol
|
|||
from twisted.internet import abstract
|
||||
from twisted.internet import error as int_error
|
||||
from twisted.internet import _sslverify
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _, D_
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
|
@ -284,7 +283,7 @@ class AndroidPlugin(object):
|
|||
self.am = activity.getSystemService(Context.AUDIO_SERVICE)
|
||||
|
||||
# sound notification
|
||||
media_dir = Path(host.memory.config_get("", "media_dir"))
|
||||
media_dir = G.config.common.media_dir
|
||||
assert media_dir is not None
|
||||
notif_path = media_dir / "sounds" / "notifications" / "music-box.mp3"
|
||||
self.notif_player = MediaPlayer()
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ from twisted.internet import defer
|
|||
from twisted.python.procutils import which
|
||||
from yaml.constructor import ConstructorError
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
|
|
@ -177,7 +178,7 @@ class AppManager:
|
|||
"is expected"
|
||||
)
|
||||
|
||||
value = self.host.memory.config_get(section, name, default)
|
||||
value = getattr(getattr(G.config, section), name) or default
|
||||
# FIXME: "public_url" is used only here and doesn't take multi-sites into account
|
||||
if name == "public_url" and (not value or value.startswith("http")):
|
||||
if not value:
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from twisted.internet import defer
|
|||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.words.protocols.jabber import error
|
||||
from twisted.words.protocols.jabber import sasl
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _, D_
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core import exceptions
|
||||
|
|
@ -229,13 +230,8 @@ class InvitationsPlugin(object):
|
|||
|
||||
jid_ = kwargs.pop("jid_", None)
|
||||
if not jid_:
|
||||
domain = self.host.memory.config_get(None, "xmpp_domain")
|
||||
if not domain:
|
||||
# TODO: fallback to profile's domain
|
||||
raise ValueError(_("You need to specify xmpp_domain in sat.conf"))
|
||||
jid_ = "invitation-{uuid}@{domain}".format(
|
||||
uuid=shortuuid.uuid(), domain=domain
|
||||
)
|
||||
domain = G.config.common.xmpp_domain
|
||||
jid_ = f"invitation-{shortuuid.uuid()}@{domain}"
|
||||
jid_ = jid.JID(jid_)
|
||||
extra[KEY_JID] = jid_.full()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,108 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# SAT plugin for static blogs
|
||||
# Copyright (C) 2014 Adrien Cossa (souliane@mailoo.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
from libervia.backend.core.i18n import _, D_
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.tools import xml_tools
|
||||
|
||||
from twisted.internet import defer
|
||||
from twisted.words.protocols.jabber import jid
|
||||
|
||||
|
||||
PLUGIN_INFO = {
|
||||
C.PI_NAME: "Static Blog Plugin",
|
||||
C.PI_IMPORT_NAME: "STATIC-BLOG",
|
||||
C.PI_TYPE: "MISC",
|
||||
C.PI_PROTOCOLS: [],
|
||||
C.PI_DEPENDENCIES: [],
|
||||
C.PI_RECOMMENDATIONS: [
|
||||
"MISC-ACCOUNT"
|
||||
], # TODO: remove when all blogs can be retrieved
|
||||
C.PI_MAIN: "StaticBlog",
|
||||
C.PI_HANDLER: "no",
|
||||
C.PI_DESCRIPTION: _("""Plugin for static blogs"""),
|
||||
}
|
||||
|
||||
|
||||
class StaticBlog(object):
|
||||
|
||||
params = """
|
||||
<params>
|
||||
<individual>
|
||||
<category name="{category_name}" label="{category_label}">
|
||||
<param name="{title_name}" label="{title_label}" value="" type="string" security="0"/>
|
||||
<param name="{banner_name}" label="{banner_label}" value="" type="string" security="0"/>
|
||||
<param name="{background_name}" label="{background_label}" value ="" type="string" security="0"/>
|
||||
<param name="{keywords_name}" label="{keywords_label}" value="" type="string" security="0"/>
|
||||
<param name="{description_name}" label="{description_label}" value="" type="string" security="0"/>
|
||||
</category>
|
||||
</individual>
|
||||
</params>
|
||||
""".format(
|
||||
category_name=C.STATIC_BLOG_KEY,
|
||||
category_label=D_(C.STATIC_BLOG_KEY),
|
||||
title_name=C.STATIC_BLOG_PARAM_TITLE,
|
||||
title_label=D_("Page title"),
|
||||
banner_name=C.STATIC_BLOG_PARAM_BANNER,
|
||||
banner_label=D_("Banner URL"),
|
||||
background_name="Background",
|
||||
background_label=D_("Background image URL"),
|
||||
keywords_name=C.STATIC_BLOG_PARAM_KEYWORDS,
|
||||
keywords_label=D_("Keywords"),
|
||||
description_name=C.STATIC_BLOG_PARAM_DESCRIPTION,
|
||||
description_label=D_("Description"),
|
||||
)
|
||||
|
||||
def __init__(self, host):
|
||||
try: # TODO: remove this attribute when all blogs can be retrieved
|
||||
self.domain = host.plugins["MISC-ACCOUNT"].account_domain_new_get()
|
||||
except KeyError:
|
||||
self.domain = None
|
||||
host.memory.update_params(self.params)
|
||||
# host.import_menu((D_("User"), D_("Public blog")), self._display_public_blog, security_limit=1, help_string=D_("Display public blog page"), type_=C.MENU_JID_CONTEXT)
|
||||
|
||||
def _display_public_blog(self, menu_data, profile):
|
||||
"""Check if the blog can be displayed and answer the frontend.
|
||||
|
||||
@param menu_data: %(menu_data)s
|
||||
@param profile: %(doc_profile)s
|
||||
@return: dict
|
||||
"""
|
||||
# FIXME: "public_blog" key has been removed
|
||||
# TODO: replace this with a more generic widget call with URIs
|
||||
try:
|
||||
user_jid = jid.JID(menu_data["jid"])
|
||||
except KeyError:
|
||||
log.error(_("jid key is not present !"))
|
||||
return defer.fail(exceptions.DataError)
|
||||
|
||||
# TODO: remove this check when all blogs can be retrieved
|
||||
if self.domain and user_jid.host != self.domain:
|
||||
info_ui = xml_tools.XMLUI("popup", title=D_("Not available"))
|
||||
info_ui.addText(
|
||||
D_("Retrieving a blog from an external domain is not implemented yet.")
|
||||
)
|
||||
return {"xmlui": info_ui.toXml()}
|
||||
|
||||
return {"public_blog": user_jid.userhost()}
|
||||
|
|
@ -23,6 +23,7 @@ from twisted.words.protocols.jabber import jid, error
|
|||
from twisted.words.xish import domish
|
||||
from twisted.internet import defer
|
||||
from wokkel import pubsub, rsm
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core import exceptions
|
||||
|
|
@ -65,7 +66,7 @@ class PubsubCache:
|
|||
|
||||
def __init__(self, host):
|
||||
log.info(_("PubSub Cache initialization"))
|
||||
strategy = host.memory.config_get(None, "pubsub_cache_strategy")
|
||||
strategy = G.config.common.pubsub_cache_strategy
|
||||
if strategy == "no_cache":
|
||||
log.info(
|
||||
_(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import time
|
|||
from typing import Optional, cast
|
||||
import uuid
|
||||
|
||||
from pydantic import Field
|
||||
import shortuuid
|
||||
from twisted.internet import defer
|
||||
from twisted.python import failure
|
||||
|
|
@ -32,6 +33,7 @@ from wokkel import rsm
|
|||
from wokkel import mam
|
||||
from zope.interface import implementer
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.core_types import SatXMPPEntity
|
||||
from libervia.backend.core.constants import Const as C
|
||||
|
|
@ -40,6 +42,7 @@ from libervia.backend.core.log import getLogger
|
|||
from libervia.backend.memory import memory
|
||||
from libervia.backend.plugins import plugin_misc_jid_search
|
||||
from libervia.backend.tools import xml_tools, utils
|
||||
from libervia.backend.tools.config import PluginSettings
|
||||
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
|
@ -71,9 +74,8 @@ HISTORY_LEGACY = "legacy"
|
|||
HISTORY_MAM = "mam"
|
||||
|
||||
|
||||
CONFIG_SECTION = "plugin muc"
|
||||
|
||||
default_conf = {"default_muc": "sat@chat.jabberfr.org"}
|
||||
class PluginsMucSettings(PluginSettings, plugin_info=PLUGIN_INFO):
|
||||
default_muc: str = Field(default="sat@chat.jabberfr.org")
|
||||
|
||||
|
||||
class AlreadyJoined(exceptions.ConflictError):
|
||||
|
|
@ -653,13 +655,9 @@ class XEP_0045:
|
|||
return jid.JID(f"{room_name}@{muc_service}")
|
||||
|
||||
def get_default_muc(self):
|
||||
"""Return the default MUC.
|
||||
|
||||
@return: unicode
|
||||
"""
|
||||
return self.host.memory.config_get(
|
||||
CONFIG_SECTION, "default_muc", default_conf["default_muc"]
|
||||
)
|
||||
"""Return the default MUC."""
|
||||
plugin_settings = G.config.get_settings(PluginsMucSettings)
|
||||
return plugin_settings.default_muc
|
||||
|
||||
def _bridge_join_eb(self, failure_, client):
|
||||
failure_.trap(AlreadyJoined)
|
||||
|
|
|
|||
|
|
@ -17,12 +17,16 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pydantic import Field
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _, D_
|
||||
from libervia.backend.core.log import getLogger
|
||||
from libervia.backend.models.types import JIDType
|
||||
from libervia.backend.tools.config import PluginSettings
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
from twisted.words.protocols.jabber.xmlstream import IQ
|
||||
from twisted.words.protocols.jabber.xmlstream import IQ, XMPPHandler
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.internet import defer
|
||||
from wokkel import data_form
|
||||
|
|
@ -32,10 +36,6 @@ from libervia.backend.tools import xml_tools
|
|||
|
||||
from wokkel import disco, iwokkel
|
||||
|
||||
try:
|
||||
from twisted.words.protocols.xmlstream import XMPPHandler
|
||||
except ImportError:
|
||||
from wokkel.subprotocols import XMPPHandler
|
||||
from zope.interface import implementer
|
||||
|
||||
|
||||
|
|
@ -44,6 +44,7 @@ NS_SEARCH = "jabber:iq:search"
|
|||
PLUGIN_INFO = {
|
||||
C.PI_NAME: "Jabber Search",
|
||||
C.PI_IMPORT_NAME: "XEP-0055",
|
||||
C.PI_CONFIG_KEY: "search",
|
||||
C.PI_TYPE: "XEP",
|
||||
C.PI_PROTOCOLS: ["XEP-0055"],
|
||||
C.PI_DEPENDENCIES: [],
|
||||
|
|
@ -65,18 +66,20 @@ FIELD_CURRENT_SERVICE = (
|
|||
)
|
||||
|
||||
|
||||
class XEP_0055(object):
|
||||
class PluginSearchSettings(PluginSettings, plugin_info=PLUGIN_INFO):
|
||||
services: list[JIDType] = Field(
|
||||
default_factory=list,
|
||||
description="Default list of services for search operations.",
|
||||
)
|
||||
|
||||
|
||||
class XEP_0055:
|
||||
def __init__(self, host):
|
||||
log.info(_("Jabber search plugin initialization"))
|
||||
self.host = host
|
||||
|
||||
# default search services (config file + hard-coded lists)
|
||||
self.services = [
|
||||
jid.JID(entry)
|
||||
for entry in host.memory.config_get(
|
||||
CONFIG_SECTION, CONFIG_SERVICE_LIST, DEFAULT_SERVICE_LIST
|
||||
)
|
||||
]
|
||||
search_settings = G.config.get_settings(PluginSearchSettings)
|
||||
self.services = search_settings.services
|
||||
|
||||
host.bridge.add_method(
|
||||
"search_fields_ui_get",
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ from typing import (
|
|||
)
|
||||
import urllib.parse
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from twisted.internet import defer, reactor
|
||||
from twisted.words.protocols.jabber import error, jid
|
||||
from twisted.words.xish import domish
|
||||
|
|
@ -44,6 +44,7 @@ from wokkel import rsm
|
|||
from wokkel import mam
|
||||
from zope.interface import implementer
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.core_types import SatXMPPEntity
|
||||
|
|
@ -91,7 +92,7 @@ DEFAULT_PUBSUB_MIN_FEAT = {
|
|||
class NodeMetadata(BaseModel):
|
||||
"""Node metadata model."""
|
||||
|
||||
model_config = {"extra": "allow"}
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
type: str | None = None
|
||||
creator: JIDType | None = None
|
||||
|
|
@ -481,9 +482,7 @@ class XEP_0060:
|
|||
|
||||
async def profile_connected(self, client):
|
||||
try:
|
||||
client.pubsub_service = jid.JID(
|
||||
self.host.memory.config_get("", "pubsub_service")
|
||||
)
|
||||
client.pubsub_service = jid.JID(G.config.common.pubsub_service)
|
||||
except RuntimeError:
|
||||
log.info(
|
||||
_(
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ from twisted.words.xish import domish
|
|||
from wokkel import data_form, disco, iwokkel
|
||||
from zope.interface import implementer
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core import exceptions
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.i18n import _
|
||||
|
|
@ -488,7 +489,7 @@ class XEP_0077:
|
|||
@param port: port of the server to register to
|
||||
"""
|
||||
if host is None:
|
||||
host = self.host.memory.config_get("", "xmpp_domain", "127.0.0.1")
|
||||
host = G.config.common.xmpp_domain
|
||||
check_certificate = host != "127.0.0.1"
|
||||
authenticator = RegisteringAuthenticator(
|
||||
jid_, password, email, check_certificate=check_certificate
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core import exceptions
|
||||
|
|
@ -137,13 +138,7 @@ class XEP_0198(object):
|
|||
host.trigger.add("xml_init", self._xml_init_trigger)
|
||||
host.trigger.add("disconnecting", self._disconnecting_trigger)
|
||||
host.trigger.add("disconnected", self._disconnected_trigger)
|
||||
try:
|
||||
self._ack_timeout = int(
|
||||
host.memory.config_get("", "ack_timeout", ACK_TIMEOUT)
|
||||
)
|
||||
except ValueError:
|
||||
log.error(_("Invalid ack_timeout value, please check your configuration"))
|
||||
self._ack_timeout = ACK_TIMEOUT
|
||||
self._ack_timeout = G.config.common.ack_timeout
|
||||
if not self._ack_timeout:
|
||||
log.info(_("Ack timeout disabled"))
|
||||
else:
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue