identifiers: Allow via on RoomId::matrix_to_event_uri()
This commit is contained in:
parent
4883a3154c
commit
2dacaf2ea0
@ -23,6 +23,7 @@ Breaking changes:
|
|||||||
* Move `CanonicalJson`, `CanonicalJsonObject` and `CanonicalJsonError` out of
|
* Move `CanonicalJson`, `CanonicalJsonObject` and `CanonicalJsonError` out of
|
||||||
the `serde` module and behind the cargo feature flag `canonical-json`
|
the `serde` module and behind the cargo feature flag `canonical-json`
|
||||||
* Make identifiers matrix URI constructors generic over owned parameters
|
* Make identifiers matrix URI constructors generic over owned parameters
|
||||||
|
* Allow to add routing servers to `RoomId::matrix_to_event_uri()`
|
||||||
|
|
||||||
[spec]: https://github.com/matrix-org/matrix-spec-proposals/pull/3669
|
[spec]: https://github.com/matrix-org/matrix-spec-proposals/pull/3669
|
||||||
|
|
||||||
|
@ -571,10 +571,19 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
room_id!("!ruma:notareal.hs")
|
room_id!("!ruma:notareal.hs")
|
||||||
.matrix_to_event_uri(event_id!("$event:notareal.hs"))
|
.matrix_to_event_uri(event_id!("$event:notareal.hs"), Vec::<OwnedServerName>::new())
|
||||||
.to_string(),
|
.to_string(),
|
||||||
"https://matrix.to/#/%21ruma%3Anotareal.hs/%24event%3Anotareal.hs"
|
"https://matrix.to/#/%21ruma%3Anotareal.hs/%24event%3Anotareal.hs"
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
room_id!("!ruma:notareal.hs")
|
||||||
|
.matrix_to_event_uri(
|
||||||
|
event_id!("$event:notareal.hs"),
|
||||||
|
vec![server_name!("notareal.hs")]
|
||||||
|
)
|
||||||
|
.to_string(),
|
||||||
|
"https://matrix.to/#/%21ruma%3Anotareal.hs/%24event%3Anotareal.hs?via=notareal.hs"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -822,6 +831,15 @@ mod tests {
|
|||||||
.to_string(),
|
.to_string(),
|
||||||
"matrix:roomid/ruma:notareal.hs/e/event:notareal.hs"
|
"matrix:roomid/ruma:notareal.hs/e/event:notareal.hs"
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
room_id!("!ruma:notareal.hs")
|
||||||
|
.matrix_event_uri(
|
||||||
|
event_id!("$event:notareal.hs"),
|
||||||
|
vec![server_name!("notareal.hs")]
|
||||||
|
)
|
||||||
|
.to_string(),
|
||||||
|
"matrix:roomid/ruma:notareal.hs/e/event:notareal.hs?via=notareal.hs"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -67,8 +67,15 @@ impl RoomId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Create a `matrix.to` URI for an event scoped under this room ID.
|
/// Create a `matrix.to` URI for an event scoped under this room ID.
|
||||||
pub fn matrix_to_event_uri(&self, ev_id: impl Into<OwnedEventId>) -> MatrixToUri {
|
pub fn matrix_to_event_uri<T>(&self, ev_id: impl Into<OwnedEventId>, via: T) -> MatrixToUri
|
||||||
MatrixToUri::new((self.to_owned(), ev_id.into()).into(), Vec::new())
|
where
|
||||||
|
T: IntoIterator,
|
||||||
|
T::Item: Into<OwnedServerName>,
|
||||||
|
{
|
||||||
|
MatrixToUri::new(
|
||||||
|
(self.to_owned(), ev_id.into()).into(),
|
||||||
|
via.into_iter().map(Into::into).collect(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a `matrix:` URI for this room ID.
|
/// Create a `matrix:` URI for this room ID.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user