Commit graph libervia-backend/libervia/backend
Author SHA1 Message Date
Goffi
5b60aaf83c core: implement SCRAM-SHA auth algorithm:
Twisted auth mechanism are outdated, and as a result, Libervia was not supporting the
mandatory SCRAM-SHA auth mechanism. This patch implements it for SCRAM-SHA-1,
SCRAM-SHA-256 and SCRAM-SHA-512 variants.
2024-04-08 12:29:40 +02:00
Goffi
e8fb0a8a28 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Implement XEP-0343: Signaling WebRTC Data Channels in Jingle. The current version of the
XEP (0.3.1) has no implementation and contains some flaws. After discussing this on xsf@,
Daniel (from Conversations) mentioned that they had a sprint with Larma (from Dino) to
work on another version and provided me with this link:
https://gist.github.com/iNPUTmice/6c56f3e948cca517c5fb129016d99e74 . I have used it for my
implementation.

This implementation reuses work done on Jingle A/V call (notably XEP-0176 and XEP-0167
plugins), with adaptations. When used, XEP-0234 will not handle the file itself as it
normally does. This is because WebRTC has several implementations (browser for web
interface, GStreamer for others), and file/data must be handled directly by the frontend.
This is particularly important for web frontends, as the file is not sent from the backend
but from the end-user's browser device.

Among the changes, there are:

- XEP-0343 implementation.
- `file_send` bridge method now use serialised dict as output.
- New `BaseTransportHandler.is_usable` method which get content data and returns a boolean
  (default to `True`) to tell if this transport can actually be used in this context (when
  we are initiator). Used in webRTC case to see if call data are available.
- Support of `application` media type, and everything necessary to handle data channels.
- Better confirmation message, with file name, size and description when available.
- When file is accepted in preflight, it is specified in following `action_new` signal for
  actual file transfer. This way, frontend can avoid the display or 2 confirmation
  messages.
- XEP-0166: when not specified, default `content` name is now its index number instead of
  a UUID. This follows the behaviour of browsers.
- XEP-0353: better handling of events such as call taken by another device.
- various other updates.

rel 441
2024-04-06 12:57:23 +02:00
Goffi
ca7c061986 core (xmpp): Add a timeout for messages processing to avoid blocking the queue. 2024-04-06 12:21:04 +02:00
Goffi
0ee6a64e3b core (constants): use bool_type:
Using `bool` for type hint in `Const.bool_const` if conflicting with `Const.bool` method.
To avoid this, `bool_type` is used as an alias to `bool`.
2024-04-06 12:14:10 +02:00
Goffi
188c2c97ba migration: fix migration when XEP-0373 or XEP-0384 can't be imported:
Those plugins are using optional modules, and if their importation fails, there is
probably no data to migrate either.
2024-03-09 15:13:14 +01:00
Goffi
25aedf57d7 plugin XEP-0391: remove the need to have a OLDMEMO session started to decrypt:
It should not be mandatory to have an OLDMEMO session started to decrypt JET files, and
this was actually making a test failing.
2024-03-05 17:31:56 +01:00
Goffi
bb57b12329 plugin XEP-0313: fix value used in msg_from when from is not explicitely specified. 2024-03-05 17:31:56 +01:00
Goffi
b6383c557e plugin XEP-0060: fix incorrect type hint. 2024-03-05 17:31:56 +01:00
Goffi
a804e6a9dc plugin XEP-0234: fix action type when pre-flight file confirmation is confirmed:
the `C.META_TYPE_FILE` can't be used in this case as it is a preflight and we don't have
yet data such as progress ID. `C.META_TYPE_FILE` is used as a sub-type to help with dialog
management in frontend.
2024-03-05 17:31:49 +01:00
Goffi
f20e5d6103 plugin XEP-0384, XEP-0391: download missing devices list:
when a peer jid was not in our roster, devices list was not retrieved, resulting in failed
en/decryption. This patch does check it and download missing devices list in necessary.

