mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
671d0619ca
Signed-off-by: Jason Volk <jason@zemos.net>
29 lines
634 B
Rust
29 lines
634 B
Rust
use ruma::events::relation::RelationType;
|
|
use serde::Deserialize;
|
|
|
|
use super::Event;
|
|
|
|
pub trait RelationTypeEqual<E: Event> {
|
|
fn relation_type_equal(&self, event: &E) -> bool;
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
struct ExtractRelatesToEventId {
|
|
#[serde(rename = "m.relates_to")]
|
|
relates_to: ExtractRelType,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
struct ExtractRelType {
|
|
rel_type: RelationType,
|
|
}
|
|
|
|
impl<E: Event> RelationTypeEqual<E> for RelationType {
|
|
fn relation_type_equal(&self, event: &E) -> bool {
|
|
event
|
|
.get_content()
|
|
.map(|c: ExtractRelatesToEventId| c.relates_to.rel_type)
|
|
.is_ok_and(|r| r == *self)
|
|
}
|
|
}
|