Commit Graph

10426 Commits

Author SHA1 Message Date
Benjamin Bouvier
ce95b6089f doc(event cache): add the copyright notice and basic module doc comment 2024-11-28 11:48:46 +01:00
Benjamin Bouvier
c6ba71ae33 feat(event cache): allow reloading from the store, and test functionalities
This required adding support for *reading* out of the event cache, for
the sqlite backend. This paves the way for the next PR (reload from the
cache), and it should also help with testing at the `EventCacheStore`
trait layer some day.
2024-11-28 11:48:46 +01:00
Benjamin Bouvier
e57d38cf57 doc(common): add a note that a decrypted raw event always has a room id 2024-11-28 11:48:46 +01:00
Benjamin Bouvier
9bea0cff24 feat(event cache): implement the sqlite backend for events 2024-11-28 11:48:46 +01:00
Benjamin Bouvier
197da2c585 doc(timeline): tweak comments when inserting a new item
A comment was duplicating (the first trace! that's removed here), and
the second block comment only applied to new items, and was not as
concise as it could be.
2024-11-28 10:09:50 +01:00
Ivan Enderlin
d2ecd745f6 chore(ui): Unify the logic for timeline item insertions
This patch unifies the logic for inserting timeline items at `Start`
and `End` positions. Both `TimelineItemPositions` can share the same
implementation, making separate logic unnecessary. Previously, `End`
included a duplicated events check as well, while `Start` did not, leading
to inconsistency.

The changes strictly involve moving and refactoring, with no functional
modifications.
2024-11-28 08:25:16 +01:00
Damir Jelić
e99939db85 refactor(crypto): Rename the IncomingResponse enum to AnyIncomingResponse 2024-11-27 19:55:27 +01:00
Damir Jelić
600a708e7b refactor!(crypto): Rename the OutgoingRequests enum to AnyOutgoingRequest 2024-11-27 19:55:27 +01:00
Damir Jelić
a94a5f1716 chore(crypto): Split out the requests module 2024-11-27 19:55:27 +01:00
Damir Jelić
46064680ce refactor!(crypto): Don't re-export the request types from the request module 2024-11-27 19:55:27 +01:00
Damir Jelić
6fe5acfc97 refactor(crypto): Move the requests module under the types module 2024-11-27 19:55:27 +01:00
Valere
3369903766 Merge pull request #4275 from matrix-org/valere/utd_hook_historical_message
feat(utd_hook): Report device-historical expected UTD with new reason
2024-11-27 18:23:53 +01:00
Valere
a0c86d9645 feat(utd_hook): Report historical expected UTD with new reason
This PR introduces a new variant to `UtdCause` specifically for device-historical messages (`HistoricalMessage`). These messages cannot be decrypted if key storage is inaccessible. Applications can leverage this new variant to provide more informative error messages to users.
2024-11-27 18:09:06 +01:00
Damir Jelić
7a454888a3 chore: Bump the deps and move some of them to the workspace 2024-11-27 17:03:50 +01:00
Ivan Enderlin
37f52e1c6c fix(common): LinkedChunk emits an Update::NewItemsChunk when constructed.
This patch updates `LinkedChunk::new_with_update_history` to emit an
`Update::NewItemsChunk` because the first chunk is created and it must
emit an update accordingly.
2024-11-27 14:40:26 +01:00
Ivan Enderlin
185423539e test(ui): Fix the test_echo test.
This patch fixes the `test_echo` test. It was doing the following:

* client sends an event to the server,
* servers acknowledges with the ID `$wWgymRfo7ri1uQx0NXO40vLJ`,
* client syncs and the server returns one event with ID `$7at8sd:localhost`,
* the test expects those 2 events to be the same!, which is incorrect.

The test was working because the transaction IDs are the same, but
that's an abuse of the existing code (the code will change soon, another
patch is coming). Whatever the code does: the connection must be based
on the event ID, not the transaction ID.
2024-11-27 14:29:24 +01:00
Stefan Ceriu
9e20659d5d chore: bring back MediaSource JSON serialization methods matrix-sdk-ffi/20241127 2024-11-27 15:13:24 +02:00
Damir Jelić
7783188769 chore: Box the OidcSession so the AuthSession enum isn't unnecessarily big 2024-11-27 13:23:34 +01:00
Damir Jelić
514af54c4c chore: Fix some clippy warnings about our docs 2024-11-27 13:23:34 +01:00
Damir Jelić
ad615b7612 chore: Fix some clippy lint warnings around the usage of map_or 2024-11-27 13:23:34 +01:00
Damir Jelić
a1b7906a7d chore: Fix some clippy lints around lifetimes 2024-11-27 13:23:34 +01:00
Damir Jelić
79c8d2c345 chore: Don't build the docs for xtask
Building the docs for xtask spews a bunch of unexpected cfg warnings. As
these warnings come from a macro in a dependency and the docs for xtask
don't exist nor will, let's just not build them with the rest of the
docs.
2024-11-27 13:23:34 +01:00
Damir Jelić
dcf6af405d chore: Silence unexpected cfg warnings
These are all coming from macro invocations of macros that are defined
in other crates. It's likely a clippy issue. We should try to revert
this the next time we bump the nightly version we're using.
2024-11-27 13:23:34 +01:00
Damir Jelić
bb598b61a5 chore: Bump the nightly version we use for the CI 2024-11-27 13:23:34 +01:00
Ivan Enderlin
1c554c4912 chore(ui): Clarifies what TimelineItemPosition::UpdateDecrypted holds.
This patch tries to clear confusion around
`TimelineItemPosition::UpdateDecrypted(usize)`: it does contains
a timeline item index. This patch changes to
`TimelineItemPosition::UpdateDecrypted { timeline_item_index: usize }`
2024-11-27 12:04:59 +01:00
Benjamin Bouvier
21f8b7ed31 refactor(linked chunk): simplify further impl of the LinkedChunkRebuilder 2024-11-27 11:01:44 +01:00
Benjamin Bouvier
23ee8e25dd feat(linked chunk): add a way to reconstruct a linked chunk from its raw representation 2024-11-27 11:01:44 +01:00
Benjamin Bouvier
1098095846 refactor(linked chunk): replace LinkedChunk::len() with a simpler implementation
It's unused so it's mostly cosmetic, and it's trivial to reimplement
using `linked_chunk.items().count()`; let's do that instead of keeping
the perfect exact count synchronized with the chunks, which pollutes the
code in a few places.
2024-11-27 10:16:12 +01:00
Ivan Enderlin
3e7d7e8a31 chore(ui): Rename TimelineEnd to TimelineNewItemPosition.
This patch renames `TimelineEnd` into `TimelineNewItemPosition` for
2 reasons:

1. In the following patches, we will introduce a new variant to insert
   at a specific index, so the suffix `End` would no longer make sense.

2. It's exactly like `TimelineItemPosition` except that it's used
   only and strictly only to add **new** items, which is why we can't use
   `TimelineItemPosition` because it contains the `UpdateDecrypted`
   variant. This renaming reflects it's only about **new** items.

This patch takes the opportunity to move the `RemoteEventOrigin` inside
`TimelineNewItemPosition` to simplify method signatures. They always
go together.
2024-11-26 20:29:31 +01:00
Benjamin Bouvier
2c45316bcb fixup! fix(room): make Room::history_visibility() return an Option 2024-11-26 19:02:46 +01:00
Benjamin Bouvier
8dc7c1f876 fix(ui): have the room list service require the create and history visibility events
These two are required to properly compute the room preview of a joined
room:

- m.room.create ends up filling the `room_type` (space or not)
- m.room.history_visibility ends up filling the `is_world_readable`
  field.
2024-11-26 19:02:46 +01:00
Benjamin Bouvier
db84936dcd fix(room): make Room::history_visibility() return an Option
And introduce `Room::history_visibility_or_default()` to return a better
sensible default, according to the spec.
2024-11-26 19:02:46 +01:00
Kévin Commaille
75d7d07013 chore(ffi): Fix thumbnail size info
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-11-26 15:45:54 +01:00
Kévin Commaille
d4d5f45edc feat(media)!: Make all fields of Thumbnail required
It seems sensible to assume that if a client is able to generate a thumbnail,
it should be able to get all this information for it too.
A thumbnail with no information is not really useful, as we don't know when it could be used instead of the original image.

Removes `BaseThumbnailInfo`.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-11-26 15:20:07 +01:00
Kévin Commaille
d0257d1cb2 refactor(media): Add method to split Thumbnail into parts
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-11-26 15:20:07 +01:00
Kévin Commaille
ecf44348cf fix(client): Do not use the encrypted original file's content type as the encrypted thumbnail's content type
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-11-26 15:20:07 +01:00
Ivan Enderlin
cc8bc05537 refactor: RoomEvents::reset really clear the linked chunk.
This patch updates `RoomEvents::reset` to not drop the `LinkedChunk` to
clear it.
2024-11-26 15:19:24 +01:00
Ivan Enderlin
728d646ce2 fix(common): AsVector clears its internal state on Update::Clear.
This patch fixes a bug in `AsVector`: when an `Update::Clear` value
is received, `AsVector`'s internal state must be cleared too, i.e. the
`UpdateToVectorDiff::chunks` field should be reset to an initial value!

This patch adds a test to ensure this works as expected.
2024-11-26 15:19:24 +01:00
Stefan Ceriu
ca397dca0f feat(ffi): wrap Ruma MediaSources and run validations before passing them over FFI
Ruma doesn't currently validate mxuri's and as such `MediaSource`s passed over FFI can contain invalid/empty URLs. This change introduces a wrapper type around Ruma's and failable transformations so that appropiate actions can be taken beforehand e.g. returning a `TimelineItemContent::FailedToParseMessageLike` or nil-ing out the thumbnail info.
2024-11-26 15:40:24 +02:00
Benjamin Bouvier
1fbe6815c3 task(event cache): log whenever we receive an ignore user list change 2024-11-26 12:29:34 +01:00
Ivan Enderlin
c61f70727f fix: RelationalLinkedChunk handles Update::Clear.
What the title says.
2024-11-25 17:45:01 +01:00
Ivan Enderlin
2abbf58825 feat(common): Implement LinkedChunk::clear.
This patch implements `LinkedChunk::clear`. The code from `impl Drop
for LinkedChunk` has been moved inside `Ends::clear`, and replaced by
a simple `self.links.clear()`. In addition, `LinkedChunk::clear` indeed
calls `self.links.clear()` but also resets all fields.

This patch adds the `Clear` variant to `Update`.

This patch updates `AsVector` to emit a `VectorDiff::Clear` on
`Update::Clear`.

Finally, this patch adds the necessary tests.
2024-11-25 17:08:43 +01:00
Ivan Enderlin
b979b2ea1e doc(common): Fix typos. 2024-11-25 17:08:27 +01:00
Ivan Enderlin
24b968ad39 refactor: EventCacheStore::handle_linked_chunk_updates takes a Vec<Update>.
This patch updates `EventCacheStore::handle_linked_chunk_updates` to
take a `Vec<Update<Item, Gap>>` instead of `&[Update<Item, Gap>]`.
In fact, `linked_chunk::ObservableUpdates::take()` already returns a
`Vec<Update<Item, Gap>>`; we can simply forward this `Vec` up to here
without any further clones.
2024-11-25 17:08:27 +01:00
Ivan Enderlin
faa8aa2b9c fix(base): Move all fields of MemoryStore inside a StdRwLock<_>.
This patch creates a new `MemoryStoreInner` and moves all fields from
`MemoryStore` into this new type. All locks are removed, but a new lock
is added around `MemoryStoreInner`. That way we have a single lock.
2024-11-25 17:08:27 +01:00
Ivan Enderlin
db9ee9d87b refactor: Add constructors for Position and ChunkIdentifier.
This patch adds constructors for `Position` and `ChunkIdentifier` so
that we keep their inner values private.
2024-11-25 17:08:27 +01:00
Ivan Enderlin
1dbb494b94 feat(common): RelationalLinkedChunk stores the RoomId. 2024-11-25 17:08:27 +01:00
Ivan Enderlin
fe52b4cb78 feat(common): EventCacheStore::handle_linked_chunk_updates takes a &RoomId. 2024-11-25 17:08:27 +01:00
Ivan Enderlin
5519442ad8 doc(common): Fix a typo. 2024-11-25 17:08:27 +01:00
Ivan Enderlin
88363d8033 feat(base): MemoryStore uses RelationalLinkedChunk to store events.
That's it.
2024-11-25 17:08:27 +01:00