mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-06-27 16:35:59 +00:00
misc cleanup
This commit is contained in:
parent
5ec0be2b41
commit
e5a26de606
32 changed files with 77 additions and 121 deletions
|
@ -1,7 +1,7 @@
|
||||||
use std::{collections::BTreeMap, convert::TryInto, sync::Arc};
|
use std::{collections::BTreeMap, convert::TryInto};
|
||||||
|
|
||||||
use super::{State, DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
|
||||||
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Database, Error, Ruma};
|
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||||
use log::info;
|
use log::info;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::backup::{
|
r0::backup::{
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::api::client::{error::ErrorKind, r0::context::get_context};
|
use ruma::api::client::{error::ErrorKind, r0::context::get_context};
|
||||||
use std::{convert::TryFrom, sync::Arc};
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::get;
|
use rocket::get;
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, utils, ConduitResult, Error, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, utils, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::{
|
r0::{
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Result, Ruma};
|
use crate::{database::ReadGuard, ConduitResult, Database, Error, Result, Ruma};
|
||||||
use log::info;
|
use log::info;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::{State, SESSION_ID_LENGTH};
|
use super::SESSION_ID_LENGTH;
|
||||||
use crate::{database::ReadGuard, utils, ConduitResult, Database, Error, Result, Ruma};
|
use crate::{database::ReadGuard, utils, ConduitResult, Database, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
@ -14,10 +14,7 @@ use ruma::{
|
||||||
encryption::UnsignedDeviceInfo,
|
encryption::UnsignedDeviceInfo,
|
||||||
DeviceId, DeviceKeyAlgorithm, UserId,
|
DeviceId, DeviceKeyAlgorithm, UserId,
|
||||||
};
|
};
|
||||||
use std::{
|
use std::collections::{BTreeMap, HashSet};
|
||||||
collections::{BTreeMap, HashSet},
|
|
||||||
sync::Arc,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{get, post};
|
use rocket::{get, post};
|
||||||
|
|
|
@ -1,15 +1,12 @@
|
||||||
use super::State;
|
use crate::{database::media::FileMeta, database::ReadGuard, utils, ConduitResult, Error, Ruma};
|
||||||
use crate::{
|
|
||||||
database::media::FileMeta, database::ReadGuard, utils, ConduitResult, Database, Error, Ruma,
|
|
||||||
};
|
|
||||||
use ruma::api::client::{
|
use ruma::api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
r0::media::{create_content, get_content, get_content_thumbnail, get_media_config},
|
r0::media::{create_content, get_content, get_content_thumbnail, get_media_config},
|
||||||
};
|
};
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{get, post};
|
use rocket::{get, post};
|
||||||
use std::{convert::TryInto, sync::Arc};
|
|
||||||
|
|
||||||
const MXC_LENGTH: usize = 32;
|
const MXC_LENGTH: usize = 32;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use super::State;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client_server,
|
client_server,
|
||||||
database::ReadGuard,
|
database::ReadGuard,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||||
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
|
@ -11,7 +10,6 @@ use ruma::{
|
||||||
use std::{
|
use std::{
|
||||||
collections::BTreeMap,
|
collections::BTreeMap,
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
sync::Arc,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
|
|
|
@ -64,9 +64,7 @@ pub use voip::*;
|
||||||
use super::State;
|
use super::State;
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use {
|
use {
|
||||||
crate::ConduitResult,
|
crate::ConduitResult, rocket::options, ruma::api::client::r0::to_device::send_event_to_device,
|
||||||
rocket::{options, State},
|
|
||||||
ruma::api::client::r0::to_device::send_event_to_device,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const DEVICE_ID_LENGTH: usize = 10;
|
pub const DEVICE_ID_LENGTH: usize = 10;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, utils, ConduitResult, Ruma};
|
||||||
use crate::{database::ReadGuard, utils, ConduitResult, Database, Ruma};
|
|
||||||
use ruma::api::client::r0::presence::{get_presence, set_presence};
|
use ruma::api::client::r0::presence::{get_presence, set_presence};
|
||||||
use std::{convert::TryInto, sync::Arc, time::Duration};
|
use std::{convert::TryInto, time::Duration};
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{get, put};
|
use rocket::{get, put};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||||
use crate::{database::ReadGuard, pdu::PduBuilder, utils, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
|
@ -10,10 +9,10 @@ use ruma::{
|
||||||
events::EventType,
|
events::EventType,
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
};
|
};
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{get, put};
|
use rocket::{get, put};
|
||||||
use std::{convert::TryInto, sync::Arc};
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "conduit_bin",
|
feature = "conduit_bin",
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
|
@ -9,10 +8,10 @@ use ruma::{
|
||||||
receipt::ReceiptType,
|
receipt::ReceiptType,
|
||||||
MilliSecondsSinceUnixEpoch,
|
MilliSecondsSinceUnixEpoch,
|
||||||
};
|
};
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::post;
|
use rocket::post;
|
||||||
use std::{collections::BTreeMap, sync::Arc};
|
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "conduit_bin",
|
feature = "conduit_bin",
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, pdu::PduBuilder, ConduitResult, Ruma};
|
||||||
use crate::{database::ReadGuard, pdu::PduBuilder, ConduitResult, Database, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::redact::redact_event,
|
api::client::r0::redact::redact_event,
|
||||||
events::{room::redaction, EventType},
|
events::{room::redaction, EventType},
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::put;
|
use rocket::put;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use super::State;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client_server::invite_helper, database::ReadGuard, pdu::PduBuilder, ConduitResult, Database,
|
client_server::invite_helper, database::ReadGuard, pdu::PduBuilder, ConduitResult, Error, Ruma,
|
||||||
Error, Ruma,
|
|
||||||
};
|
};
|
||||||
use log::info;
|
use log::info;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
|
@ -16,7 +14,7 @@ use ruma::{
|
||||||
serde::Raw,
|
serde::Raw,
|
||||||
RoomAliasId, RoomId, RoomVersionId,
|
RoomAliasId, RoomId, RoomVersionId,
|
||||||
};
|
};
|
||||||
use std::{cmp::max, collections::BTreeMap, convert::TryFrom, sync::Arc};
|
use std::{cmp::max, collections::BTreeMap, convert::TryFrom};
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{get, post};
|
use rocket::{get, post};
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::api::client::{error::ErrorKind, r0::search::search_events};
|
use ruma::api::client::{error::ErrorKind, r0::search::search_events};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::post;
|
use rocket::post;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use std::sync::Arc;
|
use super::{DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
||||||
|
use crate::{database::ReadGuard, utils, ConduitResult, Error, Ruma};
|
||||||
use super::{State, DEVICE_ID_LENGTH, TOKEN_LENGTH};
|
|
||||||
use crate::{database::ReadGuard, utils, ConduitResult, Database, Error, Ruma};
|
|
||||||
use log::info;
|
use log::info;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, pdu::PduBuilder, ConduitResult, Database, Error, Result, Ruma};
|
use crate::{database::ReadGuard, pdu::PduBuilder, ConduitResult, Database, Error, Result, Ruma};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Result, Ruma, RumaResponse};
|
use crate::{database::ReadGuard, ConduitResult, Database, Error, Result, Ruma, RumaResponse};
|
||||||
use log::error;
|
use log::error;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use super::State;
|
use crate::{database::ReadGuard, ConduitResult, Ruma};
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::r0::tag::{create_tag, delete_tag, get_tags},
|
api::client::r0::tag::{create_tag, delete_tag, get_tags},
|
||||||
events::EventType,
|
events::EventType,
|
||||||
};
|
};
|
||||||
use std::{collections::BTreeMap, sync::Arc};
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{delete, get, put};
|
use rocket::{delete, get, put};
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, ConduitResult, Error, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Error, Ruma};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{error::ErrorKind, r0::to_device::send_event_to_device},
|
api::client::{error::ErrorKind, r0::to_device::send_event_to_device},
|
||||||
to_device::DeviceIdOrAllDevices,
|
to_device::DeviceIdOrAllDevices,
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, utils, ConduitResult, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, utils, ConduitResult, Database, Ruma};
|
|
||||||
use create_typing_event::Typing;
|
use create_typing_event::Typing;
|
||||||
use ruma::api::client::r0::typing::create_typing_event;
|
use ruma::api::client::r0::typing::create_typing_event;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
use std::sync::Arc;
|
use crate::{database::ReadGuard, ConduitResult, Ruma};
|
||||||
|
|
||||||
use super::State;
|
|
||||||
use crate::{database::ReadGuard, ConduitResult, Database, Ruma};
|
|
||||||
use ruma::api::client::r0::user_directory::search_users;
|
use ruma::api::client::r0::user_directory::search_users;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
|
|
|
@ -34,7 +34,7 @@ use std::{
|
||||||
ops::Deref,
|
ops::Deref,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
};
|
};
|
||||||
use tokio::sync::{OwnedRwLockReadGuard, RwLock as TokioRwLock, RwLockReadGuard, Semaphore};
|
use tokio::sync::{OwnedRwLockReadGuard, RwLock as TokioRwLock, Semaphore};
|
||||||
|
|
||||||
use self::proxy::ProxyConfig;
|
use self::proxy::ProxyConfig;
|
||||||
|
|
||||||
|
@ -462,7 +462,6 @@ impl Deref for ReadGuard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
|
||||||
#[rocket::async_trait]
|
#[rocket::async_trait]
|
||||||
impl<'r> FromRequest<'r> for ReadGuard {
|
impl<'r> FromRequest<'r> for ReadGuard {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
@ -473,3 +472,9 @@ impl<'r> FromRequest<'r> for ReadGuard {
|
||||||
Ok(ReadGuard(Arc::clone(&db).read_owned().await)).or_forward(())
|
Ok(ReadGuard(Arc::clone(&db).read_owned().await)).or_forward(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<ReadGuard> for OwnedRwLockReadGuard<Database> {
|
||||||
|
fn into(self) -> ReadGuard {
|
||||||
|
ReadGuard(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use ruma::{
|
||||||
events::{room::message, EventType},
|
events::{room::message, EventType},
|
||||||
UserId,
|
UserId,
|
||||||
};
|
};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::{RwLock, RwLockReadGuard};
|
||||||
|
|
||||||
pub enum AdminCommand {
|
pub enum AdminCommand {
|
||||||
RegisterAppservice(serde_yaml::Value),
|
RegisterAppservice(serde_yaml::Value),
|
||||||
|
@ -54,47 +54,52 @@ impl Admin {
|
||||||
|
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
let send_message = |message: message::MessageEventContent| {};
|
let send_message =
|
||||||
|
|message: message::MessageEventContent, guard: RwLockReadGuard<'_, Database>| {
|
||||||
|
if let Some(conduit_room) = &conduit_room {
|
||||||
|
guard
|
||||||
|
.rooms
|
||||||
|
.build_and_append_pdu(
|
||||||
|
PduBuilder {
|
||||||
|
event_type: EventType::RoomMessage,
|
||||||
|
content: serde_json::to_value(message)
|
||||||
|
.expect("event is valid, we just created it"),
|
||||||
|
unsigned: None,
|
||||||
|
state_key: None,
|
||||||
|
redacts: None,
|
||||||
|
},
|
||||||
|
&conduit_user,
|
||||||
|
&conduit_room,
|
||||||
|
&guard,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
Some(event) = receiver.next() => {
|
Some(event) = receiver.next() => {
|
||||||
|
let guard = db.read().await;
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
AdminCommand::RegisterAppservice(yaml) => {
|
AdminCommand::RegisterAppservice(yaml) => {
|
||||||
db.read().await.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
guard.appservice.register_appservice(yaml).unwrap(); // TODO handle error
|
||||||
}
|
}
|
||||||
AdminCommand::ListAppservices => {
|
AdminCommand::ListAppservices => {
|
||||||
if let Ok(appservices) = db.read().await.appservice.iter_ids().map(|ids| ids.collect::<Vec<_>>()) {
|
if let Ok(appservices) = guard.appservice.iter_ids().map(|ids| ids.collect::<Vec<_>>()) {
|
||||||
let count = appservices.len();
|
let count = appservices.len();
|
||||||
let output = format!(
|
let output = format!(
|
||||||
"Appservices ({}): {}",
|
"Appservices ({}): {}",
|
||||||
count,
|
count,
|
||||||
appservices.into_iter().filter_map(|r| r.ok()).collect::<Vec<_>>().join(", ")
|
appservices.into_iter().filter_map(|r| r.ok()).collect::<Vec<_>>().join(", ")
|
||||||
);
|
);
|
||||||
send_message(message::MessageEventContent::text_plain(output));
|
send_message(message::MessageEventContent::text_plain(output), guard);
|
||||||
} else {
|
} else {
|
||||||
send_message(message::MessageEventContent::text_plain("Failed to get appservices."));
|
send_message(message::MessageEventContent::text_plain("Failed to get appservices."), guard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AdminCommand::SendMessage(message) => {
|
AdminCommand::SendMessage(message) => {
|
||||||
if let Some(conduit_room) = &conduit_room {
|
send_message(message, guard)
|
||||||
let guard = db.read().await;
|
|
||||||
guard.rooms
|
|
||||||
.build_and_append_pdu(
|
|
||||||
PduBuilder {
|
|
||||||
event_type: EventType::RoomMessage,
|
|
||||||
content: serde_json::to_value(message)
|
|
||||||
.expect("event is valid, we just created it"),
|
|
||||||
unsigned: None,
|
|
||||||
state_key: None,
|
|
||||||
redacts: None,
|
|
||||||
},
|
|
||||||
&conduit_user,
|
|
||||||
&conduit_room,
|
|
||||||
&guard,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@ pub use error::{Error, Result};
|
||||||
pub use pdu::PduEvent;
|
pub use pdu::PduEvent;
|
||||||
pub use rocket::Config;
|
pub use rocket::Config;
|
||||||
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
||||||
use std::{ops::Deref, sync::Arc};
|
use std::ops::Deref;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
pub struct State<'r, T: Send + Sync + 'static>(pub &'r T);
|
pub struct State<'r, T: Send + Sync + 'static>(pub &'r T);
|
||||||
|
|
||||||
|
|
|
@ -231,8 +231,11 @@ async fn main() {
|
||||||
};
|
};
|
||||||
log::warn!("wal-trunc: locked, flushing...");
|
log::warn!("wal-trunc: locked, flushing...");
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
guard.flush_wal();
|
if let Err(e) = guard.flush_wal() {
|
||||||
log::warn!("wal-trunc: flushed in {:?}", start.elapsed());
|
log::warn!("wal-trunc: errored: {}", e);
|
||||||
|
} else {
|
||||||
|
log::warn!("wal-trunc: flushed in {:?}", start.elapsed());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::ops::Deref;
|
||||||
|
|
||||||
#[cfg(feature = "conduit_bin")]
|
#[cfg(feature = "conduit_bin")]
|
||||||
use {
|
use {
|
||||||
crate::{server_server, Database},
|
crate::server_server,
|
||||||
log::{debug, warn},
|
log::{debug, warn},
|
||||||
rocket::{
|
rocket::{
|
||||||
data::{self, ByteUnit, Data, FromData},
|
data::{self, ByteUnit, Data, FromData},
|
||||||
|
@ -17,13 +17,12 @@ use {
|
||||||
outcome::Outcome::*,
|
outcome::Outcome::*,
|
||||||
response::{self, Responder},
|
response::{self, Responder},
|
||||||
tokio::io::AsyncReadExt,
|
tokio::io::AsyncReadExt,
|
||||||
Request, State,
|
Request,
|
||||||
},
|
},
|
||||||
ruma::api::{AuthScheme, IncomingRequest},
|
ruma::api::{AuthScheme, IncomingRequest},
|
||||||
std::collections::BTreeMap,
|
std::collections::BTreeMap,
|
||||||
std::convert::TryFrom,
|
std::convert::TryFrom,
|
||||||
std::io::Cursor,
|
std::io::Cursor,
|
||||||
std::sync::Arc,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This struct converts rocket requests into ruma structs by converting them into http requests
|
/// This struct converts rocket requests into ruma structs by converting them into http requests
|
||||||
|
|
|
@ -7,7 +7,7 @@ use get_profile_information::v1::ProfileField;
|
||||||
use http::header::{HeaderValue, AUTHORIZATION, HOST};
|
use http::header::{HeaderValue, AUTHORIZATION, HOST};
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rocket::{response::content::Json, State};
|
use rocket::response::content::Json;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::{
|
api::{
|
||||||
client::error::{Error as RumaError, ErrorKind},
|
client::error::{Error as RumaError, ErrorKind},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue