feat: invites, better public room dir, user search

This commit is contained in:
timokoesters 2020-04-14 13:54:32 +02:00
parent af1def50ac
commit abcce95dd8
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
6 changed files with 257 additions and 42 deletions

View file

@ -1,5 +1,7 @@
use js_int::UInt;
use ruma_events::{collections::all::RoomEvent, EventResult, EventType};
use ruma_events::{
collections::all::RoomEvent, stripped::AnyStrippedStateEvent, EventResult, EventType,
};
use ruma_federation_api::EventHash;
use ruma_identifiers::{EventId, RoomId, UserId};
use serde::{Deserialize, Serialize};
@ -39,4 +41,16 @@ impl PduEvent {
.into_result()
.unwrap()
}
pub fn to_stripped_state_event(&self) -> Option<AnyStrippedStateEvent> {
// Can only fail in rare circumstances that won't ever happen here, see
// https://docs.rs/serde_json/1.0.50/serde_json/fn.to_string.html
let json = serde_json::to_string(&self).unwrap();
// EventResult's deserialize implementation always returns `Ok(...)`
serde_json::from_str::<EventResult<AnyStrippedStateEvent>>(&json)
.unwrap()
.into_result()
.ok()
}
}