Upgrade Ruma
This commit is contained in:
parent
2ac7b6d411
commit
f6046871f4
7 changed files with 183 additions and 180 deletions
|
@ -295,7 +295,7 @@ pub async fn register_route(
|
|||
state_default: 50.into(),
|
||||
users,
|
||||
users_default: 0.into(),
|
||||
notifications: ruma::events::room::power_levels::NotificationPowerLevels {
|
||||
notifications: ruma::power_levels::NotificationPowerLevels {
|
||||
room: 50.into(),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -122,9 +122,7 @@ pub async fn create_room_route(
|
|||
state_default: 50.into(),
|
||||
users,
|
||||
users_default: 0.into(),
|
||||
notifications: ruma::events::room::power_levels::NotificationPowerLevels {
|
||||
room: 50.into(),
|
||||
},
|
||||
notifications: ruma::power_levels::NotificationPowerLevels { room: 50.into() },
|
||||
})
|
||||
.expect("event is valid, we just created it");
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ use std::sync::Arc;
|
|||
|
||||
use super::State;
|
||||
use crate::{ConduitResult, Database, Error, Ruma};
|
||||
use ruma::api::client::{
|
||||
error::ErrorKind,
|
||||
r0::to_device::{self, send_event_to_device},
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, r0::to_device::send_event_to_device},
|
||||
to_device::DeviceIdOrAllDevices,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
|
@ -34,27 +34,25 @@ pub async fn send_event_to_device_route(
|
|||
for (target_user_id, map) in &body.messages {
|
||||
for (target_device_id_maybe, event) in map {
|
||||
match target_device_id_maybe {
|
||||
to_device::DeviceIdOrAllDevices::DeviceId(target_device_id) => {
|
||||
db.users.add_to_device_event(
|
||||
sender_user,
|
||||
&target_user_id,
|
||||
&target_device_id,
|
||||
&body.event_type,
|
||||
serde_json::from_str(event.get()).map_err(|_| {
|
||||
Error::BadRequest(ErrorKind::InvalidParam, "Event is invalid")
|
||||
})?,
|
||||
&db.globals,
|
||||
)?
|
||||
}
|
||||
DeviceIdOrAllDevices::DeviceId(target_device_id) => db.users.add_to_device_event(
|
||||
sender_user,
|
||||
&target_user_id,
|
||||
&target_device_id,
|
||||
&body.event_type,
|
||||
event.deserialize_as().map_err(|_| {
|
||||
Error::BadRequest(ErrorKind::InvalidParam, "Event is invalid")
|
||||
})?,
|
||||
&db.globals,
|
||||
)?,
|
||||
|
||||
to_device::DeviceIdOrAllDevices::AllDevices => {
|
||||
DeviceIdOrAllDevices::AllDevices => {
|
||||
for target_device_id in db.users.all_device_ids(&target_user_id) {
|
||||
db.users.add_to_device_event(
|
||||
sender_user,
|
||||
&target_user_id,
|
||||
&target_device_id?,
|
||||
&body.event_type,
|
||||
serde_json::from_str(event.get()).map_err(|_| {
|
||||
event.deserialize_as().map_err(|_| {
|
||||
Error::BadRequest(ErrorKind::InvalidParam, "Event is invalid")
|
||||
})?,
|
||||
&db.globals,
|
||||
|
|
|
@ -719,7 +719,7 @@ impl Users {
|
|||
sender: &UserId,
|
||||
target_user_id: &UserId,
|
||||
target_device_id: &DeviceId,
|
||||
event_type: &EventType,
|
||||
event_type: &str,
|
||||
content: serde_json::Value,
|
||||
globals: &super::globals::Globals,
|
||||
) -> Result<()> {
|
||||
|
@ -730,7 +730,7 @@ impl Users {
|
|||
key.extend_from_slice(&globals.next_count()?.to_be_bytes());
|
||||
|
||||
let mut json = serde_json::Map::new();
|
||||
json.insert("type".to_owned(), event_type.to_string().into());
|
||||
json.insert("type".to_owned(), event_type.to_owned().into());
|
||||
json.insert("sender".to_owned(), sender.to_string().into());
|
||||
json.insert("content".to_owned(), content);
|
||||
|
||||
|
|
|
@ -9,10 +9,7 @@ use regex::Regex;
|
|||
use rocket::{response::content::Json, State};
|
||||
use ruma::{
|
||||
api::{
|
||||
client::{
|
||||
error::{Error as RumaError, ErrorKind},
|
||||
r0::to_device,
|
||||
},
|
||||
client::error::{Error as RumaError, ErrorKind},
|
||||
federation::{
|
||||
authorization::get_event_authorization,
|
||||
device::get_devices::{self, v1::UserDevice},
|
||||
|
@ -49,6 +46,7 @@ use ruma::{
|
|||
serde::Raw,
|
||||
signatures::{CanonicalJsonObject, CanonicalJsonValue},
|
||||
state_res::{self, Event, EventMap, RoomVersion, StateMap},
|
||||
to_device::DeviceIdOrAllDevices,
|
||||
uint, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName,
|
||||
ServerSigningKeyId, UserId,
|
||||
};
|
||||
|
@ -748,13 +746,13 @@ pub async fn send_transaction_message_route(
|
|||
for (target_user_id, map) in &messages {
|
||||
for (target_device_id_maybe, event) in map {
|
||||
match target_device_id_maybe {
|
||||
to_device::DeviceIdOrAllDevices::DeviceId(target_device_id) => {
|
||||
DeviceIdOrAllDevices::DeviceId(target_device_id) => {
|
||||
db.users.add_to_device_event(
|
||||
&sender,
|
||||
&target_user_id,
|
||||
&target_device_id,
|
||||
&ev_type,
|
||||
serde_json::from_str(event.get()).map_err(|_| {
|
||||
&ev_type.to_string(),
|
||||
event.deserialize_as().map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Event is invalid",
|
||||
|
@ -764,14 +762,14 @@ pub async fn send_transaction_message_route(
|
|||
)?
|
||||
}
|
||||
|
||||
to_device::DeviceIdOrAllDevices::AllDevices => {
|
||||
DeviceIdOrAllDevices::AllDevices => {
|
||||
for target_device_id in db.users.all_device_ids(&target_user_id) {
|
||||
db.users.add_to_device_event(
|
||||
&sender,
|
||||
&target_user_id,
|
||||
&target_device_id?,
|
||||
&ev_type,
|
||||
serde_json::from_str(event.get()).map_err(|_| {
|
||||
&ev_type.to_string(),
|
||||
event.deserialize_as().map_err(|_| {
|
||||
Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Event is invalid",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue