Commit graph libervia-backend/libervia/backend/core
Author SHA1 Message Date
Goffi
2af29e7999 doc (configuration): update (and rewrite for TOML):
- Configuration is now made with TOML, and the documentation was outdated. It has been
  rewritten for TOML, and autodoc is used to show configuration options available in code
  (and keep it up-to-date).
- New isolation mode is documentated.
- (core/constants): fix the `tmp` isolation mode to inherits the parent configuration like
  `normal`.
2026-11-03 18:02:05 +01:00
Goffi
2f0c1d4818 core: reject dashes in isolation instance names:
To avoid confusion and hard-to-debug behaviours, `-` are now rejected in isolation
instance names, only `_` is accepted.
2026-11-03 18:02:05 +01:00
Goffi
50ffc8c3b4 core, memory (sqla), plugins XEP-0277, XEP-0346: various fixes:
- `is_local`: now use `server_jid`.
- `aio_func`: pass the missing `self` argument (`aio_fund` is unbound).
- Declare `pubsub_service` in `core_types.SatXMPPEntity`
- plugin XEP-0277: fix handling of `MbData.from_element` when node is not specified (so we
  use default node).
- plugin XEP-0346: `IdentityData`: fix field access, following move to Pydantic model.
2026-10-27 16:04:50 +01:00
Goffi
f862efe790 core (main): fix call to get_items in getDiscoItems 2026-10-26 18:36:41 +01:00
Goffi
bd1c93f7d4 memory (cache): add persistent cache entries:
`max_age` can now be `C.MAX_AGE_PERSISTENT` to keep a cache entry indefinitely: its `eol`
is then `None` and no expiration check is done.
2026-10-26 18:36:41 +01:00
Goffi
185a765e01 bridge: fix signature for disco_infos and disco_find_by_features 2026-10-26 18:36:41 +01:00
Goffi
0c6f852ce9 plugin XEP-0272: update to v0.2.0 + fixes:
- use the proper `urn:xmpp:jingle:muji:0` namespace
- replace XEP-0249 invitations with XEP-0482
- the dedicated `META_TYPE_GROUP_CALL` subtype is now used for the confirm action (instead
  of `META_TYPE_MUC_INVITATION`)
- handle MUJI invitation: on accept, join the room, start preparing and answer with the
  connection method element
- add the `<muji>` element to outgoing Jingle IQs
- propagate the call type (audio/video) in the MUJI invites (the `type` attribute), so the
  invited clients set up the proper local stream
- the joining participant initiates the sessions with the other participants, using their
  real JIDs, extracted from the presence (the room is set non-anonymous for that)
- only trust the `<muji>` element of a `session-initiate` from a member of the room
- add a `call_group_end` bridge method to clean the MUJI session
- typo fix in `META_TYPE_MUC_INVIRATION` (`R` instead of `T`)
2026-10-17 13:43:33 +02:00
Goffi
b4f88480db bridge (dbus): export the D-Bus name only once the plugins are loaded:
client connecting too early were seeing an incomplete plugin interface.
2026-10-08 20:50:37 +02:00
Goffi
bdca7d2354 tools (common/async_process): add a cleaning mecanism:
PID of commands run with `CommandProtocol` are now tracked in memory and stopped/killed on
exit. A `pid_file` argument can be use to track the file on disk, which is useful to
detect stalled processes after a crash/unclean ending of the backend.

Add helper methods to stop and kill those processes.
2026-09-23 18:19:03 +02:00
Goffi
4b235fc86b core (xmpp): Prevent non printable message to be displayed:
We now use `client.is_message_printable` to check if message is printable. If it's not, we
block storage in DB and sending to bridge. The previous code could let message pass if
metadata were stored in `extra`.
2026-07-21 19:11:17 +02:00
Goffi
e05c69267d core (main, xmpp): fix cleaning methods:
Cleaning methods per-profile (`profile_disconnected`) and per-plugin (`unload`) were not
called correctly. They are now called on shutdown with the `before/shutdown` Twisted
event.
With this event, it's still possible to call Deferred and do cleaning requiring async
calls.

rel 479
2026-07-17 23:27:47 +02:00
Goffi
f7a42771e8 core: implement isolation mode:
Normally the backend is made to have a singleton instance, and handle all profiles.
However, it may be useful to run instances independently (e.g., for development, to run
components in independent processes, for testing, etc).

This was previously possible by using a specific configuration files at backend's root.
This patch introduce a cleaner way by using an isolation mode.

Isolation mode is activated by settings the `LIBERVIA_ISOLATION` environment variable to
the name of the isolated instance. `LIBERVIA_ISOLATION_MODE` can be used to specify one of
the following mode:
- normal (default): config and shared files are in XDG in a `isolated/<name>` subdirectory
  (usually `~/.local/share/libervia/isolated/<name>` and
  `~/.config/libervia/isolated/<name>`). Runtime files and other instance specific data
  (such as D-Bus name) are also isolated. Config uses cascade as usual.
- full: same as above, but config isn't cascading, it's using only its own isolated config
  file.
- tmp: same as normal but the local directory is put in a temporary directory, and deleted
  on backend startup. It stays on termination, so data can be checked if necessary (this mode is
  usually used for development).

This feature will notably be useful to test severless mode on a single machine.

rel 479
2026-07-17 16:45:29 +02:00
Goffi
dbc3973642 plugin XEP-0447: handle deferred sources:
XEP-0447 allow to send sources after the original message. Dino is doing that, and thus we
can't display attachment immediately with only the original message.

This patch handle that by updating the original message once the sources are received, and
emitting a `message_update` signal to notify frontends.
2026-07-09 17:13:37 +02:00
Goffi
88ba99acd0 core (types): Fix type hint for mess_id2uid 2026-07-09 17:13:37 +02:00
Goffi
7b2afd238b core (xmpp): make client.encryption a property to make pyright happy 2026-07-09 17:13:37 +02:00
Goffi
31296c6108 plugin XEP-0447: Mutiple-files support:
- multiple-files support now that the XEP has them. The legacy message compatibility layer
  is implemented too, with the new `message_sent` trigger for 1:1, and with follow-up
  messages sent on message echo for MUC.
- usual modernisation (type hints, `get_plugin_data`)
- (core) new `message_sent` trigger point
2026-07-09 17:13:37 +02:00
Goffi
a214ba6fe3 plugin XEP-0367: "Message Attaching" implementation 2026-07-09 17:13:37 +02:00
Goffi
46e0e3b582 core (xmpp): make message_parse an async trigger point 2026-07-09 17:13:37 +02:00
Goffi
7696afb3d8 core: uid is now set in extra in client.sendMessage:
By setting `uid` in extra, it can now be specified by frontends.
2026-07-09 17:13:37 +02:00
Goffi
e241075a34 core: Unseen message counter:
This patches add handling for unseen messages counter, and last message received. The
counters are retrieved from DB on startup, they updated in-memory. Frontend are expected
to have their own in-memory counter too, the backend one is used for re-sync (e.g.; on page
reload).

Bridge methods are added to retrieve the state, and indicate which message has been seen
last by user. A signal is sent on counter reset to all frontends can synchronise.

This is currently local only, but it should be compatible with a future XEP-0490 (Message
Displayed Synchronization) implementation.
2026-06-20 15:11:06 +02:00
Goffi
cf225eee83 core (constants): fix XDG config path:
The config path was using `APP_NAME` instead of `APP_NAME_FILE`, resulting in `Libervia`
(with uppercase `L`) used instead of `libervia`.
2026-06-19 12:10:14 +02:00
Goffi
29a39b771b plugin XEP-0115: Fix race condition on disco creation:
This patch chains disco query to `conn_deferred` to be sure that `client.disco` is set.

fix #484
2026-06-07 21:20:05 +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
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
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
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
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
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
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
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
eda078197a core (types): Add messageProt to SatXMPPEntity 2026-05-02 15:55:18 +02:00
Goffi
80e5a9e6ac memory (disco): Fix error handling for find_service_entity/find_service_entities:
- Error raised by `disco_info` where not properly handler, resulting in an exception
  instead of appropriate logging and return value.
