Skip to content

Commit 6a340f4

Browse files
committed
Merge branch 'main' into toger5/widget-driver-matrix-api-errors
2 parents 88ee196 + a6e1f05 commit 6a340f4

File tree

51 files changed

+1380
-1034
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1380
-1034
lines changed

.deny.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ allow-git = [
5555
"https://github.com/element-hq/tracing.git",
5656
# Sam as for the tracing dependency.
5757
"https://github.com/element-hq/paranoid-android.git",
58+
# Well, it's Ruma.
59+
"https://github.com/ruma/ruma",
5860
# A patch override for the bindings: https://github.com/rodrimati1992/const_panic/pull/10
5961
"https://github.com/jplatte/const_panic",
6062
# A patch override for the bindings: https://github.com/smol-rs/async-compat/pull/22

CONTRIBUTING.md

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,46 @@ that is, just the branch name.)
4545

4646
# Writing changelog entries
4747

48-
We aim to maintain clear and informative changelogs that accurately reflect the
49-
changes in our project. This guide will help you write useful changelog entries
50-
using git-cliff, which fetches changelog entries from commit messages.
48+
Our goal is to maintain clear, concise, and informative changelogs that
49+
accurately document changes in the project. Changelog entries should be written
50+
manually for each crate in the `/crates/$CRATE_NAME/Changelog.md` file.
51+
52+
Be sure to include a link to the pull request for additional context. A
53+
well-written changelog entry should be understandable even to those who may not
54+
be deeply familiar with the project. Provide enough context to ensure clarity
55+
and ease of understanding.
56+
57+
A couple of examples of bad changelog entry would look like:
58+
59+
```markdown
60+
- Fixed a panic.
61+
```
62+
63+
```markdown
64+
- Added the Bar function to Foo.
65+
```
66+
67+
A good example of a changelog entry could look like the following:
68+
69+
```markdown
70+
- Use the inviter's server name and the server name from the room alias as
71+
fallback values for the via parameter when requesting the room summary from
72+
the homeserver. This ensures requests succeed even when the room being
73+
previewed is hosted on a federated server.
74+
([#4357](https://github.com/matrix-org/matrix-rust-sdk/pull/4357))
75+
```
76+
77+
For security-related changelog entries, please include the following additional
78+
details alongside the pull request number:
79+
80+
* Impact: Clearly describe the issue's potential impact on users or systems.
81+
* CVE Number: If available, include the CVE (Common Vulnerabilities and Exposures) identifier.
82+
* GitHub Advisory Link: Provide a link to the corresponding GitHub security advisory for further context.
83+
84+
```markdown
85+
- Use a constant-time Base64 encoder for secret key material to mitigate
86+
side-channel attacks leaking secret key material ([#156](https://github.com/matrix-org/vodozemac/pull/156)) (Low, [CVE-2024-40640](https://www.cve.org/CVERecord?id=CVE-2024-40640), [GHSA-j8cm-g7r6-hfpq](https://github.com/matrix-org/vodozemac/security/advisories/GHSA-j8cm-g7r6-hfpq)).
87+
```
5188

5289
## Commit message format
5390

@@ -74,45 +111,20 @@ The type of changes which will be included in changelogs is one of the following
74111
The scope is optional and can specify the area of the codebase affected (e.g.,
75112
olm, cipher).
76113

77-
### Changelog trailer
78-
79-
In addition to the Conventional Commit format, you can use the `Changelog` git
80-
trailer to specify the changelog message explicitly. When that trailer is
81-
present, its value will be used as the changelog entry instead of the commit's
82-
leading line. The `Breaking-Change` git trailer can be used in a similar manner
83-
if the changelog entry should be marked as a breaking change.
84-
85-
86-
#### Example commit message
87-
88-
```
89-
feat: Add a method to encode Ed25519 public keys to Base64
90-
91-
This patch adds the `Ed25519PublicKey::to_base64()` method, which allows us to
92-
stringify Ed25519 and thus present them to users. It's also commonly used when
93-
Ed25519 keys need to be inserted into JSON.
94-
95-
Changelog: Add the `Ed25519PublicKey::to_base64()` method which can be used to
96-
stringify the Ed25519 public key.
97-
```
98-
99-
In this commit message, the content specified in the `Changelog` trailer will be
100-
used for the changelog entry.
101-
102-
Be careful to add at least one whitespace after new lines to create a paragraph.
103-
104114
### Security fixes
105115

106116
Commits addressing security vulnerabilities must include specific trailers for
107-
vulnerability metadata. These commits are required to include at least the
108-
`Security-Impact` trailer to indicate that the commit is a security fix.
117+
vulnerability metadata, which should also be reflected in the corresponding
118+
changelog entry.
109119

110-
Security issues have some additional git-trailers:
120+
The metadata must be included in the following git-trailers:
111121

112122
* `Security-Impact`: The magnitude of harm that can be expected, i.e. low/moderate/high/critical.
113123
* `CVE`: The CVE that was assigned to this issue.
114124
* `GitHub-Advisory`: The GitHub advisory identifier.
115125

126+
Please include all of the fields that are available.
127+
116128
Example:
117129

118130
```
@@ -131,9 +143,6 @@ material.
131143
Security-Impact: Low
132144
CVE: CVE-2024-40640
133145
GitHub-Advisory: GHSA-j8cm-g7r6-hfpq
134-
135-
Changelog: Use a constant-time Base64 encoder for secret key material
136-
to mitigate side-channel attacks leaking secret key material.
137146
```
138147

139148
## Review process

Cargo.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ The procedure is as follows:
1717
git switch -c release-x.y.z
1818
  ```
1919
20-
2. Prepare the release. This will update the `README.md`, prepend the `CHANGELOG.md`
21-
file using `git cliff`, and bump the version in the `Cargo.toml` file.
20+
2. Prepare the release. This will update the `README.md`, set the versions in
21+
the `CHANGELOG.md` file, and bump the version in the `Cargo.toml` file.
2222
2323
```bash
2424
cargo xtask release prepare --execute minor|patch|rc

bindings/matrix-sdk-crypto-ffi/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mod tests {
112112

113113
#[test]
114114
fn test_withheld_error_mapping() {
115-
use matrix_sdk_crypto::types::events::room_key_withheld::WithheldCode;
115+
use matrix_sdk_common::deserialized_responses::WithheldCode;
116116

117117
let inner_error = MegolmError::MissingRoomKey(Some(WithheldCode::Unverified));
118118

bindings/matrix-sdk-ffi/src/event.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use matrix_sdk::IdParseError;
33
use matrix_sdk_ui::timeline::TimelineEventItemId;
44
use ruma::{
55
events::{
6-
room::{message::Relation, redaction::SyncRoomRedactionEvent},
6+
room::{
7+
message::{MessageType as RumaMessageType, Relation},
8+
redaction::SyncRoomRedactionEvent,
9+
},
710
AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent,
811
MessageLikeEventContent as RumaMessageLikeEventContent, RedactContent,
912
RedactedStateEventContent, StaticStateEventContent, SyncMessageLikeEvent, SyncStateEvent,
@@ -356,6 +359,39 @@ impl From<MessageLikeEventType> for ruma::events::MessageLikeEventType {
356359
}
357360
}
358361

362+
#[derive(Debug, PartialEq, Clone, uniffi::Enum)]
363+
pub enum RoomMessageEventMessageType {
364+
Audio,
365+
Emote,
366+
File,
367+
Image,
368+
Location,
369+
Notice,
370+
ServerNotice,
371+
Text,
372+
Video,
373+
VerificationRequest,
374+
Other,
375+
}
376+
377+
impl From<RumaMessageType> for RoomMessageEventMessageType {
378+
fn from(val: ruma::events::room::message::MessageType) -> Self {
379+
match val {
380+
RumaMessageType::Audio { .. } => Self::Audio,
381+
RumaMessageType::Emote { .. } => Self::Emote,
382+
RumaMessageType::File { .. } => Self::File,
383+
RumaMessageType::Image { .. } => Self::Image,
384+
RumaMessageType::Location { .. } => Self::Location,
385+
RumaMessageType::Notice { .. } => Self::Notice,
386+
RumaMessageType::ServerNotice { .. } => Self::ServerNotice,
387+
RumaMessageType::Text { .. } => Self::Text,
388+
RumaMessageType::Video { .. } => Self::Video,
389+
RumaMessageType::VerificationRequest { .. } => Self::VerificationRequest,
390+
_ => Self::Other,
391+
}
392+
}
393+
}
394+
359395
/// Contains the 2 possible identifiers of an event, either it has a remote
360396
/// event id or a local transaction id, never both or none.
361397
#[derive(Clone, uniffi::Enum)]

bindings/matrix-sdk-ffi/src/room.rs

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use matrix_sdk::{
1111
ComposerDraft as SdkComposerDraft, ComposerDraftType as SdkComposerDraftType,
1212
RoomHero as SdkRoomHero, RoomMemberships, RoomState,
1313
};
14-
use matrix_sdk_ui::timeline::{PaginationError, RoomExt, TimelineFocus};
14+
use matrix_sdk_ui::timeline::{default_event_filter, PaginationError, RoomExt, TimelineFocus};
1515
use mime::Mime;
1616
use ruma::{
1717
api::client::room::report_content,
@@ -23,7 +23,7 @@ use ruma::{
2323
message::RoomMessageEventContentWithoutRelation,
2424
power_levels::RoomPowerLevels as RumaPowerLevels, MediaSource,
2525
},
26-
TimelineEventType,
26+
AnyMessageLikeEventContent, AnySyncTimelineEvent, TimelineEventType,
2727
},
2828
EventId, Int, OwnedDeviceId, OwnedUserId, RoomAliasId, UserId,
2929
};
@@ -34,7 +34,7 @@ use super::RUNTIME;
3434
use crate::{
3535
chunk_iterator::ChunkIterator,
3636
error::{ClientError, MediaInfoError, RoomError},
37-
event::{MessageLikeEventType, StateEventType},
37+
event::{MessageLikeEventType, RoomMessageEventMessageType, StateEventType},
3838
identity_status_change::IdentityStatusChange,
3939
room_info::RoomInfo,
4040
room_member::RoomMember,
@@ -260,6 +260,48 @@ impl Room {
260260
Ok(Timeline::new(timeline))
261261
}
262262

263+
/// A timeline instance that can be configured to only include RoomMessage
264+
/// type events and filter those further based on their message type.
265+
///
266+
/// Virtual timeline items will still be provided and the
267+
/// `default_event_filter` will be applied before everything else.
268+
///
269+
/// # Arguments
270+
///
271+
/// * `internal_id_prefix` - An optional String that will be prepended to
272+
/// all the timeline item's internal IDs, making it possible to
273+
/// distinguish different timeline instances from each other.
274+
///
275+
/// * `allowed_message_types` - A list of `RoomMessageEventMessageType` that
276+
/// will be allowed to appear in the timeline
277+
pub async fn message_filtered_timeline(
278+
&self,
279+
internal_id_prefix: Option<String>,
280+
allowed_message_types: Vec<RoomMessageEventMessageType>,
281+
) -> Result<Arc<Timeline>, ClientError> {
282+
let mut builder = matrix_sdk_ui::timeline::Timeline::builder(&self.inner);
283+
284+
if let Some(internal_id_prefix) = internal_id_prefix {
285+
builder = builder.with_internal_id_prefix(internal_id_prefix);
286+
}
287+
288+
builder = builder.event_filter(move |event, room_version_id| {
289+
default_event_filter(event, room_version_id)
290+
&& match event {
291+
AnySyncTimelineEvent::MessageLike(msg) => match msg.original_content() {
292+
Some(AnyMessageLikeEventContent::RoomMessage(content)) => {
293+
allowed_message_types.contains(&content.msgtype.into())
294+
}
295+
_ => false,
296+
},
297+
_ => false,
298+
}
299+
});
300+
301+
let timeline = builder.build().await?;
302+
Ok(Timeline::new(timeline))
303+
}
304+
263305
pub fn is_encrypted(&self) -> Result<bool, ClientError> {
264306
Ok(RUNTIME.block_on(self.inner.is_encrypted())?)
265307
}

cliff-weekly-report.toml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)