Commit Graph

13223 Commits

Author SHA1 Message Date
Ivan Enderlin 9443f455a4 Test Media caching, and re-implement it inside MemoryStore
Test Media caching, and re-implement it inside `MemoryStore`
2023-12-14 15:51:04 +01:00
Ivan Enderlin 384deec1c8 chore(base): Simplify code. 2023-12-14 15:39:24 +01:00
Kévin Commaille 5310f41cda integration-testing: Add test for QR verification
And check room ID in SAS test.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 15:23:16 +01:00
Ivan Enderlin 95a1db8fc7 Merge pull request #2947 from matrix-org/andybalaam/use-correct-limit-in-chunk_large_query_over
Use the limit() method to find the variable limit in chunk_large_query_over
2023-12-14 14:31:40 +01:00
Ivan Enderlin 3d9dffa3b7 chore(base): Remove unused imports. 2023-12-14 14:18:56 +01:00
Andy Balaam 3d7e1d5989 Merge branch 'main' into andybalaam/use-correct-limit-in-chunk_large_query_over 2023-12-14 13:17:06 +00:00
Ivan Enderlin a46bf76d74 test(base): Improve test_media_content.
This patch improves `test_media_content` to ensure that, in case of
multiple medias, only the expected ones are removed. Previously, the
test wasn't testing _other_ medias that should be kept in case of
removals.

This patch continues to improve `test_media_content` to ensure that the
content of the media are the expected ones.

Finally, this patch updates the `MemoryStore` implementation to make
tests happy.
2023-12-14 14:15:01 +01:00
Ivan Enderlin 326935db63 feat(base): Correct implementations for MemoryStore media removal.
This patch rewrites `MemoryStore::add_media_content`,
`::get_media_content`, `::remove_media_content` and
`::remove_media_content_for_uri` to (i) work on `mxc://` URI instead
of “unique key”, and (ii) to handle removal correctly thanks to the new
`RingBuffer::remove` method.
2023-12-14 13:54:12 +01:00
Ivan Enderlin 416bc8b0e4 feat(base): Implement Media::uri.
This new method returns the `MxcUri` associated to the `Media`.
2023-12-14 13:53:23 +01:00
Ivan Enderlin edd113a17c feat(common): Implement RingBuffer::remove. 2023-12-14 13:28:17 +01:00
Ivan Enderlin 66411d7b2e Merge pull request #2946 from matrix-org/andybalaam/tests-for-repeat_vars
Unit tests for the repeat_vars function
2023-12-14 13:10:12 +01:00
Ivan Enderlin 4a53bf1f3d Merge pull request #2945 from matrix-org/andybalaam/limits-access-for-sqlite
Provide a limit() method in sqlite to find limit values
2023-12-14 13:10:02 +01:00
Andy Balaam a3aa55ce91 Use the limit() method to find the variable limit
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2023-12-14 11:31:01 +00:00
Andy Balaam 0066ae6614 Unit tests for the repeat_vars function
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2023-12-14 11:26:43 +00:00
Andy Balaam 17ebc23719 Provide a limit() method in sqlite to find limit values
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2023-12-14 11:21:25 +00:00
Ivan Enderlin cdb3449ce2 test(sdk): Test that Media::get_media_content with caching works. 2023-12-14 12:11:24 +01:00
Ivan Enderlin c5b11fc2f8 feat(sdk): Simplify code from Media::get_media_content.
If `use_cache` is true and the cache exists, let's return everything in
one go instead of declaring a `content` variable. It makes the code
easier to read and to understand.
2023-12-14 12:10:08 +01:00
Ivan Enderlin 2ad6acb930 doc(common): Add documentation for RingBuffer::drain. 2023-12-14 12:07:08 +01:00
Ivan Enderlin dac779f4fc test(base): Re-implement a super basic media cache for MemoryStore.
This is a rather over simplistic media cache implementation for the
`MemoryStore`.

It's based on a `RingBuffer` of size 20.