- `async` coroutines, type hints
2026-04-24 17:38:54 +02:00
Goffi
992d14cb86 core (xmpp): Message processing queue improvements:
Messages are now queued per conversation (i.e. one-to-one chats, or MUCs). This allows
messages to be treated in parallel instead of waiting sequentially for each one to be
processed.
2026-04-21 12:52:16 +02:00
Goffi
e41d2cf26f core (xmpp): Remove host from SatMessageProtocol:
It is not needed anymore to pass `host` to most classes, as it is now available as a
global variable with `G`.
2026-04-21 12:52:16 +02:00
Goffi
fd58b78762 core, dependencies: update Tx-XMPP to v0.13.0:
`DiscoFeature.identities` format has evolved so `(category, map)` can be checked directly
again. The code using identities has been updated.
2026-04-21 12:49:30 +02:00
Goffi
dd79a42931 plugin XEP-0115: refactoring and complete implementation:
- the XEP-0115 implementation has been completed with validation, caps node handling in
  disco requests, hash generation fixes, and real support for xml:lang.
- the `generate_hash` method has been moved from disco where it's not used anymore to
  XEP-0115.
- Disco doesn't hash systematically, it nos use a per-jid cache for non XEP-0115
  supporting client.
- code modernisation, with use of `get_plugin_data` for Client data in XEP-0115, type
  hints, etc.
- More comments have been added to link algorithms steps to the relevant part in
  specification.
2026-04-18 01:08:01 +02:00
Goffi
f6db575ee4 core, dependencies: Update Tx-XMPP to 0.12:
Tx-XMPP 0.12 has beaking change in `discoFeature.identities` because it now supports
`xml:lang` attribute, so this update implies updating the code everywhere were this is
used.
2026-04-17 17:26:54 +02:00
Goffi
ec2cf0a522 core, dependencies: make Libervia compatible with Python 3.14:
- work around a deprecated behaviour in `asyncio.get_event_loop` until the fix is
  integrated in a released Twisted.
- update dependencies to have versions compatible with Python 3.14
- disable `term-image` which is bounded to incompatible Pillow version. It is unmaintained
  for 1 year, and will probably be removed soon in favor of `textual-image`.
2026-04-16 21:47:36 +02:00
Goffi
f5e0152b32 plugin XEP-0355: Namespace Delegation implementation:
The admin mode is implemented. It is needed to handle PEP with Pubsub Component.

rel 476
2026-04-14 23:04:04 +02:00
Goffi
73b410aa97 tests (unit/cli/calls): Skip tests in case of missing media or webrtc:
Test were raising exceptions when optional modules were missing (GStreamer related modules
for `webrtc`). Those are now catched so the tests are simply skipped in this case.

`MissingModule` is now inheriting from `ImportError`, as it's a natural subclass, and it
makes import error catching easier.
2026-04-09 21:47:46 +02:00
Goffi
57d3d8e07e memory (sqla): Improve handling of RSM in get_items:
- update queries to handle correctly the `before=""` case and RSM order (older to newer)
  while having correct order when `max_items` without RSM is used (then order it newer to
  older).
- put RSM code path in a separated method for better readability.
- check values of `max_items` and `from_index` and raise exception is they are not
  positive
- when using `before` or `after`, check that the item ID used as reference exists, and
  raise an exception otherwise.
- updated docstring to reflect the new behaviour.
- update pubsub cache use of `get_items` with RSM, to adapt to new behaviour.

rel 476
2026-04-07 14:58:42 +02:00
Goffi
cba0e388b6 core (types): fix name conflict with xmlstream + docstring for is_local. 2026-04-04 00:48:19 +02:00
Goffi
68da01a043 Dates update. 2026-03-31 12:57:17 +02:00
Goffi
c634204ac7 core (main): log errors during post_init. 2026-03-30 11:37:17 +02:00
Goffi
b9762ce474 core (launcher): log configuration filenames. 2026-03-30 11:37:17 +02:00
Goffi
80944e7a62 core (constants): Fix path for hidden config files in $HOME:
Config file can be hidden in $HOME (`~/.libervia.toml`), and the path was wrongly handled
probably following a change to use `Path`.
2026-03-30 11:37:17 +02:00