Update crates and change to UUID
This commit is contained in:
@ -6,12 +6,14 @@ use serde_json::{from_value, to_value, Value};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
struct Input {
|
||||
room_id: String,
|
||||
room_id: Uuid,
|
||||
events: Vec<Event>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
struct Output {}
|
||||
struct Output {
|
||||
events: Vec<Uuid>,
|
||||
}
|
||||
|
||||
pub async fn handle(input: &InputEnvelope, session: Option<Session>) -> Result<Value, Error> {
|
||||
Ok(to_value(
|
||||
@ -21,9 +23,13 @@ pub async fn handle(input: &InputEnvelope, session: Option<Session>) -> Result<V
|
||||
|
||||
async fn new_event(input: Input, session: Option<Session>) -> Result<Output, Error> {
|
||||
let _account = get_account(&session)?;
|
||||
let mut uuids = vec![];
|
||||
// TODO check permissions
|
||||
for event in input.events {
|
||||
subscription::push(input.room_id.as_str(), event).await?;
|
||||
for mut event in input.events {
|
||||
let uuid = Uuid::new_v4();
|
||||
event.id = Some(uuid);
|
||||
uuids.push(uuid);
|
||||
subscription::push(&input.room_id, event).await?;
|
||||
}
|
||||
Ok(Output {})
|
||||
Ok(Output {events: uuids})
|
||||
}
|
||||
|
Reference in New Issue
Block a user