mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-08-11 17:50:59 +00:00
parent
780eab83f8
commit
db60f7e7b8
13 changed files with 159 additions and 104 deletions
|
@ -4,13 +4,20 @@ use argon2::{Config, Variant};
|
|||
use cmp::Ordering;
|
||||
use rand::prelude::*;
|
||||
use ring::digest;
|
||||
use ruma::{canonical_json::try_from_json_map, CanonicalJsonError, CanonicalJsonObject};
|
||||
use ruma::{
|
||||
api::{client::sync::sync_events::StrippedState, federation::membership::RawStrippedState},
|
||||
canonical_json::try_from_json_map,
|
||||
serde::Raw,
|
||||
CanonicalJsonError, CanonicalJsonObject, RoomId,
|
||||
};
|
||||
use std::{
|
||||
cmp, fmt,
|
||||
str::FromStr,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use crate::Result;
|
||||
|
||||
pub fn millis_since_unix_epoch() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
|
@ -185,3 +192,16 @@ impl fmt::Display for HtmlEscape<'_> {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts `RawStrippedState` (federation format) into `Raw<StrippedState>` (client format)
|
||||
pub fn convert_stripped_state(
|
||||
stripped_state: Vec<RawStrippedState>,
|
||||
_room_id: &RoomId,
|
||||
) -> Result<Vec<Raw<StrippedState>>> {
|
||||
stripped_state
|
||||
.into_iter()
|
||||
.map(|stripped_state| match stripped_state {
|
||||
RawStrippedState::Stripped(state) => Ok(state.cast()),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue