Commit graph

4,627 commits

Author SHA1 Message Date
Goffi
836a9c962e tools (common/uri): Modernization + more flexible URIs:
- Remove Python < 3.9 workaround
- Type hints + docstring update
- Accept `kwargs` when `type_` is `None`.

rel 477
2026-06-06 12:23:06 +02:00
Goffi
6aba4c6686 plugin XEP-0045: Fix variable used in logs. 2026-06-06 12:23:06 +02:00
Goffi
ed462a661b core (memory): Modernize methods signature/docstrings of encrypt_value and decrypt_value:
- Use `client` instead of `profile`
- Add `decrypt_value_by_profile` which is notably useful on client startup, when the
  encrypted password needs to be retrieved, and the `SatXMPPEntity` instance is not yet
  created.
- Add type hints/update docstrings

rel 477
2026-06-06 12:23:06 +02:00
Goffi
e0064e0372 component pubsub: Set default access model for PEP to presence 2026-05-27 15:28:11 +02:00
Goffi
23cbd8ff9d memory (sqla), bridge: New history_last_messages_metadata_get method:
This method is used to retrieve last messages and their timestamps. It's useful on frontend
startup to display data on last discussions.
2026-05-25 17:52:26 +02:00
Goffi
ac315a4300 plugin XEP-0402: log a warning instead of an exception on TimeoutError. 2026-05-25 17:41:53 +02:00
Goffi
e257600ad5 core (launcher): Separate add_subparsers for exensibility:
`add_subparsers` is now in its own method to it can be extended by a subclass. Notably
needed by web frontend to add its `local` command.
2026-05-22 18:27:46 +02:00
Goffi
00c7f1b1a3 plugin XEP-402: log a warning instead of an exception on NotFound error. 2026-05-21 21:10:30 +02:00
Goffi
f5e065b56a plugin XEP-0465: Remove duplicate ps_public_subscriptions_get bridge method. 2026-05-21 21:10:30 +02:00
Goffi
a722464238 bridge (embedded): Update and fix:
Fix embedded bridge and adapt to changes in core code:

- Add `EmbeddedBridgeSettings` so it can be used in settings.
- Add `AIOBridge` and `TwistedBridge` wrappers.
- Fix callbacks, instead of logging them (and breaking the errback chain), they are now
  raised using `BridgeException` like in other bridges.
- Ensure that a singleton `Bridge` is used between backend and frontend.
- Init backend on first call to `bridge_connect`.
- Add Python 3.14 fix (as it is normally done in Launcher which is not run with with
`embedded`, we have to do it there).
- Track generated files.
2026-05-21 21:09:43 +02:00
Goffi
15ad700b22 plugin XEP-0402: Fetch bookmarks on startup and handle autojoin. 2026-05-14 11:49:02 +02:00
Goffi
dce577bf3a plugin XEP-0163: type hints 2026-05-14 11:49:02 +02:00
Goffi
502d9aad19 plugin XEP-0313: Fix elements dump in the warning:
The use of `pp_elt` was printing the element instead of showing them in the warning
message.
2026-05-14 11:49:02 +02:00
Goffi
d8b083cdb0 plugin XEP-0384: Regenerate key on corrupted data. 2026-05-14 11:49:02 +02:00
Goffi
45395c729a core (xmpp): Return as soon as possible once connection is establied:
To improve connection time and UX in frontends, the `start_connection` returns immediately
after the connection is established (authentication successful), and the rest of
initialisation is now done in background. The `profile_ready` and
`profile_connection_error` signals can be used to track the end of the full connection
process.
Roster retrieval is now also done in background for the same reason.
`LiberviaRosterProtocol.got_roster` Deferred can be used to track roster retrieval.
2026-05-14 11:49:02 +02:00
Goffi
8780d2133f bridge: Add profile_connection_error signal 2026-05-14 11:49:02 +02:00
Goffi
2b0f4bd192 plugin XEP-0033: Fix validation error when only metadata address are used:
XEP-0033 may be used as a simple metadata marker when sending messages (e.g. to indicate a
`replyto`). The validation was failing on that due to missing `to`, `cc` and `bcc`.
2026-05-14 11:49:02 +02:00
Goffi
2c5713b486 memory (disco): Fix pending queries isolation and cancellation:
When returning pending queries `Deferred`, a caller could add its own callbacks/errbacks
and modify the result. When another caller was reusing the `Deferred`, it got the modified
result (which could be `None`) instead of the expected `DiscoInfo`.

This has been fixed by creating and new `Deferred` on each request, and chaining it to the
original pending queries using the new `fork_deferred` helper method, so each caller get
its own isolated `Deferred`.

In `fork_deferred`, `cancel` method is used to call the parent Deferred `cancel`, to avoid
a wrong Exception propagation and the chained Deferred to be eventually called twice
(triggering `AlreadyCalledError`).

`cleanup_query` has been moved above `infos_cb` callback, as it should be the first
callback called.
2026-05-14 11:43:59 +02:00
Goffi
709366fe13 plugin XEP-0084: fix avatar retrieval and disabling:
- Avatar disabling was not correctly handled for all cases, this should now be fixed.
- Avatar retrieval is now down only on PEP events, no directly anymore. `get_avatar` only
  returns cached version.
2026-05-04 16:49:07 +02:00
Goffi
89c23c8a4c plugin XEP-0084: Fix double feature advertising:
`NS_AVATAR_METADATA` is already advertised by `add_pep_event`, adding it to `getDiscoInfo`
too was resulting in double advertising, making the disco infos invalid for caching
(resulting in other devices repeatedly requesting disco#info).
2026-05-04 16:47:42 +02:00
Goffi
a750154c2f bridge (D-Bus): fix BridgeException wrapping 2026-05-04 16:44:39 +02:00
Goffi
c3906da781 cli (base): Flush output on self.disp:
When `li` stdout was redirected (e.g. with a pipe), the buffer was preventing to display
immediately data, which is a problem when we need it immediately (like when monitoring
with `li debug monitor`). Flushing is now done immediately to avoid that.
2026-05-04 16:44:39 +02:00
Goffi
1c6ca838b5 plugin XEP-0473: Don't try do load secrets if there is not encrypted elements:
The plugin was trying to decrypt all pubsub events, without checking if there is
"encrypted" element first, resulting in warning for all clear events.

This patch fixes it by detecting <encrypted> element and exiting early if none is found.
2026-05-04 16:44:39 +02:00
Goffi
351b7e2140 plugin XEP-0356: Fix incorrect _on_presence definition 2026-05-04 16:44:39 +02:00
Goffi
18d3f0167f plugin XEP-0115: Fix disco duplicate on caps node query + check own generation:
When caps node was requested, disco infos was returned from cache + infos from normal
disco gathering, resulting in doubled items and other entities rejecting the disco info.

This is fixed by subclassing the disco handler to add a trigger. This trigger is used by
XEP-0115 to short circuit the disco gathering and returned its cached data instead.

Our own hash is re-generated on each connection, and validated, so if there is a bug, this
helps see and catch it.
2026-05-04 16:44:39 +02:00
Goffi
58834f15ae tools (trigger): Type hint + dead code removal:
- Remove `is_available` which uncomplete and not used at all.
- Add/fix type hints and docstrings.
2026-05-04 15:08:13 +02:00
Goffi
d2fd11df13 plugin XEP-215: Use bare JID instead of raising an exception on full jid. 2026-05-04 15:04:04 +02:00
Goffi
1613554018 memory (disco): ensure that we don't cache None in disco hashes:
Add a guard to avoid mapping `None` to a hash.
2026-05-04 15:04:04 +02:00
Goffi
779d58d5ff core (xmpp/messages): only send "origin" request for printable messages:
"Origin" request are disco requests to know if a message sender is a bot or coming from a
gateway. It was sending request on every message, including pubsub/PEP events, resulting
in requests done to many entities, including ones not cacheables (bare entities or third
party servers, without caps mechanisms).

To avoid that, the requests is now done only for printable messages. To use
`client.is_message_printable` correctly, origin check has be moved to the end, after
`message_parse` trigger, so attachments are added to data.
2026-05-04 15:04:04 +02:00
Goffi
4a66addc34 plugin XEP-0402: Use cast for correct type hints. 2026-05-04 15:04:04 +02:00
Goffi
2d86208e98 plugin XEP-0048: Don't use legacy bookmarks anymore on profile connection:
Legacy bookmarks are not used anymore for autoconnect, it will be done from XEP-0402 now.
2026-05-04 15:03:22 +02:00
Goffi
e0a8bfeb85 plugin XEP-0198: match new init sequence on full init:
Match the new init sequence in normal startup: `<presence>` is now send before MAM sync,
and MAM is now run in background.
2026-05-03 11:45:17 +02:00
Goffi
ee4c80e4d1 plugin XEP-0384: Fix reentrancy loop:
When `prepare_for_profile` is called during connection init, an infinite loop could happen
with 'get_session_manager` calling `prepare_for_profile`. A check is added to early exit
if the profile is already being prepared, avoiding this issue.
2026-05-03 11:32:11 +02:00
Goffi
b4f41fe4a5 plugin XEP-0115: Implement "Stream Feature":
Server features are now checked to find capabilities data and use it for disco caching.
This is §6.3 of the XEP.
2026-05-03 11:20:33 +02:00
Goffi
2aee31732b plugin XEP-0084: Fix entity updated:
`on_metadata_update` was wrongly using our own JID instead of the PEP sender's one.
2026-05-03 11:07:36 +02:00
Goffi
6e723b58a6 core (xmpp): Cache unreachable server on presence error to avoid disco queries:
In case of dead server/component with lot of contacts, we may receive a lot of
`<presence>` error with `remote-server-not-found` conditions. This patch use this to mark
the server as unreachable and avoid to do disco queries there.
2026-05-03 11:00:46 +02:00
Goffi
378f05ca35 memory (disco): Cache failing servers:
When a `remote-server-not-found` stanza error is received, cache the whole server, so all
queries to a entity from this server will be blocked by the cache, avoiding unnecessary
network requests.

During cache check, full entity JID is checked first, then its server.
2026-05-03 11:00:46 +02:00
Goffi
cc4d9b9bd8 memory (disco): track pending queries to re-use them:
When many queries are run in parallel (e.g. during initial sync on startup), the same
entity may be disco queries several times in parallel. To avoid network request
duplication, we now track pending queries, and re-use them in this case.
2026-05-03 11:00:45 +02:00
Goffi
46440d8409 core (xmpp/messages): Optimize and avoir exception on parse_message:
- When we want to disco a bare JID, disco its server instead, to avoid many uncached
requests. In most case, the server disco is enough to discover JID origin.
- Avoid exception on `exceptions.ExternalRequestError`, print a warning instead.
2026-05-03 10:46:23 +02:00
Goffi
5dced35020 core (xmpp): send self-presence immediately after getting roster. 2026-05-03 10:26:43 +02:00
Goffi
df28f1a4b4 plugin XEP-0308:
Fix call to `client.messageProt.parse_message`
2026-05-02 15:55:18 +02:00
Goffi
766d49fb38 plugin XEP-0313: Sync status tracking + resume workflow:
- Add sync status tracking with bridge signals (`mam_sync_started`, `mam_sync_completed`,
  `mam_sync_error`), `mam_sync_statuses_get` method and helper methods that are called
  from `plugin_xep_0045`.
- Update "resume" workflow:
    - fix settings of last stanza ID, so it's always set (was not set for our own messages)
    - own message now use `onMessage` full workflow instead of just store and signal.
    - add `flush_archive_batch` at the end of the process.
    - Sync status are sent during resumt
- Modernisation (type hints, use of `get_plugin_data`)
2026-05-02 15:55:18 +02:00
Goffi
95b24ec319 plugin XEP-0045: MAM archive batching:
Message archives (MAM) are sent by batches to avoid flooding the bridge when the client is
retrieving big ones.
2026-05-02 15:55:18 +02:00
Goffi
a55ef47b0a plugin XEP-0045: MUC joining refactoring:
- Join method is completely refactored so a room is now joined immediately, and MAM
  synchronisation happens in background.
- Legacy history is not used anymore to simplify code.
- Global simplification of the plugin, not more complicated states handling or message
  caching.
2026-05-02 15:55:18 +02:00
Goffi
6cc536472c core: add signal when profile is ready:
A `profile_ready` signal is now sent, so all frontends can know when a profile is
connected, and we don't have to wait for `connect` bridge method and risk a timeout.
2026-05-02 15:55:18 +02:00
Goffi
e5646c9a9d memory: add WAL checkpoint and unload:
- Add `wal_checkpoint()` method to manually checkpoint Write-Ahead logs.
- Do the checkpoint on startup to start clean and avoid delay on first login.
- Add an `unload` method to clean DB on exit, and do a checkpoint there.
2026-05-02 15:55:18 +02:00
Goffi
70ad837e5d cli (base): Add a failsafe on guess_background:
In some cases (e.g. inherited env values in a wrapping tool), the background detection
code can be validated but hangs. This patch avoids that by adding a timeout with a
`SIGALRM`.
2026-05-02 15:55:18 +02:00
Goffi
eda078197a core (types): Add messageProt to SatXMPPEntity 2026-05-02 15:55:18 +02:00
Goffi
399802455f memory (sqla_mapping): Add index on PrivateInd* tables:
`PriaveInd*` may be queried without `key`, in which case an index was missing.
2026-05-02 15:55:18 +02:00
Goffi
b7b5797262 tools (utils): Add aio_func attribute to @aio decorated methods:
We sometimes to need to call another method in asyncio context when we already are in this
context. With the `@aio` decorator which makes the method return a `Deferred`, it was
necessary to use a ping pong between `Deferred` and `Future`.
This patch adds a `aio_func` attribute which directly returns the wrapped asyncio method,
so it can now be awaited directly.
2026-05-02 15:55:18 +02:00