There is no subscription managed yet, so the list won't be updated in case of new devices,
this should be addressed at some point.
2024-03-05 17:31:36 +01:00
Goffi
23e7b2720d plugin XEP-0384: be sure to have open access model for created nodes. 2024-03-05 17:31:36 +01:00
Goffi
0548f443ca plugin XEP-0373: fix serialisation of public_key_list 2024-03-05 17:31:36 +01:00
Goffi
3694bb3991 core (memory/migration):
Update XEP-0384 and `fe3a02cb4bec_convert_legacypickle_columns_to_json.py` migration to
properly handle (de)serialisation of `TrustMessageCacheEntry`.
2024-03-05 17:31:12 +01:00
Goffi
a8348576ae core: get rid of pickle:
Use of `pickle` to serialise data was a technical legacy that was causing trouble to store
in database, to update (if a class was serialised, a change could break update), and to
security (pickle can lead to code execution).

This patch remove all use of Pickle in favour in JSON, notably:
- for caching data, a Pydantic model is now used instead
- for SQLAlchemy model, the LegacyPickle is replaced by JSON serialisation
- in XEP-0373 a class `PublicKeyMetadata` was serialised. New method `from_dict` and
  `to_dict` method have been implemented to do serialisation.
- new methods to (de)serialise data can now be specified with Identity data types. It is
  notably used to (de)serialise `path` of avatars.

A migration script has been created to convert data (for upgrade or downgrade), with
special care for XEP-0373 case. Depending of size of database, this migration script can
be long to run.

rel 443
2024-02-23 13:31:04 +01:00
Goffi
dc8078fe4c core: use a user specific directory for PID file:
default location of pid file is now specific to logged user, this allow to run several
instances of Libervia by different users on the same machine without PID conflicts.
2024-01-14 17:48:02 +01:00
Goffi
133fe9c6fe plugin XEP-0444: fix emoji check and ID used 2023-12-13 22:00:25 +01:00
Goffi
b571b0d6e2 plugin XEP-0424: fix ID used and recipients 2023-12-13 22:00:25 +01:00
Goffi
817d7b6daf plugin XEP-0308: fix ID used, recipients and author check. 2023-12-13 22:00:25 +01:00
Goffi
5470bbf7b9 plugin XEP-0359: if no origin ID is found, use <message> ID instead:
This way, we always have the right ID to check for non groupchat message in
`History.origin_id`.
2023-12-13 22:00:25 +01:00
Goffi
79fd3d7c13 plugin XEP-0045: avoir crash if subject is not set when _get_room_joined_args is called. 2023-12-13 22:00:25 +01:00
Goffi
6fa46e20fd core (launcher): new wait_for_service option:
if `wait_for_service` is used in `[DEFAULT]`, the service at the specified host/port is
waited for before starting the backend. This is useful in the situation where we need to
be sure that something is started before running, e.g. in a container.
2023-12-13 22:00:25 +01:00
Goffi
e14dd9da8b core: add new init_script_path option:
`init_script_path` option can be used in `[DEFAULTS]` to run a script at the end of
backend initialisation. A new `init_pre_script` method is used to wait for backend to
reach this stage (designed to be used mostly by CLI frontend), then the usual `ready_get`
method is finished once the script is finished.
2023-12-13 22:00:22 +01:00
Goffi
258c99b3c5 plugin forums: parsing fix + formatting:
- reformatted with black
- fix parsing of forums
- minor improvements
2023-12-12 12:17:15 +01:00
Goffi
b634e41ac0 core, doc, cli (forums): new forums set commands + doc:
- document the fact that if an empty `uri` is used, the forum node is created
  automatically
- new `forums/set` CLI commands and its documentation
2023-12-11 18:10:27 +01:00
Goffi
05bdfe122a component AP gateway: be sure to have a string for error message. 2023-12-11 18:07:58 +01:00
Goffi
1dd8a46572 plugin XEP-0277: fix comments node handling when parent node doesn't exist. 2023-12-11 00:46:34 +01:00
Goffi
ff5c2e0ea5 plugin ad-hoc registration: Implement plugin to handle registration links:
registration links are used in web frontend to allow registration with secret links when
it's normally closed.
2023-12-10 18:32:04 +01:00
Goffi
f1cc34cc53 plugin XEP-0050: small code quality improvements + add C.ENTITY_ADMINS magic key to allow administrators profiles 2023-12-10 15:08:08 +01:00
Goffi
b8d00757d3 plugin XEP-053, component AP gateway: use the new trigger.add_with_check method 2023-12-09 19:20:13 +01:00
Goffi
ba1475962e core (tools/trigger): new add_with_check method:
this method add a wrapper which will skip the trigger is the plugin is not available in
the session (e.g. a component which doesn't use the plugin).
2023-12-09 19:19:26 +01:00
Goffi
2db4ba9b3e plugin XEP-0471: modify variable name to be linter friendly. 2023-12-09 19:17:34 +01:00
Goffi
bbac8b6822 plugin IP: fix use of legacy URL + coroutine use:
An https:/salut-a-toi.org URL was used to retrieve external IP, but it's not valid
anymore, resulting in an exception. This feature is currently disabled.

Also moved several methods from legacy inline callbacks to coroutines.
2023-12-09 14:30:54 +01:00
Goffi
34fa69661c core: fix path in get_local_path:
`local_dir` was not used in final path, resulting in workind dir used instead or actual
local path.
2023-12-09 14:05:02 +01:00
Goffi
d80c4e89dc plugin XEP-0277, doc: conflict is now checked and avoided if user_friendly_id_suffix is False, doc updated 2023-12-05 13:39:03 +01:00
Goffi
4db2a87feb plugin XEP-0277: generate and parse altertate links with the new alt_links data in extra 2023-12-05 13:14:03 +01:00
Goffi
f35d799e28 Plugin XEP-0277: Add metadata to prevent adding random suffixes to generated user-friendly IDs. 2023-12-05 13:10:21 +01:00
Goffi
6f8230804f core (constants): user platform temporary dir by default for PID files 2023-12-04 17:51:28 +01:00
Goffi
510b6fb62c component AP gateway: log a warning instead of raising an exception in onMessage:
if something goes wrong, a warning is logged instead of raising a failing in `onMessage`'s
`get_ap_actor_id_from_account` and `sign_and_post` calls.
2023-12-01 18:22:26 +01:00
Goffi
0979b3fee3 core (message): fix calling of post treatments during message workflow 2023-12-01 18:20:27 +01:00
Goffi
ec2a637847 plugin ad-hoc D-Bus: fix deprecated use of python-dbus:
the plugin was using python-dbus which is deprecated in the backend in the favor of
TxDBus. Methods calls have been updated, and the plugin works again, but there seems to be
still some issues (warnings in the logs). Those will be fixed later.
2023-12-01 15:22:55 +01:00
Goffi
3c35dea8b1 plugin XEP-0424: message retraction update:
- follow specification update (with namespace bump)
- retract from history on message reception for group chat
- send bridge message
2023-11-30 13:23:53 +01:00
Goffi
ee4caf8ee7 template: add a bare_jid filter 2023-11-28 17:41:49 +01:00
Goffi
67e8367ff3 plugin XEP-0384: fix trigger used for OLDMEMO:
OLDMEMO was applied at the `send_message_data` trigger level, however this was missing
stanza constructed without message data (which is notably the case for XEP-0308). This has
been fixed by using the `send` trigger instead. As a side effect, the same code is now
used for TWOMEMO and OLDMEMO, making it simpler.
2023-11-28 17:41:02 +01:00
Goffi
85cecd3d30 plugin XEP-0308: implement Last Message Correction 2023-11-28 17:38:31 +01:00
Goffi
c9c886480e models (core): separate MessageEditData from MessageEdition:
`MessageEditData` is used to carry a new `MessageData` when an edition has happened, while
`MessageEdition` is used to send changes to do for a new edition.
2023-11-28 17:37:02 +01:00
Goffi
445d5c088e core (memory/sqla_mapping): delete-orphan in History:
add `cascade=delete-orphan` to History's `messages`, `subjects` and `thread`, to make
modification of those attributes easier.
2023-11-28 17:35:20 +01:00
Goffi
191d06126e core (memory/sqla): add id filter in history_get 2023-11-28 17:26:45 +01:00
Goffi
70f3502429 core (memory/memory): fix the use of empty from_jid and to_jid in history_get 2023-11-28 17:25:47 +01:00
Goffi
39dc28fedf tools (common/data_objects): expose message's extra field. 2023-11-22 15:11:25 +01:00
Goffi
2b501c70d7 plugin XEP-0444: complete implementation:
"Message Reactions" implementation is now working and updating history. The
`message_reactions_set` bridge method can be used by frontend to `replace`, `add`,
`remove` or `toggle` reactions. History is properly updated, and signal are sent when
necessary.
2023-11-22 15:10:04 +01:00