`remove_media_content` pops all medias until the correct one is met (if
it exists). `remove_media_content_for_uri` removes all medias, it
ignores the URI.
2023-12-14 12:04:58 +01:00
Kévin Commaille e2ea19ee77 Add rule kind to error messages
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille cc38768bf4 notification settings: Don't error if poll start rules are not found
These rules are unstable so they might not be
found in every ruleset.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille c87bd4d4ec notification settings: Log errors from requests
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille 5700c700f0 error: Use NotificationSettingsError::RuleNotFound's rule ID in display impl
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille fff9882792 notification settings: Rely more on Ruma methods
Simplifies code.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille 45f8ff11c2 notification settings: Derive Copy for enum types
This a good practice for inexpensive types
and avoids to have to call `.clone()` explicitely.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille 7c9d842d05 notification settings: Use private method to get poll start rule ID
A `From` implementation is part of the public API
and this conversion does not make sense outside of the module.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-14 11:39:42 +01:00
Kévin Commaille c3706d7ca0 notification settings: Allow to manage keywords (#2905)
* notification settings: Allow to manage keywords
* Fix wording of docs

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Signed-off-by: Kévin Commaille <76261501+zecakeh@users.noreply.github.com>
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
2023-12-14 11:16:40 +01:00
Ivan Enderlin b314da37b8 feat(ffi): Timeline::send_image and send_video takes an optional thumbnail_url
feat(ffi): `Timeline::send_image` and `send_video` takes an optional `thumbnail_url`
2023-12-14 10:48:16 +01:00
Ivan Enderlin 02ba6c0dbe feat(ffi): Client::*media* are now async
feat(ffi): `Client::*media*` are now async
2023-12-14 09:14:39 +01:00
Ivan Enderlin 22d9c62262 feat(ffi): Timeline::send_image and send_video takes an optional thumbnail_url.
This patch updates `Timeline::send_image` and `Timeline::send_video` so
that `thumbnail_url` is now an `Option<String>`.

The idea is to allow sending an image or a video without a thumbnail.
2023-12-13 17:07:03 +01:00
Ivan Enderlin 18b6387a7a Merge pull request #2935 from matrix-org/rav/fix_nonmonotonic_panic
Configure `Instant` wasm polyfill to use monotonic time
2023-12-13 15:57:32 +01:00
Ivan Enderlin c5ddba2e13 feat(ffi): Client::*media* are now async.
This patch removes `RUNTIME.block_on` inside `Client::get_media_file`,
`::upload_media`, `::get_media_content` and `::get_media_thumbnail`, and
makes those methods async.
2023-12-13 15:33:01 +01:00
Kévin Commaille 9756ed28cf verification: Expose the room ID where the verification is happening
Useful if we want to know in what room
we just sent a VerificationRequest,
with UserIdentity::request_verification

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-13 15:22:13 +01:00
Richard van der Hoff 5701cea51e Configure Instant wasm polyfill to use monotonic time
With the `inaccurate` feature, this polyfill uses `Date.now()` to emulate
`Instant`, which is not monotonic, causing problems like
https://github.com/element-hq/element-web/issues/26416.
2023-12-13 12:08:54 +00:00
Andy Balaam 794b7ead7a Clippy fixes 2023-12-13 08:43:59 +00:00
Andy Balaam f879f3d866 Formatting 2023-12-13 08:32:00 +00:00
Andy Balaam 4ebb8e29b4 Provide CryptoStore::mark_sessions_as_backed_up on stores and use it in BackupMachine::mark_request_as_sent
Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
2023-12-12 16:09:22 +00:00
Doug d764fca7da xtask: Move all the Swift files found
… and fix build swift errors.

- The XCFramework was being built with dylibs which aren't supported on iOS
- The tests build was attempting to generate uniffi from a moved file
2023-12-12 16:51:49 +01:00
Jonas Platte 3b7f9f7361 Reapply "bindings: Use new uniffi-bindgen build mode"
This reverts commit 0d24bcf6e5.
2023-12-12 16:51:49 +01:00
Doug 73770b78bb room: Add test for unban_user. 2023-12-12 16:13:09 +01:00
Doug 7cffc34984 ffi: Support banning, unbanning and kicking users. 2023-12-12 16:13:09 +01:00
Benjamin Bouvier c4ef967523 dx: tweak debugging of user/device pairs missing a session 2023-12-11 17:11:11 +01:00
Kévin Commaille f0b378179e matrix auth: Await save_session_callback
Otherwise the future will not run.
Changes the corresponding test to fail with the old behavior.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-11 16:54:53 +01:00
Kévin Commaille ee344112f3 verification: Expose the QrVerificationState and the stream for its changes
Allows to have a similar API as SasVerification

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-11 16:13:56 +01:00
Benoit Marty 1f52aca210 Fix typo in doc. 2023-12-11 12:13:05 +01:00
Kévin Commaille 74091de8ef sdk: Make sure "testing" feature is enabled for integration tests
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-11 11:53:25 +01:00
Kévin Commaille 0f6efc391a client: Allow to create encrypted DM
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2023-12-11 11:14:19 +01:00
Mauro c707e1f17e feat(bindings): expose a function to send private read receipts (#2906) 2023-12-11 09:29:06 +00:00
Benjamin Bouvier 5ab69f7400 ffi: add emoji indices in the session verification data + use decimals as a fallback 2023-12-08 14:48:48 +01:00
Jonas Platte e652069896 sdk: Use crates.io release of mas-oidc-client 2023-12-07 17:34:36 +01:00