Subscriptions working

This commit is contained in:
2021-06-05 14:17:23 +02:00
parent a96cbdc059
commit 473b553662
12 changed files with 306 additions and 34 deletions

View File

@ -0,0 +1,28 @@
use crate::usimp::*;
use crate::usimp::subscription;
use serde_json::{Value, from_value, to_value};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone)]
struct Input {
room_id: String,
events: Vec<Event>,
}
#[derive(Serialize, Deserialize, Clone)]
struct Output {
}
pub async fn handle(input: &InputEnvelope, session: Option<Session>) -> Result<Value, Error> {
Ok(to_value(new_event(from_value(input.data.clone())?, session).await?)?)
}
async fn new_event(input: Input, session: Option<Session>) -> Result<Output, Error> {
let _account = get_account(&session)?;
// TODO check permissions
for event in input.events {
subscription::push(input.room_id.as_str(), event).await?;
}
Ok(Output {})
}