mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-10-03 18:50:45 +00:00
feat(hydra): Initial public commit for v12 support
# Conflicts: # src/core/info/room_version.rs # src/service/rooms/timeline/create.rs # Conflicts: # Cargo.lock # src/core/matrix/state_res/event_auth.rs # Conflicts: # Cargo.toml
This commit is contained in:
parent
51423c9d7d
commit
96a58f6d69
56 changed files with 950 additions and 385 deletions
|
@ -31,7 +31,7 @@ use crate::Result;
|
|||
pub struct Pdu {
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
pub room_id: OwnedRoomId,
|
||||
pub room_id: Option<OwnedRoomId>,
|
||||
|
||||
pub sender: OwnedUserId,
|
||||
|
||||
|
@ -110,7 +110,19 @@ impl Event for Pdu {
|
|||
fn redacts(&self) -> Option<&EventId> { self.redacts.as_deref() }
|
||||
|
||||
#[inline]
|
||||
fn room_id(&self) -> &RoomId { &self.room_id }
|
||||
fn room_id(&self) -> Option<&RoomId> { self.room_id.as_deref() }
|
||||
|
||||
#[inline]
|
||||
fn room_id_or_hash(&self) -> OwnedRoomId {
|
||||
if let Some(room_id) = &self.room_id {
|
||||
room_id.clone()
|
||||
} else {
|
||||
let constructed_hash = "!".to_owned() + &self.event_id.as_str()[1..];
|
||||
RoomId::parse(&constructed_hash)
|
||||
.expect("event ID can be indexed")
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn sender(&self) -> &UserId { &self.sender }
|
||||
|
@ -163,7 +175,19 @@ impl Event for &Pdu {
|
|||
fn redacts(&self) -> Option<&EventId> { self.redacts.as_deref() }
|
||||
|
||||
#[inline]
|
||||
fn room_id(&self) -> &RoomId { &self.room_id }
|
||||
fn room_id(&self) -> Option<&RoomId> { self.room_id.as_ref().map(AsRef::as_ref) }
|
||||
|
||||
#[inline]
|
||||
fn room_id_or_hash(&self) -> OwnedRoomId {
|
||||
if let Some(room_id) = &self.room_id {
|
||||
room_id.clone()
|
||||
} else {
|
||||
let constructed_hash = "!".to_owned() + &self.event_id.as_str()[1..];
|
||||
RoomId::parse(&constructed_hash)
|
||||
.expect("event ID can be indexed")
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn sender(&self) -> &UserId { &self.sender }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue