run cargo fix for rust 2024 changes and rustfmt
Signed-off-by: June Clementine Strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
e97952b7f6
commit
a1e1f40ded
320 changed files with 2212 additions and 2039 deletions
|
@ -1,23 +1,22 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{
|
||||
err, implement,
|
||||
utils::{result::LogErr, stream::TryIgnore, ReadyExt},
|
||||
Err, Result,
|
||||
Err, Result, err, implement,
|
||||
utils::{ReadyExt, result::LogErr, stream::TryIgnore},
|
||||
};
|
||||
use database::{Deserialized, Handle, Ignore, Json, Map};
|
||||
use futures::{Stream, StreamExt, TryFutureExt};
|
||||
use ruma::{
|
||||
RoomId, UserId,
|
||||
events::{
|
||||
AnyGlobalAccountDataEvent, AnyRawAccountDataEvent, AnyRoomAccountDataEvent,
|
||||
GlobalAccountDataEventType, RoomAccountDataEventType,
|
||||
},
|
||||
serde::Raw,
|
||||
RoomId, UserId,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{globals, Dep};
|
||||
use crate::{Dep, globals};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
|
|
@ -5,14 +5,14 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use conduwuit::{debug, defer, error, log, log::is_systemd_mode, Server};
|
||||
use conduwuit::{Server, debug, defer, error, log, log::is_systemd_mode};
|
||||
use futures::future::{AbortHandle, Abortable};
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
use rustyline_async::{Readline, ReadlineError, ReadlineEvent};
|
||||
use termimad::MadSkin;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
use crate::{admin, Dep};
|
||||
use crate::{Dep, admin};
|
||||
|
||||
pub struct Console {
|
||||
server: Arc<Server>,
|
||||
|
@ -221,7 +221,7 @@ pub fn print(markdown: &str) {
|
|||
}
|
||||
|
||||
fn configure_output_err(mut output: MadSkin) -> MadSkin {
|
||||
use termimad::{crossterm::style::Color, Alignment, CompoundStyle, LineStyle};
|
||||
use termimad::{Alignment, CompoundStyle, LineStyle, crossterm::style::Color};
|
||||
|
||||
let code_style = CompoundStyle::with_fgbg(Color::AnsiValue(196), Color::AnsiValue(234));
|
||||
output.inline_code = code_style.clone();
|
||||
|
@ -236,7 +236,7 @@ fn configure_output_err(mut output: MadSkin) -> MadSkin {
|
|||
}
|
||||
|
||||
fn configure_output(mut output: MadSkin) -> MadSkin {
|
||||
use termimad::{crossterm::style::Color, Alignment, CompoundStyle, LineStyle};
|
||||
use termimad::{Alignment, CompoundStyle, LineStyle, crossterm::style::Color};
|
||||
|
||||
let code_style = CompoundStyle::with_fgbg(Color::AnsiValue(40), Color::AnsiValue(234));
|
||||
output.inline_code = code_style.clone();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use conduwuit::{pdu::PduBuilder, Result};
|
||||
use conduwuit::{Result, pdu::PduBuilder};
|
||||
use ruma::{
|
||||
RoomId, RoomVersionId,
|
||||
events::room::{
|
||||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
create::RoomCreateEventContent,
|
||||
|
@ -14,7 +15,6 @@ use ruma::{
|
|||
preview_url::RoomPreviewUrlsEventContent,
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
RoomId, RoomVersionId,
|
||||
};
|
||||
|
||||
use crate::Services;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use conduwuit::{debug, debug_info, error, implement, info, Err, Result};
|
||||
use conduwuit::{Err, Result, debug, debug_info, error, implement, info};
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
use tokio::time::{sleep, Duration};
|
||||
use tokio::time::{Duration, sleep};
|
||||
|
||||
pub(super) const SIGNAL: &str = "SIGUSR2";
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
use conduwuit::{error, implement, Result};
|
||||
use conduwuit::{Result, error, implement};
|
||||
use ruma::{
|
||||
RoomId, UserId,
|
||||
events::{
|
||||
RoomAccountDataEventType,
|
||||
room::{
|
||||
member::{MembershipState, RoomMemberEventContent},
|
||||
message::RoomMessageEventContent,
|
||||
power_levels::RoomPowerLevelsEventContent,
|
||||
},
|
||||
tag::{TagEvent, TagEventContent, TagInfo},
|
||||
RoomAccountDataEventType,
|
||||
},
|
||||
RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::pdu::PduBuilder;
|
||||
|
|
|
@ -11,18 +11,18 @@ use std::{
|
|||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
debug, err, error, error::default_log, pdu::PduBuilder, Error, PduEvent, Result, Server,
|
||||
Error, PduEvent, Result, Server, debug, err, error, error::default_log, pdu::PduBuilder,
|
||||
};
|
||||
pub use create::create_admin_room;
|
||||
use futures::{FutureExt, TryFutureExt};
|
||||
use loole::{Receiver, Sender};
|
||||
use ruma::{
|
||||
events::room::message::{Relation, RoomMessageEventContent},
|
||||
OwnedEventId, OwnedRoomId, RoomId, UserId,
|
||||
events::room::message::{Relation, RoomMessageEventContent},
|
||||
};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{account_data, globals, rooms, rooms::state::RoomMutexGuard, Dep};
|
||||
use crate::{Dep, account_data, globals, rooms, rooms::state::RoomMutexGuard};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
|
|
@ -4,14 +4,14 @@ mod registration_info;
|
|||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{err, utils::stream::TryIgnore, Result};
|
||||
use conduwuit::{Result, err, utils::stream::TryIgnore};
|
||||
use database::Map;
|
||||
use futures::{Future, StreamExt, TryStreamExt};
|
||||
use ruma::{api::appservice::Registration, RoomAliasId, RoomId, UserId};
|
||||
use ruma::{RoomAliasId, RoomId, UserId, api::appservice::Registration};
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
pub use self::{namespace_regex::NamespaceRegex, registration_info::RegistrationInfo};
|
||||
use crate::{sending, Dep};
|
||||
use crate::{Dep, sending};
|
||||
|
||||
pub struct Service {
|
||||
registration_info: RwLock<BTreeMap<String, RegistrationInfo>>,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use conduwuit::Result;
|
||||
use ruma::{api::appservice::Registration, UserId};
|
||||
use ruma::{UserId, api::appservice::Registration};
|
||||
|
||||
use super::NamespaceRegex;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use conduwuit::{err, implement, trace, Config, Result};
|
||||
use conduwuit::{Config, Result, err, implement, trace};
|
||||
use either::Either;
|
||||
use ipaddress::IPAddress;
|
||||
use reqwest::redirect;
|
||||
|
@ -172,10 +172,9 @@ fn base(config: &Config) -> Result<reqwest::ClientBuilder> {
|
|||
builder = builder.no_zstd();
|
||||
};
|
||||
|
||||
if let Some(proxy) = config.proxy.to_proxy()? {
|
||||
Ok(builder.proxy(proxy))
|
||||
} else {
|
||||
Ok(builder)
|
||||
match config.proxy.to_proxy()? {
|
||||
| Some(proxy) => Ok(builder.proxy(proxy)),
|
||||
| _ => Ok(builder),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@ use std::{iter, ops::Deref, path::Path, sync::Arc};
|
|||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
config::{check, Config},
|
||||
error, implement, Result, Server,
|
||||
Result, Server,
|
||||
config::{Config, check},
|
||||
error, implement,
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{error, warn, Result};
|
||||
use conduwuit::{Result, error, warn};
|
||||
use ruma::{
|
||||
events::{
|
||||
push_rules::PushRulesEventContent, GlobalAccountDataEvent, GlobalAccountDataEventType,
|
||||
GlobalAccountDataEvent, GlobalAccountDataEventType, push_rules::PushRulesEventContent,
|
||||
},
|
||||
push::Ruleset,
|
||||
};
|
||||
|
||||
use crate::{account_data, globals, users, Dep};
|
||||
use crate::{Dep, account_data, globals, users};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
|
|
@ -2,20 +2,20 @@ use std::{fmt::Debug, mem};
|
|||
|
||||
use bytes::Bytes;
|
||||
use conduwuit::{
|
||||
debug, debug::INFO_SPAN_LEVEL, debug_error, debug_warn, err, error::inspect_debug_log,
|
||||
implement, trace, utils::string::EMPTY, Err, Error, Result,
|
||||
Err, Error, Result, debug, debug::INFO_SPAN_LEVEL, debug_error, debug_warn, err,
|
||||
error::inspect_debug_log, implement, trace, utils::string::EMPTY,
|
||||
};
|
||||
use http::{header::AUTHORIZATION, HeaderValue};
|
||||
use http::{HeaderValue, header::AUTHORIZATION};
|
||||
use ipaddress::IPAddress;
|
||||
use reqwest::{Client, Method, Request, Response, Url};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, ServerName, ServerSigningKeyId,
|
||||
api::{
|
||||
client::error::Error as RumaError, EndpointError, IncomingResponse, MatrixVersion,
|
||||
OutgoingRequest, SendAccessToken,
|
||||
EndpointError, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
|
||||
client::error::Error as RumaError,
|
||||
},
|
||||
serde::Base64,
|
||||
server_util::authorization::XMatrix,
|
||||
CanonicalJsonObject, CanonicalJsonValue, ServerName, ServerSigningKeyId,
|
||||
};
|
||||
|
||||
use crate::resolver::actual::ActualDest;
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
|||
|
||||
use conduwuit::{Result, Server};
|
||||
|
||||
use crate::{client, resolver, server_keys, Dep};
|
||||
use crate::{Dep, client, resolver, server_keys};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use conduwuit::{utils, Result};
|
||||
use conduwuit::{Result, utils};
|
||||
use database::{Database, Deserialized, Map};
|
||||
|
||||
pub struct Data {
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
time::Instant,
|
||||
};
|
||||
|
||||
use conduwuit::{error, utils::bytes::pretty, Result, Server};
|
||||
use conduwuit::{Result, Server, error, utils::bytes::pretty};
|
||||
use data::Data;
|
||||
use regex::RegexSet;
|
||||
use ruma::{OwnedEventId, OwnedRoomAliasId, OwnedServerName, OwnedUserId, ServerName, UserId};
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
err, implement,
|
||||
Err, Result, err, implement,
|
||||
utils::stream::{ReadyExt, TryIgnore},
|
||||
Err, Result,
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||
use futures::StreamExt;
|
||||
use ruma::{
|
||||
OwnedRoomId, RoomId, UserId,
|
||||
api::client::backup::{BackupAlgorithm, KeyBackupData, RoomKeyBackup},
|
||||
serde::Raw,
|
||||
OwnedRoomId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::{globals, Dep};
|
||||
use crate::{Dep, globals};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::{panic::AssertUnwindSafe, sync::Arc, time::Duration};
|
||||
|
||||
use conduwuit::{debug, debug_warn, error, trace, utils::time, warn, Err, Error, Result, Server};
|
||||
use conduwuit::{Err, Error, Result, Server, debug, debug_warn, error, trace, utils::time, warn};
|
||||
use futures::{FutureExt, TryFutureExt};
|
||||
use tokio::{
|
||||
sync::{Mutex, MutexGuard},
|
||||
|
@ -8,7 +8,7 @@ use tokio::{
|
|||
time::sleep,
|
||||
};
|
||||
|
||||
use crate::{service, service::Service, Services};
|
||||
use crate::{Services, service, service::Service};
|
||||
|
||||
pub(crate) struct Manager {
|
||||
manager: Mutex<Option<JoinHandle<Result<()>>>>,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[cfg(feature = "blurhashing")]
|
||||
use conduwuit::config::BlurhashConfig as CoreBlurhashConfig;
|
||||
use conduwuit::{implement, Result};
|
||||
use conduwuit::{Result, implement};
|
||||
|
||||
use super::Service;
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug_info, err,
|
||||
utils::{str_from_bytes, stream::TryIgnore, string_from_bytes, ReadyExt},
|
||||
Err, Result,
|
||||
Err, Result, debug, debug_info, err,
|
||||
utils::{ReadyExt, str_from_bytes, stream::TryIgnore, string_from_bytes},
|
||||
};
|
||||
use database::{Database, Interfix, Map};
|
||||
use futures::StreamExt;
|
||||
use ruma::{http_headers::ContentDisposition, Mxc, OwnedMxcUri, UserId};
|
||||
use ruma::{Mxc, OwnedMxcUri, UserId, http_headers::ContentDisposition};
|
||||
|
||||
use super::{preview::UrlPreviewData, thumbnail::Dim};
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug_info, debug_warn, error, info,
|
||||
utils::{stream::TryIgnore, ReadyExt},
|
||||
warn, Config, Result,
|
||||
Config, Result, debug, debug_info, debug_warn, error, info,
|
||||
utils::{ReadyExt, stream::TryIgnore},
|
||||
warn,
|
||||
};
|
||||
|
||||
use crate::Services;
|
||||
|
|
|
@ -8,13 +8,13 @@ mod thumbnail;
|
|||
use std::{path::PathBuf, sync::Arc, time::SystemTime};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
use conduwuit::{
|
||||
debug, debug_error, debug_info, debug_warn, err, error, trace,
|
||||
Err, Result, Server, debug, debug_error, debug_info, debug_warn, err, error, trace,
|
||||
utils::{self, MutexMap},
|
||||
warn, Err, Result, Server,
|
||||
warn,
|
||||
};
|
||||
use ruma::{http_headers::ContentDisposition, Mxc, OwnedMxcUri, UserId};
|
||||
use ruma::{Mxc, OwnedMxcUri, UserId, http_headers::ContentDisposition};
|
||||
use tokio::{
|
||||
fs,
|
||||
io::{AsyncReadExt, AsyncWriteExt, BufReader},
|
||||
|
@ -22,7 +22,7 @@ use tokio::{
|
|||
|
||||
use self::data::{Data, Metadata};
|
||||
pub use self::thumbnail::Dim;
|
||||
use crate::{client, globals, sending, Dep};
|
||||
use crate::{Dep, client, globals, sending};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FileMeta {
|
||||
|
@ -105,22 +105,27 @@ impl Service {
|
|||
|
||||
/// Deletes a file in the database and from the media directory via an MXC
|
||||
pub async fn delete(&self, mxc: &Mxc<'_>) -> Result<()> {
|
||||
if let Ok(keys) = self.db.search_mxc_metadata_prefix(mxc).await {
|
||||
for key in keys {
|
||||
trace!(?mxc, "MXC Key: {key:?}");
|
||||
debug_info!(?mxc, "Deleting from filesystem");
|
||||
match self.db.search_mxc_metadata_prefix(mxc).await {
|
||||
| Ok(keys) => {
|
||||
for key in keys {
|
||||
trace!(?mxc, "MXC Key: {key:?}");
|
||||
debug_info!(?mxc, "Deleting from filesystem");
|
||||
|
||||
if let Err(e) = self.remove_media_file(&key).await {
|
||||
debug_error!(?mxc, "Failed to remove media file: {e}");
|
||||
if let Err(e) = self.remove_media_file(&key).await {
|
||||
debug_error!(?mxc, "Failed to remove media file: {e}");
|
||||
}
|
||||
|
||||
debug_info!(?mxc, "Deleting from database");
|
||||
self.db.delete_file_mxc(mxc).await;
|
||||
}
|
||||
|
||||
debug_info!(?mxc, "Deleting from database");
|
||||
self.db.delete_file_mxc(mxc).await;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
} else {
|
||||
Err!(Database(error!("Failed to find any media keys for MXC {mxc} in our database.")))
|
||||
Ok(())
|
||||
},
|
||||
| _ => {
|
||||
Err!(Database(error!(
|
||||
"Failed to find any media keys for MXC {mxc} in our database."
|
||||
)))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,22 +159,21 @@ impl Service {
|
|||
|
||||
/// Downloads a file.
|
||||
pub async fn get(&self, mxc: &Mxc<'_>) -> Result<Option<FileMeta>> {
|
||||
if let Ok(Metadata { content_disposition, content_type, key }) =
|
||||
self.db.search_file_metadata(mxc, &Dim::default()).await
|
||||
{
|
||||
let mut content = Vec::with_capacity(8192);
|
||||
let path = self.get_media_file(&key);
|
||||
BufReader::new(fs::File::open(path).await?)
|
||||
.read_to_end(&mut content)
|
||||
.await?;
|
||||
match self.db.search_file_metadata(mxc, &Dim::default()).await {
|
||||
| Ok(Metadata { content_disposition, content_type, key }) => {
|
||||
let mut content = Vec::with_capacity(8192);
|
||||
let path = self.get_media_file(&key);
|
||||
BufReader::new(fs::File::open(path).await?)
|
||||
.read_to_end(&mut content)
|
||||
.await?;
|
||||
|
||||
Ok(Some(FileMeta {
|
||||
content: Some(content),
|
||||
content_type,
|
||||
content_disposition,
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
Ok(Some(FileMeta {
|
||||
content: Some(content),
|
||||
content_type,
|
||||
content_disposition,
|
||||
}))
|
||||
},
|
||||
| _ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use std::time::SystemTime;
|
||||
|
||||
use conduwuit::{debug, Err, Result};
|
||||
use conduwuit::{Err, Result, debug};
|
||||
use conduwuit_core::implement;
|
||||
use ipaddress::IPAddress;
|
||||
use serde::Serialize;
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use std::{fmt::Debug, time::Duration};
|
||||
|
||||
use conduwuit::{
|
||||
debug_warn, err, implement, utils::content_disposition::make_content_disposition, Err, Error,
|
||||
Result,
|
||||
Err, Error, Result, debug_warn, err, implement,
|
||||
utils::content_disposition::make_content_disposition,
|
||||
};
|
||||
use http::header::{HeaderValue, CONTENT_DISPOSITION, CONTENT_TYPE};
|
||||
use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE, HeaderValue};
|
||||
use ruma::{
|
||||
Mxc, ServerName, UserId,
|
||||
api::{
|
||||
OutgoingRequest,
|
||||
client::{
|
||||
error::ErrorKind::{NotFound, Unrecognized},
|
||||
media,
|
||||
},
|
||||
federation,
|
||||
federation::authenticated_media::{Content, FileOrLocation},
|
||||
OutgoingRequest,
|
||||
},
|
||||
Mxc, ServerName, UserId,
|
||||
};
|
||||
|
||||
use super::{Dim, FileMeta};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
async fn long_file_names_works() {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use base64::{engine::general_purpose, Engine as _};
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
use std::{cmp, num::Saturating as Sat};
|
||||
|
||||
use conduwuit::{checked, err, implement, Result};
|
||||
use ruma::{http_headers::ContentDisposition, media::Method, Mxc, UInt, UserId};
|
||||
use conduwuit::{Result, checked, err, implement};
|
||||
use ruma::{Mxc, UInt, UserId, http_headers::ContentDisposition, media::Method};
|
||||
use tokio::{
|
||||
fs,
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
};
|
||||
|
||||
use super::{data::Metadata, FileMeta};
|
||||
use super::{FileMeta, data::Metadata};
|
||||
|
||||
/// Dimension specification for a thumbnail.
|
||||
#[derive(Debug)]
|
||||
|
@ -65,12 +65,12 @@ impl super::Service {
|
|||
// 0, 0 because that's the original file
|
||||
let dim = dim.normalized();
|
||||
|
||||
if let Ok(metadata) = self.db.search_file_metadata(mxc, &dim).await {
|
||||
self.get_thumbnail_saved(metadata).await
|
||||
} else if let Ok(metadata) = self.db.search_file_metadata(mxc, &Dim::default()).await {
|
||||
self.get_thumbnail_generate(mxc, &dim, metadata).await
|
||||
} else {
|
||||
Ok(None)
|
||||
match self.db.search_file_metadata(mxc, &dim).await {
|
||||
| Ok(metadata) => self.get_thumbnail_saved(metadata).await,
|
||||
| _ => match self.db.search_file_metadata(mxc, &Dim::default()).await {
|
||||
| Ok(metadata) => self.get_thumbnail_generate(mxc, &dim, metadata).await,
|
||||
| _ => Ok(None),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
use std::cmp;
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug_info, debug_warn, error, info,
|
||||
Err, Result, debug, debug_info, debug_warn, error, info,
|
||||
result::NotFound,
|
||||
utils::{
|
||||
stream::{TryExpect, TryIgnore},
|
||||
IterStream, ReadyExt,
|
||||
stream::{TryExpect, TryIgnore},
|
||||
},
|
||||
warn, Err, Result,
|
||||
warn,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use itertools::Itertools;
|
||||
use ruma::{
|
||||
OwnedUserId, RoomId, UserId,
|
||||
events::{
|
||||
push_rules::PushRulesEvent, room::member::MembershipState, GlobalAccountDataEventType,
|
||||
GlobalAccountDataEventType, push_rules::PushRulesEvent, room::member::MembershipState,
|
||||
},
|
||||
push::Ruleset,
|
||||
OwnedUserId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::{media, Services};
|
||||
use crate::{Services, media};
|
||||
|
||||
/// The current schema version.
|
||||
/// - If database is opened at greater version we reject with error. The
|
||||
|
|
|
@ -30,7 +30,7 @@ pub mod users;
|
|||
extern crate conduwuit_core as conduwuit;
|
||||
extern crate conduwuit_database as database;
|
||||
|
||||
pub use conduwuit::{pdu, PduBuilder, PduCount, PduEvent};
|
||||
pub use conduwuit::{PduBuilder, PduCount, PduEvent, pdu};
|
||||
pub(crate) use service::{Args, Dep, Service};
|
||||
|
||||
pub use crate::services::Services;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{
|
||||
debug_warn, utils,
|
||||
utils::{stream::TryIgnore, ReadyExt},
|
||||
Result,
|
||||
Result, debug_warn, utils,
|
||||
utils::{ReadyExt, stream::TryIgnore},
|
||||
};
|
||||
use database::{Deserialized, Json, Map};
|
||||
use futures::Stream;
|
||||
use ruma::{events::presence::PresenceEvent, presence::PresenceState, UInt, UserId};
|
||||
use ruma::{UInt, UserId, events::presence::PresenceEvent, presence::PresenceState};
|
||||
|
||||
use super::Presence;
|
||||
use crate::{globals, users, Dep};
|
||||
use crate::{Dep, globals, users};
|
||||
|
||||
pub(crate) struct Data {
|
||||
presenceid_presence: Arc<Map>,
|
||||
|
|
|
@ -5,16 +5,16 @@ use std::{sync::Arc, time::Duration};
|
|||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
checked, debug, debug_warn, error, result::LogErr, trace, Error, Result, Server,
|
||||
Error, Result, Server, checked, debug, debug_warn, error, result::LogErr, trace,
|
||||
};
|
||||
use database::Database;
|
||||
use futures::{stream::FuturesUnordered, Stream, StreamExt, TryFutureExt};
|
||||
use futures::{Stream, StreamExt, TryFutureExt, stream::FuturesUnordered};
|
||||
use loole::{Receiver, Sender};
|
||||
use ruma::{events::presence::PresenceEvent, presence::PresenceState, OwnedUserId, UInt, UserId};
|
||||
use ruma::{OwnedUserId, UInt, UserId, events::presence::PresenceEvent, presence::PresenceState};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use self::{data::Data, presence::Presence};
|
||||
use crate::{globals, users, Dep};
|
||||
use crate::{Dep, globals, users};
|
||||
|
||||
pub struct Service {
|
||||
timer_channel: (Sender<TimerType>, Receiver<TimerType>),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use conduwuit::{utils, Error, Result};
|
||||
use conduwuit::{Error, Result, utils};
|
||||
use ruma::{
|
||||
UInt, UserId,
|
||||
events::presence::{PresenceEvent, PresenceEventContent},
|
||||
presence::PresenceState,
|
||||
UInt, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
|
@ -2,34 +2,35 @@ use std::{fmt::Debug, mem, sync::Arc};
|
|||
|
||||
use bytes::BytesMut;
|
||||
use conduwuit::{
|
||||
debug_warn, err, trace,
|
||||
Err, PduEvent, Result, debug_warn, err, trace,
|
||||
utils::{stream::TryIgnore, string_from_bytes},
|
||||
warn, Err, PduEvent, Result,
|
||||
warn,
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ipaddress::IPAddress;
|
||||
use ruma::{
|
||||
RoomId, UInt, UserId,
|
||||
api::{
|
||||
client::push::{set_pusher, Pusher, PusherKind},
|
||||
IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
|
||||
client::push::{Pusher, PusherKind, set_pusher},
|
||||
push_gateway::send_event_notification::{
|
||||
self,
|
||||
v1::{Device, Notification, NotificationCounts, NotificationPriority},
|
||||
},
|
||||
IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
|
||||
},
|
||||
events::{
|
||||
room::power_levels::RoomPowerLevelsEventContent, AnySyncTimelineEvent, StateEventType,
|
||||
TimelineEventType,
|
||||
AnySyncTimelineEvent, StateEventType, TimelineEventType,
|
||||
room::power_levels::RoomPowerLevelsEventContent,
|
||||
},
|
||||
push::{
|
||||
Action, PushConditionPowerLevelsCtx, PushConditionRoomCtx, PushFormat, Ruleset, Tweak,
|
||||
},
|
||||
serde::Raw,
|
||||
uint, RoomId, UInt, UserId,
|
||||
uint,
|
||||
};
|
||||
|
||||
use crate::{client, globals, rooms, sending, users, Dep};
|
||||
use crate::{Dep, client, globals, rooms, sending, users};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{
|
|||
net::{IpAddr, SocketAddr},
|
||||
};
|
||||
|
||||
use conduwuit::{debug, debug_error, debug_info, debug_warn, err, error, trace, Err, Result};
|
||||
use conduwuit::{Err, Result, debug, debug_error, debug_info, debug_warn, err, error, trace};
|
||||
use futures::{FutureExt, TryFutureExt};
|
||||
use hickory_resolver::error::ResolveError;
|
||||
use ipaddress::IPAddress;
|
||||
|
@ -11,7 +11,7 @@ use ruma::ServerName;
|
|||
|
||||
use super::{
|
||||
cache::{CachedDest, CachedOverride, MAX_IPS},
|
||||
fed::{add_port_to_hostname, get_ip_with_port, FedDest, PortString},
|
||||
fed::{FedDest, PortString, add_port_to_hostname, get_ip_with_port},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -71,12 +71,16 @@ impl super::Service {
|
|||
| None =>
|
||||
if let Some(pos) = dest.as_str().find(':') {
|
||||
self.actual_dest_2(dest, cache, pos).await?
|
||||
} else if let Some(delegated) = self.request_well_known(dest.as_str()).await? {
|
||||
self.actual_dest_3(&mut host, cache, delegated).await?
|
||||
} else if let Some(overrider) = self.query_srv_record(dest.as_str()).await? {
|
||||
self.actual_dest_4(&host, cache, overrider).await?
|
||||
} else {
|
||||
self.actual_dest_5(dest, cache).await?
|
||||
match self.request_well_known(dest.as_str()).await? {
|
||||
| Some(delegated) =>
|
||||
self.actual_dest_3(&mut host, cache, delegated).await?,
|
||||
| _ => match self.query_srv_record(dest.as_str()).await? {
|
||||
| Some(overrider) =>
|
||||
self.actual_dest_4(&host, cache, overrider).await?,
|
||||
| _ => self.actual_dest_5(dest, cache).await?,
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -136,10 +140,10 @@ impl super::Service {
|
|||
self.actual_dest_3_2(cache, delegated, pos).await
|
||||
} else {
|
||||
trace!("Delegated hostname has no port in this branch");
|
||||
if let Some(overrider) = self.query_srv_record(&delegated).await? {
|
||||
self.actual_dest_3_3(cache, delegated, overrider).await
|
||||
} else {
|
||||
self.actual_dest_3_4(cache, delegated).await
|
||||
match self.query_srv_record(&delegated).await? {
|
||||
| Some(overrider) =>
|
||||
self.actual_dest_3_3(cache, delegated, overrider).await,
|
||||
| _ => self.actual_dest_3_4(cache, delegated).await,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::{net::IpAddr, sync::Arc, time::SystemTime};
|
||||
|
||||
use conduwuit::{
|
||||
Result,
|
||||
arrayvec::ArrayVec,
|
||||
at, err, implement,
|
||||
utils::{math::Expected, rand, stream::TryIgnore},
|
||||
Result,
|
||||
};
|
||||
use database::{Cbor, Deserialized, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
|
@ -96,7 +96,7 @@ pub fn destinations(&self) -> impl Stream<Item = (&ServerName, CachedDest)> + Se
|
|||
self.destinations
|
||||
.stream()
|
||||
.ignore_err()
|
||||
.map(|item: (&ServerName, Cbor<_>)| (item.0, item.1 .0))
|
||||
.map(|item: (&ServerName, Cbor<_>)| (item.0, item.1.0))
|
||||
}
|
||||
|
||||
#[implement(Cache)]
|
||||
|
@ -104,7 +104,7 @@ pub fn overrides(&self) -> impl Stream<Item = (&ServerName, CachedOverride)> + S
|
|||
self.overrides
|
||||
.stream()
|
||||
.ignore_err()
|
||||
.map(|item: (&ServerName, Cbor<_>)| (item.0, item.1 .0))
|
||||
.map(|item: (&ServerName, Cbor<_>)| (item.0, item.1.0))
|
||||
}
|
||||
|
||||
impl CachedDest {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::{net::SocketAddr, sync::Arc, time::Duration};
|
||||
|
||||
use conduwuit::{err, Result, Server};
|
||||
use conduwuit::{Result, Server, err};
|
||||
use futures::FutureExt;
|
||||
use hickory_resolver::{lookup_ip::LookupIp, TokioAsyncResolver};
|
||||
use hickory_resolver::{TokioAsyncResolver, lookup_ip::LookupIp};
|
||||
use reqwest::dns::{Addrs, Name, Resolve, Resolving};
|
||||
|
||||
use super::cache::{Cache, CachedOverride};
|
||||
|
|
|
@ -6,10 +6,10 @@ mod tests;
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{arrayvec::ArrayString, utils::MutexMap, Result, Server};
|
||||
use conduwuit::{Result, Server, arrayvec::ArrayString, utils::MutexMap};
|
||||
|
||||
use self::{cache::Cache, dns::Resolver};
|
||||
use crate::{client, Dep};
|
||||
use crate::{Dep, client};
|
||||
|
||||
pub struct Service {
|
||||
pub cache: Arc<Cache>,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#![cfg(test)]
|
||||
|
||||
use super::fed::{add_port_to_hostname, get_ip_with_port, FedDest};
|
||||
use super::fed::{FedDest, add_port_to_hostname, get_ip_with_port};
|
||||
|
||||
#[test]
|
||||
fn ips_get_default_ports() {
|
||||
|
|
|
@ -3,21 +3,20 @@ mod remote;
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{
|
||||
err,
|
||||
utils::{stream::TryIgnore, ReadyExt},
|
||||
Err, Result, Server,
|
||||
Err, Result, Server, err,
|
||||
utils::{ReadyExt, stream::TryIgnore},
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Map};
|
||||
use futures::{Stream, StreamExt, TryFutureExt};
|
||||
use ruma::{
|
||||
events::{
|
||||
room::power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
|
||||
StateEventType,
|
||||
},
|
||||
OwnedRoomId, OwnedServerName, OwnedUserId, RoomAliasId, RoomId, RoomOrAliasId, UserId,
|
||||
events::{
|
||||
StateEventType,
|
||||
room::power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
|
||||
},
|
||||
};
|
||||
|
||||
use crate::{admin, appservice, appservice::RegistrationInfo, globals, rooms, sending, Dep};
|
||||
use crate::{Dep, admin, appservice, appservice::RegistrationInfo, globals, rooms, sending};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::iter::once;
|
||||
|
||||
use conduwuit::{debug, debug_error, err, implement, Result};
|
||||
use conduwuit::{Result, debug, debug_error, err, implement};
|
||||
use federation::query::get_room_information::v1::Response;
|
||||
use ruma::{api::federation, OwnedRoomId, OwnedServerName, RoomAliasId, ServerName};
|
||||
use ruma::{OwnedRoomId, OwnedServerName, RoomAliasId, ServerName, api::federation};
|
||||
|
||||
#[implement(super::Service)]
|
||||
pub(super) async fn remote_resolve(
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use conduwuit::{err, utils, utils::math::usize_from_f64, Err, Result};
|
||||
use conduwuit::{Err, Result, err, utils, utils::math::usize_from_f64};
|
||||
use database::Map;
|
||||
use lru_cache::LruCache;
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
at, debug, debug_error, implement, trace,
|
||||
Err, Result, at, debug, debug_error, implement, trace,
|
||||
utils::{
|
||||
stream::{ReadyExt, TryBroadbandExt},
|
||||
IterStream,
|
||||
stream::{ReadyExt, TryBroadbandExt},
|
||||
},
|
||||
validated, warn, Err, Result,
|
||||
validated, warn,
|
||||
};
|
||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use ruma::{EventId, OwnedEventId, RoomId};
|
||||
|
||||
use self::data::Data;
|
||||
use crate::{rooms, rooms::short::ShortEventId, Dep};
|
||||
use crate::{Dep, rooms, rooms::short::ShortEventId};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{implement, utils::stream::TryIgnore, Result};
|
||||
use conduwuit::{Result, implement, utils::stream::TryIgnore};
|
||||
use database::Map;
|
||||
use futures::Stream;
|
||||
use ruma::{api::client::room::Visibility, RoomId};
|
||||
use ruma::{RoomId, api::client::room::Visibility};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use conduwuit::{debug, implement, trace, warn, Err, Result};
|
||||
use conduwuit::{Err, Result, debug, implement, trace, warn};
|
||||
use ruma::{
|
||||
events::{room::server_acl::RoomServerAclEventContent, StateEventType},
|
||||
RoomId, ServerName,
|
||||
events::{StateEventType, room::server_acl::RoomServerAclEventContent},
|
||||
};
|
||||
|
||||
/// Returns Ok if the acl allows the server
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use std::{
|
||||
collections::{hash_map, BTreeMap, HashSet, VecDeque},
|
||||
collections::{BTreeMap, HashSet, VecDeque, hash_map},
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug_error, debug_warn, implement, pdu, trace,
|
||||
utils::continue_exponential_backoff_secs, warn, PduEvent,
|
||||
PduEvent, debug, debug_error, debug_warn, implement, pdu, trace,
|
||||
utils::continue_exponential_backoff_secs, warn,
|
||||
};
|
||||
use futures::TryFutureExt;
|
||||
use ruma::{
|
||||
api::federation::event::get_event, CanonicalJsonValue, OwnedEventId, RoomId, ServerName,
|
||||
CanonicalJsonValue, OwnedEventId, RoomId, ServerName, api::federation::event::get_event,
|
||||
};
|
||||
|
||||
use super::get_room_version_id;
|
||||
|
@ -138,12 +138,15 @@ pub(super) async fn fetch_and_handle_outliers<'a>(
|
|||
.and_then(CanonicalJsonValue::as_array)
|
||||
{
|
||||
for auth_event in auth_events {
|
||||
if let Ok(auth_event) =
|
||||
serde_json::from_value::<OwnedEventId>(auth_event.clone().into())
|
||||
{
|
||||
todo_auth_events.push_back(auth_event);
|
||||
} else {
|
||||
warn!("Auth event id is not valid");
|
||||
match serde_json::from_value::<OwnedEventId>(
|
||||
auth_event.clone().into(),
|
||||
) {
|
||||
| Ok(auth_event) => {
|
||||
todo_auth_events.push_back(auth_event);
|
||||
},
|
||||
| _ => {
|
||||
warn!("Auth event id is not valid");
|
||||
},
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -4,14 +4,13 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
debug_warn, err, implement,
|
||||
PduEvent, Result, debug_warn, err, implement,
|
||||
state_res::{self},
|
||||
PduEvent, Result,
|
||||
};
|
||||
use futures::{future, FutureExt};
|
||||
use futures::{FutureExt, future};
|
||||
use ruma::{
|
||||
int, uint, CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, ServerName,
|
||||
UInt,
|
||||
CanonicalJsonValue, MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, ServerName, UInt, int,
|
||||
uint,
|
||||
};
|
||||
|
||||
use super::check_room_id;
|
||||
|
@ -43,54 +42,59 @@ pub(super) async fn fetch_prev(
|
|||
while let Some(prev_event_id) = todo_outlier_stack.pop_front() {
|
||||
self.services.server.check_running()?;
|
||||
|
||||
if let Some((pdu, mut json_opt)) = self
|
||||
match self
|
||||
.fetch_and_handle_outliers(origin, &[prev_event_id.clone()], create_event, room_id)
|
||||
.boxed()
|
||||
.await
|
||||
.pop()
|
||||
{
|
||||
check_room_id(room_id, &pdu)?;
|
||||
| Some((pdu, mut json_opt)) => {
|
||||
check_room_id(room_id, &pdu)?;
|
||||
|
||||
let limit = self.services.server.config.max_fetch_prev_events;
|
||||
if amount > limit {
|
||||
debug_warn!("Max prev event limit reached! Limit: {limit}");
|
||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||
continue;
|
||||
}
|
||||
|
||||
if json_opt.is_none() {
|
||||
json_opt = self
|
||||
.services
|
||||
.outlier
|
||||
.get_outlier_pdu_json(&prev_event_id)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
if let Some(json) = json_opt {
|
||||
if pdu.origin_server_ts > first_ts_in_room {
|
||||
amount = amount.saturating_add(1);
|
||||
for prev_prev in &pdu.prev_events {
|
||||
if !graph.contains_key(prev_prev) {
|
||||
todo_outlier_stack.push_back(prev_prev.clone());
|
||||
}
|
||||
}
|
||||
|
||||
graph
|
||||
.insert(prev_event_id.clone(), pdu.prev_events.iter().cloned().collect());
|
||||
} else {
|
||||
// Time based check failed
|
||||
let limit = self.services.server.config.max_fetch_prev_events;
|
||||
if amount > limit {
|
||||
debug_warn!("Max prev event limit reached! Limit: {limit}");
|
||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||
continue;
|
||||
}
|
||||
|
||||
eventid_info.insert(prev_event_id.clone(), (pdu, json));
|
||||
} else {
|
||||
// Get json failed, so this was not fetched over federation
|
||||
if json_opt.is_none() {
|
||||
json_opt = self
|
||||
.services
|
||||
.outlier
|
||||
.get_outlier_pdu_json(&prev_event_id)
|
||||
.await
|
||||
.ok();
|
||||
}
|
||||
|
||||
if let Some(json) = json_opt {
|
||||
if pdu.origin_server_ts > first_ts_in_room {
|
||||
amount = amount.saturating_add(1);
|
||||
for prev_prev in &pdu.prev_events {
|
||||
if !graph.contains_key(prev_prev) {
|
||||
todo_outlier_stack.push_back(prev_prev.clone());
|
||||
}
|
||||
}
|
||||
|
||||
graph.insert(
|
||||
prev_event_id.clone(),
|
||||
pdu.prev_events.iter().cloned().collect(),
|
||||
);
|
||||
} else {
|
||||
// Time based check failed
|
||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||
}
|
||||
|
||||
eventid_info.insert(prev_event_id.clone(), (pdu, json));
|
||||
} else {
|
||||
// Get json failed, so this was not fetched over federation
|
||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||
}
|
||||
},
|
||||
| _ => {
|
||||
// Fetch and handle failed
|
||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||
}
|
||||
} else {
|
||||
// Fetch and handle failed
|
||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::collections::{hash_map, HashMap};
|
||||
use std::collections::{HashMap, hash_map};
|
||||
|
||||
use conduwuit::{debug, debug_warn, implement, Err, Error, PduEvent, Result};
|
||||
use conduwuit::{Err, Error, PduEvent, Result, debug, debug_warn, implement};
|
||||
use futures::FutureExt;
|
||||
use ruma::{
|
||||
api::federation::event::get_room_state_ids, events::StateEventType, EventId, OwnedEventId,
|
||||
RoomId, ServerName,
|
||||
EventId, OwnedEventId, RoomId, ServerName, api::federation::event::get_room_state_ids,
|
||||
events::StateEventType,
|
||||
};
|
||||
|
||||
use crate::rooms::short::ShortStateKey;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use std::{
|
||||
collections::{hash_map, BTreeMap},
|
||||
collections::{BTreeMap, hash_map},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use conduwuit::{debug, debug::INFO_SPAN_LEVEL, err, implement, warn, Err, Result};
|
||||
use conduwuit::{Err, Result, debug, debug::INFO_SPAN_LEVEL, err, implement, warn};
|
||||
use futures::{
|
||||
future::{try_join5, OptionFuture},
|
||||
FutureExt,
|
||||
future::{OptionFuture, try_join5},
|
||||
};
|
||||
use ruma::{events::StateEventType, CanonicalJsonValue, EventId, RoomId, ServerName, UserId};
|
||||
use ruma::{CanonicalJsonValue, EventId, RoomId, ServerName, UserId, events::StateEventType};
|
||||
|
||||
use crate::rooms::timeline::RawPduId;
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use std::{
|
||||
collections::{hash_map, BTreeMap, HashMap},
|
||||
collections::{BTreeMap, HashMap, hash_map},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug_info, err, implement, state_res, trace, warn, Err, Error, PduEvent, Result,
|
||||
Err, Error, PduEvent, Result, debug, debug_info, err, implement, state_res, trace, warn,
|
||||
};
|
||||
use futures::{future::ready, TryFutureExt};
|
||||
use futures::{TryFutureExt, future::ready};
|
||||
use ruma::{
|
||||
api::client::error::ErrorKind, events::StateEventType, CanonicalJsonObject,
|
||||
CanonicalJsonValue, EventId, RoomId, ServerName,
|
||||
CanonicalJsonObject, CanonicalJsonValue, EventId, RoomId, ServerName,
|
||||
api::client::error::ErrorKind, events::StateEventType,
|
||||
};
|
||||
|
||||
use super::{check_room_id, get_room_version_id, to_room_version};
|
||||
|
|
|
@ -5,8 +5,8 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug::INFO_SPAN_LEVEL, implement, utils::continue_exponential_backoff_secs, Err,
|
||||
PduEvent, Result,
|
||||
Err, PduEvent, Result, debug, debug::INFO_SPAN_LEVEL, implement,
|
||||
utils::continue_exponential_backoff_secs,
|
||||
};
|
||||
use ruma::{CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName, UInt};
|
||||
|
||||
|
|
|
@ -18,16 +18,16 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
utils::{MutexMap, TryFutureExtExt},
|
||||
Err, PduEvent, Result, RoomVersion, Server,
|
||||
utils::{MutexMap, TryFutureExtExt},
|
||||
};
|
||||
use futures::TryFutureExt;
|
||||
use ruma::{
|
||||
events::room::create::RoomCreateEventContent, OwnedEventId, OwnedRoomId, RoomId,
|
||||
RoomVersionId,
|
||||
OwnedEventId, OwnedRoomId, RoomId, RoomVersionId,
|
||||
events::room::create::RoomCreateEventContent,
|
||||
};
|
||||
|
||||
use crate::{globals, rooms, sending, server_keys, Dep};
|
||||
use crate::{Dep, globals, rooms, sending, server_keys};
|
||||
|
||||
pub struct Service {
|
||||
pub mutex_federation: RoomMutexMap,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use conduwuit::{err, implement, pdu::gen_event_id_canonical_json, result::FlatOk, Result};
|
||||
use conduwuit::{Result, err, implement, pdu::gen_event_id_canonical_json, result::FlatOk};
|
||||
use ruma::{CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, OwnedRoomId};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
|
|
|
@ -5,13 +5,12 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
err, implement,
|
||||
Error, Result, err, implement,
|
||||
state_res::{self, StateMap},
|
||||
trace,
|
||||
utils::stream::{automatic_width, IterStream, ReadyExt, TryWidebandExt, WidebandExt},
|
||||
Error, Result,
|
||||
utils::stream::{IterStream, ReadyExt, TryWidebandExt, WidebandExt, automatic_width},
|
||||
};
|
||||
use futures::{future::try_join, FutureExt, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::try_join};
|
||||
use ruma::{OwnedEventId, RoomId, RoomVersionId};
|
||||
|
||||
use crate::rooms::state_compressor::CompressedState;
|
||||
|
@ -93,11 +92,7 @@ pub async fn resolve_state(
|
|||
let new_room_state: CompressedState = self
|
||||
.services
|
||||
.state_compressor
|
||||
.compress_state_events(
|
||||
state_events
|
||||
.iter()
|
||||
.map(|(ref ssk, eid)| (ssk, (*eid).borrow())),
|
||||
)
|
||||
.compress_state_events(state_events.iter().map(|(ssk, eid)| (ssk, (*eid).borrow())))
|
||||
.collect()
|
||||
.await;
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
debug, err, implement, trace,
|
||||
PduEvent, Result, StateMap, debug, err, implement, trace,
|
||||
utils::stream::{BroadbandExt, IterStream, ReadyExt, TryBroadbandExt, TryWidebandExt},
|
||||
PduEvent, Result, StateMap,
|
||||
};
|
||||
use futures::{future::try_join, FutureExt, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, future::try_join};
|
||||
use ruma::{OwnedEventId, RoomId, RoomVersionId};
|
||||
|
||||
use crate::rooms::short::ShortStateHash;
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::{borrow::Borrow, collections::BTreeMap, iter::once, sync::Arc, time::Instant};
|
||||
|
||||
use conduwuit::{
|
||||
debug, debug_info, err, implement, state_res, trace,
|
||||
Err, EventTypeExt, PduEvent, Result, StateKey, debug, debug_info, err, implement, state_res,
|
||||
trace,
|
||||
utils::stream::{BroadbandExt, ReadyExt},
|
||||
warn, Err, EventTypeExt, PduEvent, Result, StateKey,
|
||||
warn,
|
||||
};
|
||||
use futures::{future::ready, FutureExt, StreamExt};
|
||||
use ruma::{events::StateEventType, CanonicalJsonValue, RoomId, ServerName};
|
||||
use futures::{FutureExt, StreamExt, future::ready};
|
||||
use ruma::{CanonicalJsonValue, RoomId, ServerName, events::StateEventType};
|
||||
|
||||
use super::{get_room_version_id, to_room_version};
|
||||
use crate::rooms::{
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
use std::{collections::HashSet, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
implement,
|
||||
utils::{stream::TryIgnore, IterStream, ReadyExt},
|
||||
Result,
|
||||
Result, implement,
|
||||
utils::{IterStream, ReadyExt, stream::TryIgnore},
|
||||
};
|
||||
use database::{Database, Deserialized, Handle, Interfix, Map, Qry};
|
||||
use futures::{pin_mut, Stream, StreamExt};
|
||||
use ruma::{api::client::filter::LazyLoadOptions, DeviceId, OwnedUserId, RoomId, UserId};
|
||||
use futures::{Stream, StreamExt, pin_mut};
|
||||
use ruma::{DeviceId, OwnedUserId, RoomId, UserId, api::client::filter::LazyLoadOptions};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{implement, utils::stream::TryIgnore, Result};
|
||||
use conduwuit::{Result, implement, utils::stream::TryIgnore};
|
||||
use database::Map;
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::RoomId;
|
||||
|
||||
use crate::{rooms, Dep};
|
||||
use crate::{Dep, rooms};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{implement, Result};
|
||||
use conduwuit::{Result, implement};
|
||||
use database::{Deserialized, Json, Map};
|
||||
use ruma::{CanonicalJsonObject, EventId};
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
use std::{mem::size_of, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
PduCount, PduEvent,
|
||||
arrayvec::ArrayVec,
|
||||
result::LogErr,
|
||||
utils::{
|
||||
ReadyExt,
|
||||
stream::{TryIgnore, WidebandExt},
|
||||
u64_from_u8, ReadyExt,
|
||||
u64_from_u8,
|
||||
},
|
||||
PduCount, PduEvent,
|
||||
};
|
||||
use database::Map;
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{api::Direction, EventId, RoomId, UserId};
|
||||
use ruma::{EventId, RoomId, UserId, api::Direction};
|
||||
|
||||
use crate::{
|
||||
rooms,
|
||||
Dep, rooms,
|
||||
rooms::{
|
||||
short::{ShortEventId, ShortRoomId},
|
||||
timeline::{PduId, RawPduId},
|
||||
},
|
||||
Dep,
|
||||
};
|
||||
|
||||
pub(super) struct Data {
|
||||
|
|
|
@ -2,11 +2,11 @@ mod data;
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{PduCount, Result};
|
||||
use futures::{future::try_join, StreamExt};
|
||||
use ruma::{api::Direction, EventId, RoomId, UserId};
|
||||
use futures::{StreamExt, future::try_join};
|
||||
use ruma::{EventId, RoomId, UserId, api::Direction};
|
||||
|
||||
use self::data::{Data, PdusIterItem};
|
||||
use crate::{rooms, Dep};
|
||||
use crate::{Dep, rooms};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
@ -81,7 +81,7 @@ impl Service {
|
|||
.collect();
|
||||
|
||||
'limit: while let Some(stack_pdu) = stack.pop() {
|
||||
let target = match stack_pdu.0 .0 {
|
||||
let target = match stack_pdu.0.0 {
|
||||
| PduCount::Normal(c) => c,
|
||||
// TODO: Support backfilled relations
|
||||
| PduCount::Backfilled(_) => 0, // This will result in an empty iterator
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{
|
||||
utils::{stream::TryIgnore, ReadyExt},
|
||||
Result,
|
||||
utils::{ReadyExt, stream::TryIgnore},
|
||||
};
|
||||
use database::{Deserialized, Json, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{
|
||||
events::{receipt::ReceiptEvent, AnySyncEphemeralRoomEvent},
|
||||
serde::Raw,
|
||||
CanonicalJsonObject, RoomId, UserId,
|
||||
events::{AnySyncEphemeralRoomEvent, receipt::ReceiptEvent},
|
||||
serde::Raw,
|
||||
};
|
||||
|
||||
use crate::{globals, Dep};
|
||||
use crate::{Dep, globals};
|
||||
|
||||
pub(super) struct Data {
|
||||
roomuserid_privateread: Arc<Map>,
|
||||
|
|
|
@ -2,19 +2,19 @@ mod data;
|
|||
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduwuit::{debug, err, warn, PduCount, PduId, RawPduId, Result};
|
||||
use futures::{try_join, Stream, TryFutureExt};
|
||||
use conduwuit::{PduCount, PduId, RawPduId, Result, debug, err, warn};
|
||||
use futures::{Stream, TryFutureExt, try_join};
|
||||
use ruma::{
|
||||
OwnedEventId, OwnedUserId, RoomId, UserId,
|
||||
events::{
|
||||
receipt::{ReceiptEvent, ReceiptEventContent, Receipts},
|
||||
AnySyncEphemeralRoomEvent, SyncEphemeralRoomEvent,
|
||||
receipt::{ReceiptEvent, ReceiptEventContent, Receipts},
|
||||
},
|
||||
serde::Raw,
|
||||
OwnedEventId, OwnedUserId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use self::data::{Data, ReceiptItem};
|
||||
use crate::{rooms, sending, Dep};
|
||||
use crate::{Dep, rooms, sending};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
@ -145,12 +145,14 @@ where
|
|||
let receipt = serde_json::from_str::<SyncEphemeralRoomEvent<ReceiptEventContent>>(
|
||||
value.json().get(),
|
||||
);
|
||||
if let Ok(value) = receipt {
|
||||
for (event, receipt) in value.content {
|
||||
json.insert(event, receipt);
|
||||
}
|
||||
} else {
|
||||
debug!("failed to parse receipt: {:?}", receipt);
|
||||
match receipt {
|
||||
| Ok(value) =>
|
||||
for (event, receipt) in value.content {
|
||||
json.insert(event, receipt);
|
||||
},
|
||||
| _ => {
|
||||
debug!("failed to parse receipt: {:?}", receipt);
|
||||
},
|
||||
}
|
||||
}
|
||||
let content = ReceiptEventContent::from_iter(json);
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{
|
||||
PduCount, PduEvent, Result,
|
||||
arrayvec::ArrayVec,
|
||||
implement,
|
||||
utils::{
|
||||
set,
|
||||
ArrayVecExt, IterStream, ReadyExt, set,
|
||||
stream::{TryIgnore, WidebandExt},
|
||||
ArrayVecExt, IterStream, ReadyExt,
|
||||
},
|
||||
PduCount, PduEvent, Result,
|
||||
};
|
||||
use database::{keyval::Val, Map};
|
||||
use database::{Map, keyval::Val};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{api::client::search::search_events::v3::Criteria, RoomId, UserId};
|
||||
use ruma::{RoomId, UserId, api::client::search::search_events::v3::Criteria};
|
||||
|
||||
use crate::{
|
||||
rooms,
|
||||
Dep, rooms,
|
||||
rooms::{
|
||||
short::ShortRoomId,
|
||||
timeline::{PduId, RawPduId},
|
||||
},
|
||||
Dep,
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
|
@ -140,7 +138,7 @@ pub async fn search_pdus<'a>(
|
|||
pub async fn search_pdu_ids(
|
||||
&self,
|
||||
query: &RoomQuery<'_>,
|
||||
) -> Result<impl Stream<Item = RawPduId> + Send + '_> {
|
||||
) -> Result<impl Stream<Item = RawPduId> + Send + '_ + use<'_>> {
|
||||
let shortroomid = self.services.short.get_shortroomid(query.room_id).await?;
|
||||
|
||||
let pdu_ids = self.search_pdu_ids_query_room(query, shortroomid).await;
|
||||
|
@ -187,7 +185,7 @@ fn search_pdu_ids_query_word(
|
|||
&self,
|
||||
shortroomid: ShortRoomId,
|
||||
word: &str,
|
||||
) -> impl Stream<Item = Val<'_>> + Send + '_ {
|
||||
) -> impl Stream<Item = Val<'_>> + Send + '_ + use<'_> {
|
||||
// rustc says const'ing this not yet stable
|
||||
let end_id: RawPduId = PduId {
|
||||
shortroomid,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use std::{borrow::Borrow, fmt::Debug, mem::size_of_val, sync::Arc};
|
||||
|
||||
pub use conduwuit::pdu::{ShortEventId, ShortId, ShortRoomId, ShortStateKey};
|
||||
use conduwuit::{err, implement, utils, utils::IterStream, Result, StateKey};
|
||||
use conduwuit::{Result, StateKey, err, implement, utils, utils::IterStream};
|
||||
use database::{Deserialized, Get, Map, Qry};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{events::StateEventType, EventId, RoomId};
|
||||
use ruma::{EventId, RoomId, events::StateEventType};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{globals, Dep};
|
||||
use crate::{Dep, globals};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -5,18 +5,18 @@ mod tests;
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{
|
||||
implement,
|
||||
Err, Error, Result, implement,
|
||||
utils::{
|
||||
IterStream,
|
||||
future::BoolExt,
|
||||
math::usize_from_f64,
|
||||
stream::{BroadbandExt, ReadyExt},
|
||||
IterStream,
|
||||
},
|
||||
Err, Error, Result,
|
||||
};
|
||||
use futures::{pin_mut, stream::FuturesUnordered, FutureExt, Stream, StreamExt, TryFutureExt};
|
||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, pin_mut, stream::FuturesUnordered};
|
||||
use lru_cache::LruCache;
|
||||
use ruma::{
|
||||
OwnedEventId, OwnedRoomId, OwnedServerName, RoomId, ServerName, UserId,
|
||||
api::{
|
||||
client::space::SpaceHierarchyRoomsChunk,
|
||||
federation::{
|
||||
|
@ -25,18 +25,17 @@ use ruma::{
|
|||
},
|
||||
},
|
||||
events::{
|
||||
StateEventType,
|
||||
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
|
||||
space::child::{HierarchySpaceChildEvent, SpaceChildEventContent},
|
||||
StateEventType,
|
||||
},
|
||||
serde::Raw,
|
||||
space::SpaceRoomJoinRule,
|
||||
OwnedEventId, OwnedRoomId, OwnedServerName, RoomId, ServerName, UserId,
|
||||
};
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
|
||||
pub use self::pagination_token::PaginationToken;
|
||||
use crate::{conduwuit::utils::TryFutureExtExt, rooms, sending, Dep};
|
||||
use crate::{Dep, conduwuit::utils::TryFutureExtExt, rooms, sending};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
@ -440,8 +439,9 @@ async fn is_accessible_child(
|
|||
pub fn get_parent_children_via(
|
||||
parent: &SpaceHierarchyParentSummary,
|
||||
suggested_only: bool,
|
||||
) -> impl DoubleEndedIterator<Item = (OwnedRoomId, impl Iterator<Item = OwnedServerName>)> + Send + '_
|
||||
{
|
||||
) -> impl DoubleEndedIterator<Item = (OwnedRoomId, impl Iterator<Item = OwnedServerName> + use<>)>
|
||||
+ Send
|
||||
+ '_ {
|
||||
parent
|
||||
.children_state
|
||||
.iter()
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{Error, Result};
|
||||
use ruma::{api::client::error::ErrorKind, UInt};
|
||||
use ruma::{UInt, api::client::error::ErrorKind};
|
||||
|
||||
use crate::rooms::short::ShortRoomId;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use ruma::{
|
||||
UInt,
|
||||
api::federation::space::{SpaceHierarchyParentSummary, SpaceHierarchyParentSummaryInit},
|
||||
owned_room_id, owned_server_name,
|
||||
space::SpaceRoomJoinRule,
|
||||
UInt,
|
||||
};
|
||||
|
||||
use crate::rooms::spaces::{get_parent_children_via, PaginationToken};
|
||||
use crate::rooms::spaces::{PaginationToken, get_parent_children_via};
|
||||
|
||||
#[test]
|
||||
fn get_summary_children() {
|
||||
|
|
|
@ -1,36 +1,34 @@
|
|||
use std::{collections::HashMap, fmt::Write, iter::once, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
err,
|
||||
PduEvent, Result, err,
|
||||
result::FlatOk,
|
||||
state_res::{self, StateMap},
|
||||
utils::{
|
||||
calculate_hash,
|
||||
IterStream, MutexMap, MutexMapGuard, ReadyExt, calculate_hash,
|
||||
stream::{BroadbandExt, TryIgnore},
|
||||
IterStream, MutexMap, MutexMapGuard, ReadyExt,
|
||||
},
|
||||
warn, PduEvent, Result,
|
||||
warn,
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Map};
|
||||
use futures::{
|
||||
future::join_all, pin_mut, FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt,
|
||||
FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, future::join_all, pin_mut,
|
||||
};
|
||||
use ruma::{
|
||||
EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId,
|
||||
events::{
|
||||
room::{create::RoomCreateEventContent, member::RoomMemberEventContent},
|
||||
AnyStrippedStateEvent, StateEventType, TimelineEventType,
|
||||
room::{create::RoomCreateEventContent, member::RoomMemberEventContent},
|
||||
},
|
||||
serde::Raw,
|
||||
EventId, OwnedEventId, OwnedRoomId, RoomId, RoomVersionId, UserId,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
globals, rooms,
|
||||
Dep, globals, rooms,
|
||||
rooms::{
|
||||
short::{ShortEventId, ShortStateHash},
|
||||
state_compressor::{parse_compressed_state_event, CompressedState},
|
||||
state_compressor::{CompressedState, parse_compressed_state_event},
|
||||
},
|
||||
Dep,
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
|
@ -192,13 +190,13 @@ impl Service {
|
|||
.await;
|
||||
|
||||
if !already_existed {
|
||||
let states_parents = if let Ok(p) = previous_shortstatehash {
|
||||
self.services
|
||||
.state_compressor
|
||||
.load_shortstatehash_info(p)
|
||||
.await?
|
||||
} else {
|
||||
Vec::new()
|
||||
let states_parents = match previous_shortstatehash {
|
||||
| Ok(p) =>
|
||||
self.services
|
||||
.state_compressor
|
||||
.load_shortstatehash_info(p)
|
||||
.await?,
|
||||
| _ => Vec::new(),
|
||||
};
|
||||
|
||||
let (statediffnew, statediffremoved) =
|
||||
|
@ -256,63 +254,65 @@ impl Service {
|
|||
.aput::<BUFSIZE, BUFSIZE, _, _>(shorteventid, p);
|
||||
}
|
||||
|
||||
if let Some(state_key) = &new_pdu.state_key {
|
||||
let states_parents = if let Ok(p) = previous_shortstatehash {
|
||||
self.services
|
||||
match &new_pdu.state_key {
|
||||
| Some(state_key) => {
|
||||
let states_parents = match previous_shortstatehash {
|
||||
| Ok(p) =>
|
||||
self.services
|
||||
.state_compressor
|
||||
.load_shortstatehash_info(p)
|
||||
.await?,
|
||||
| _ => Vec::new(),
|
||||
};
|
||||
|
||||
let shortstatekey = self
|
||||
.services
|
||||
.short
|
||||
.get_or_create_shortstatekey(&new_pdu.kind.to_string().into(), state_key)
|
||||
.await;
|
||||
|
||||
let new = self
|
||||
.services
|
||||
.state_compressor
|
||||
.load_shortstatehash_info(p)
|
||||
.await?
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
.compress_state_event(shortstatekey, &new_pdu.event_id)
|
||||
.await;
|
||||
|
||||
let shortstatekey = self
|
||||
.services
|
||||
.short
|
||||
.get_or_create_shortstatekey(&new_pdu.kind.to_string().into(), state_key)
|
||||
.await;
|
||||
let replaces = states_parents
|
||||
.last()
|
||||
.map(|info| {
|
||||
info.full_state
|
||||
.iter()
|
||||
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let new = self
|
||||
.services
|
||||
.state_compressor
|
||||
.compress_state_event(shortstatekey, &new_pdu.event_id)
|
||||
.await;
|
||||
if Some(&new) == replaces {
|
||||
return Ok(previous_shortstatehash.expect("must exist"));
|
||||
}
|
||||
|
||||
let replaces = states_parents
|
||||
.last()
|
||||
.map(|info| {
|
||||
info.full_state
|
||||
.iter()
|
||||
.find(|bytes| bytes.starts_with(&shortstatekey.to_be_bytes()))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
// TODO: statehash with deterministic inputs
|
||||
let shortstatehash = self.services.globals.next_count()?;
|
||||
|
||||
if Some(&new) == replaces {
|
||||
return Ok(previous_shortstatehash.expect("must exist"));
|
||||
}
|
||||
let mut statediffnew = CompressedState::new();
|
||||
statediffnew.insert(new);
|
||||
|
||||
// TODO: statehash with deterministic inputs
|
||||
let shortstatehash = self.services.globals.next_count()?;
|
||||
let mut statediffremoved = CompressedState::new();
|
||||
if let Some(replaces) = replaces {
|
||||
statediffremoved.insert(*replaces);
|
||||
}
|
||||
|
||||
let mut statediffnew = CompressedState::new();
|
||||
statediffnew.insert(new);
|
||||
self.services.state_compressor.save_state_from_diff(
|
||||
shortstatehash,
|
||||
Arc::new(statediffnew),
|
||||
Arc::new(statediffremoved),
|
||||
2,
|
||||
states_parents,
|
||||
)?;
|
||||
|
||||
let mut statediffremoved = CompressedState::new();
|
||||
if let Some(replaces) = replaces {
|
||||
statediffremoved.insert(*replaces);
|
||||
}
|
||||
|
||||
self.services.state_compressor.save_state_from_diff(
|
||||
shortstatehash,
|
||||
Arc::new(statediffnew),
|
||||
Arc::new(statediffremoved),
|
||||
2,
|
||||
states_parents,
|
||||
)?;
|
||||
|
||||
Ok(shortstatehash)
|
||||
} else {
|
||||
Ok(previous_shortstatehash.expect("first event in room must be a state event"))
|
||||
Ok(shortstatehash)
|
||||
},
|
||||
| _ =>
|
||||
Ok(previous_shortstatehash.expect("first event in room must be a state event")),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,14 +9,16 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
err, utils,
|
||||
utils::math::{usize_from_f64, Expected},
|
||||
Result,
|
||||
Result, err, utils,
|
||||
utils::math::{Expected, usize_from_f64},
|
||||
};
|
||||
use database::Map;
|
||||
use lru_cache::LruCache;
|
||||
use ruma::{
|
||||
EventEncryptionAlgorithm, JsOption, OwnedRoomAliasId, OwnedRoomId, OwnedServerName,
|
||||
OwnedUserId, RoomId, UserId,
|
||||
events::{
|
||||
StateEventType,
|
||||
room::{
|
||||
avatar::RoomAvatarEventContent,
|
||||
canonical_alias::RoomCanonicalAliasEventContent,
|
||||
|
@ -29,15 +31,12 @@ use ruma::{
|
|||
name::RoomNameEventContent,
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
StateEventType,
|
||||
},
|
||||
room::RoomType,
|
||||
space::SpaceRoomJoinRule,
|
||||
EventEncryptionAlgorithm, JsOption, OwnedRoomAliasId, OwnedRoomId, OwnedServerName,
|
||||
OwnedUserId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::{rooms, rooms::short::ShortStateHash, Dep};
|
||||
use crate::{Dep, rooms, rooms::short::ShortStateHash};
|
||||
|
||||
pub struct Service {
|
||||
pub server_visibility_cache: Mutex<LruCache<(OwnedServerName, ShortStateHash), bool>>,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::borrow::Borrow;
|
||||
|
||||
use conduwuit::{err, implement, PduEvent, Result, StateKey};
|
||||
use conduwuit::{PduEvent, Result, StateKey, err, implement};
|
||||
use futures::{Stream, StreamExt, TryFutureExt};
|
||||
use ruma::{events::StateEventType, EventId, RoomId};
|
||||
use ruma::{EventId, RoomId, events::StateEventType};
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Returns a single PDU from `room_id` with key (`event_type`,`state_key`).
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use conduwuit::{error, implement, utils::stream::ReadyExt};
|
||||
use futures::StreamExt;
|
||||
use ruma::{
|
||||
events::{
|
||||
room::history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
|
||||
StateEventType,
|
||||
},
|
||||
EventId, RoomId, ServerName,
|
||||
events::{
|
||||
StateEventType,
|
||||
room::history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
|
||||
},
|
||||
};
|
||||
|
||||
/// Whether a server is allowed to see an event through federation, based on
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
use std::{borrow::Borrow, ops::Deref, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
at, err, implement, pair_of,
|
||||
PduEvent, Result, StateKey, at, err, implement, pair_of,
|
||||
utils::{
|
||||
result::FlatOk,
|
||||
stream::{BroadbandExt, IterStream, ReadyExt, TryExpect},
|
||||
},
|
||||
PduEvent, Result, StateKey,
|
||||
};
|
||||
use database::Deserialized;
|
||||
use futures::{future::try_join, pin_mut, FutureExt, Stream, StreamExt, TryFutureExt};
|
||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, future::try_join, pin_mut};
|
||||
use ruma::{
|
||||
events::{
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
StateEventType,
|
||||
},
|
||||
EventId, OwnedEventId, UserId,
|
||||
events::{
|
||||
StateEventType,
|
||||
room::member::{MembershipState, RoomMemberEventContent},
|
||||
},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::rooms::{
|
||||
short::{ShortEventId, ShortStateHash, ShortStateKey},
|
||||
state_compressor::{compress_state_event, parse_compressed_state_event, CompressedState},
|
||||
state_compressor::{CompressedState, compress_state_event, parse_compressed_state_event},
|
||||
};
|
||||
|
||||
/// The user was a joined member at this state (potentially in the past)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use conduwuit::{error, implement, pdu::PduBuilder, Err, Error, Result};
|
||||
use conduwuit::{Err, Error, Result, error, implement, pdu::PduBuilder};
|
||||
use ruma::{
|
||||
EventId, RoomId, UserId,
|
||||
events::{
|
||||
StateEventType, TimelineEventType,
|
||||
room::{
|
||||
history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
|
||||
member::{MembershipState, RoomMemberEventContent},
|
||||
power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
|
||||
},
|
||||
StateEventType, TimelineEventType,
|
||||
},
|
||||
EventId, RoomId, UserId,
|
||||
};
|
||||
|
||||
use crate::rooms::state::RoomMutexGuard;
|
||||
|
@ -44,7 +44,7 @@ pub async fn user_can_redact(
|
|||
)));
|
||||
}
|
||||
|
||||
if let Ok(pl_event_content) = self
|
||||
match self
|
||||
.room_state_get_content::<RoomPowerLevelsEventContent>(
|
||||
room_id,
|
||||
&StateEventType::RoomPowerLevels,
|
||||
|
@ -52,33 +52,35 @@ pub async fn user_can_redact(
|
|||
)
|
||||
.await
|
||||
{
|
||||
let pl_event: RoomPowerLevels = pl_event_content.into();
|
||||
Ok(pl_event.user_can_redact_event_of_other(sender)
|
||||
|| pl_event.user_can_redact_own_event(sender)
|
||||
&& if let Ok(redacting_event) = redacting_event {
|
||||
if federation {
|
||||
redacting_event.sender.server_name() == sender.server_name()
|
||||
} else {
|
||||
redacting_event.sender == sender
|
||||
}
|
||||
} else {
|
||||
false
|
||||
})
|
||||
} else {
|
||||
// Falling back on m.room.create to judge power level
|
||||
if let Ok(room_create) = self
|
||||
.room_state_get(room_id, &StateEventType::RoomCreate, "")
|
||||
.await
|
||||
{
|
||||
Ok(room_create.sender == sender
|
||||
|| redacting_event
|
||||
.as_ref()
|
||||
.is_ok_and(|redacting_event| redacting_event.sender == sender))
|
||||
} else {
|
||||
Err(Error::bad_database(
|
||||
"No m.room.power_levels or m.room.create events in database for room",
|
||||
))
|
||||
}
|
||||
| Ok(pl_event_content) => {
|
||||
let pl_event: RoomPowerLevels = pl_event_content.into();
|
||||
Ok(pl_event.user_can_redact_event_of_other(sender)
|
||||
|| pl_event.user_can_redact_own_event(sender)
|
||||
&& match redacting_event {
|
||||
| Ok(redacting_event) =>
|
||||
if federation {
|
||||
redacting_event.sender.server_name() == sender.server_name()
|
||||
} else {
|
||||
redacting_event.sender == sender
|
||||
},
|
||||
| _ => false,
|
||||
})
|
||||
},
|
||||
| _ => {
|
||||
// Falling back on m.room.create to judge power level
|
||||
match self
|
||||
.room_state_get(room_id, &StateEventType::RoomCreate, "")
|
||||
.await
|
||||
{
|
||||
| Ok(room_create) => Ok(room_create.sender == sender
|
||||
|| redacting_event
|
||||
.as_ref()
|
||||
.is_ok_and(|redacting_event| redacting_event.sender == sender)),
|
||||
| _ => Err(Error::bad_database(
|
||||
"No m.room.power_levels or m.room.create events in database for room",
|
||||
)),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,31 +4,31 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
is_not_empty,
|
||||
Result, is_not_empty,
|
||||
result::LogErr,
|
||||
utils::{stream::TryIgnore, ReadyExt, StreamTools},
|
||||
warn, Result,
|
||||
utils::{ReadyExt, StreamTools, stream::TryIgnore},
|
||||
warn,
|
||||
};
|
||||
use database::{serialize_key, Deserialized, Ignore, Interfix, Json, Map};
|
||||
use futures::{future::join5, pin_mut, stream::iter, Stream, StreamExt};
|
||||
use database::{Deserialized, Ignore, Interfix, Json, Map, serialize_key};
|
||||
use futures::{Stream, StreamExt, future::join5, pin_mut, stream::iter};
|
||||
use itertools::Itertools;
|
||||
use ruma::{
|
||||
OwnedRoomId, OwnedServerName, RoomId, ServerName, UserId,
|
||||
events::{
|
||||
AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType,
|
||||
RoomAccountDataEventType, StateEventType,
|
||||
direct::DirectEvent,
|
||||
room::{
|
||||
create::RoomCreateEventContent,
|
||||
member::{MembershipState, RoomMemberEventContent},
|
||||
power_levels::RoomPowerLevelsEventContent,
|
||||
},
|
||||
AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType,
|
||||
RoomAccountDataEventType, StateEventType,
|
||||
},
|
||||
int,
|
||||
serde::Raw,
|
||||
OwnedRoomId, OwnedServerName, RoomId, ServerName, UserId,
|
||||
};
|
||||
|
||||
use crate::{account_data, appservice::RegistrationInfo, globals, rooms, users, Dep};
|
||||
use crate::{Dep, account_data, appservice::RegistrationInfo, globals, rooms, users};
|
||||
|
||||
pub struct Service {
|
||||
appservice_in_room_cache: AppServiceInRoomCache,
|
||||
|
|
|
@ -6,10 +6,10 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
Result,
|
||||
arrayvec::ArrayVec,
|
||||
at, checked, err, expected, utils,
|
||||
utils::{bytes, math::usize_from_f64, stream::IterStream},
|
||||
Result,
|
||||
};
|
||||
use database::Map;
|
||||
use futures::{Stream, StreamExt};
|
||||
|
@ -17,9 +17,8 @@ use lru_cache::LruCache;
|
|||
use ruma::{EventId, RoomId};
|
||||
|
||||
use crate::{
|
||||
rooms,
|
||||
Dep, rooms,
|
||||
rooms::short::{ShortEventId, ShortId, ShortStateHash, ShortStateKey},
|
||||
Dep,
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
err,
|
||||
PduCount, PduEvent, PduId, RawPduId, Result, err,
|
||||
utils::{
|
||||
stream::{TryIgnore, WidebandExt},
|
||||
ReadyExt,
|
||||
stream::{TryIgnore, WidebandExt},
|
||||
},
|
||||
PduCount, PduEvent, PduId, RawPduId, Result,
|
||||
};
|
||||
use database::{Deserialized, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{
|
||||
api::client::threads::get_threads::v1::IncludeThreads, events::relation::BundledThread, uint,
|
||||
CanonicalJsonValue, EventId, OwnedUserId, RoomId, UserId,
|
||||
api::client::threads::get_threads::v1::IncludeThreads, events::relation::BundledThread, uint,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{rooms, rooms::short::ShortRoomId, Dep};
|
||||
use crate::{Dep, rooms, rooms::short::ShortRoomId};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
@ -121,10 +120,13 @@ impl Service {
|
|||
}
|
||||
|
||||
let mut users = Vec::new();
|
||||
if let Ok(userids) = self.get_participants(&root_id).await {
|
||||
users.extend_from_slice(&userids);
|
||||
} else {
|
||||
users.push(root_pdu.sender);
|
||||
match self.get_participants(&root_id).await {
|
||||
| Ok(userids) => {
|
||||
users.extend_from_slice(&userids);
|
||||
},
|
||||
| _ => {
|
||||
users.push(root_pdu.sender);
|
||||
},
|
||||
}
|
||||
users.push(pdu.sender.clone());
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
use std::{borrow::Borrow, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
at, err,
|
||||
Err, PduCount, PduEvent, Result, at, err,
|
||||
result::{LogErr, NotFound},
|
||||
utils,
|
||||
utils::stream::TryReadyExt,
|
||||
Err, PduCount, PduEvent, Result,
|
||||
};
|
||||
use database::{Database, Deserialized, Json, KeyVal, Map};
|
||||
use futures::{future::select_ok, pin_mut, FutureExt, Stream, TryFutureExt, TryStreamExt};
|
||||
use ruma::{api::Direction, CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId};
|
||||
use futures::{FutureExt, Stream, TryFutureExt, TryStreamExt, future::select_ok, pin_mut};
|
||||
use ruma::{CanonicalJsonObject, EventId, OwnedUserId, RoomId, UserId, api::Direction};
|
||||
|
||||
use super::{PduId, RawPduId};
|
||||
use crate::{rooms, rooms::short::ShortRoomId, Dep};
|
||||
use crate::{Dep, rooms, rooms::short::ShortRoomId};
|
||||
|
||||
pub(super) struct Data {
|
||||
eventid_outlierpdu: Arc<Map>,
|
||||
|
|
|
@ -10,22 +10,25 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
at, debug, debug_warn, err, error, implement, info,
|
||||
pdu::{gen_event_id, EventHash, PduBuilder, PduCount, PduEvent},
|
||||
Err, Error, Result, Server, at, debug, debug_warn, err, error, implement, info,
|
||||
pdu::{EventHash, PduBuilder, PduCount, PduEvent, gen_event_id},
|
||||
state_res::{self, Event, RoomVersion},
|
||||
utils::{
|
||||
self, future::TryExtExt, stream::TryIgnore, IterStream, MutexMap, MutexMapGuard, ReadyExt,
|
||||
self, IterStream, MutexMap, MutexMapGuard, ReadyExt, future::TryExtExt, stream::TryIgnore,
|
||||
},
|
||||
validated, warn, Err, Error, Result, Server,
|
||||
validated, warn,
|
||||
};
|
||||
pub use conduwuit::{PduId, RawPduId};
|
||||
use futures::{
|
||||
future, future::ready, pin_mut, Future, FutureExt, Stream, StreamExt, TryStreamExt,
|
||||
Future, FutureExt, Stream, StreamExt, TryStreamExt, future, future::ready, pin_mut,
|
||||
};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId, OwnedServerName,
|
||||
RoomId, RoomVersionId, ServerName, UserId,
|
||||
api::federation,
|
||||
canonical_json::to_canonical_value,
|
||||
events::{
|
||||
GlobalAccountDataEventType, StateEventType, TimelineEventType,
|
||||
push_rules::PushRulesEvent,
|
||||
room::{
|
||||
create::RoomCreateEventContent,
|
||||
|
@ -34,23 +37,21 @@ use ruma::{
|
|||
power_levels::RoomPowerLevelsEventContent,
|
||||
redaction::RoomRedactionEventContent,
|
||||
},
|
||||
GlobalAccountDataEventType, StateEventType, TimelineEventType,
|
||||
},
|
||||
push::{Action, Ruleset, Tweak},
|
||||
uint, CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, OwnedRoomId,
|
||||
OwnedServerName, RoomId, RoomVersionId, ServerName, UserId,
|
||||
uint,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
||||
use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
|
||||
|
||||
use self::data::Data;
|
||||
pub use self::data::PdusIterItem;
|
||||
use crate::{
|
||||
account_data, admin, appservice,
|
||||
Dep, account_data, admin, appservice,
|
||||
appservice::NamespaceRegex,
|
||||
globals, pusher, rooms,
|
||||
rooms::{short::ShortRoomId, state_compressor::CompressedState},
|
||||
sending, server_keys, users, Dep,
|
||||
sending, server_keys, users,
|
||||
};
|
||||
|
||||
// Update Relationships
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
debug_info, trace,
|
||||
Result, Server, debug_info, trace,
|
||||
utils::{self, IterStream},
|
||||
Result, Server,
|
||||
};
|
||||
use futures::StreamExt;
|
||||
use ruma::{
|
||||
OwnedRoomId, OwnedUserId, RoomId, UserId,
|
||||
api::federation::transactions::edu::{Edu, TypingContent},
|
||||
events::SyncEphemeralRoomEvent,
|
||||
OwnedRoomId, OwnedUserId, RoomId, UserId,
|
||||
};
|
||||
use tokio::sync::{broadcast, RwLock};
|
||||
use tokio::sync::{RwLock, broadcast};
|
||||
|
||||
use crate::{globals, sending, sending::EduBuf, users, Dep};
|
||||
use crate::{Dep, globals, sending, sending::EduBuf, users};
|
||||
|
||||
pub struct Service {
|
||||
server: Arc<Server>,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{implement, Result};
|
||||
use conduwuit::{Result, implement};
|
||||
use database::{Database, Deserialized, Map};
|
||||
use ruma::{RoomId, UserId};
|
||||
|
||||
use crate::{globals, rooms, rooms::short::ShortStateHash, Dep};
|
||||
use crate::{Dep, globals, rooms, rooms::short::ShortStateHash};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::{fmt::Debug, mem};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use conduwuit::{debug_error, err, trace, utils, warn, Err, Result};
|
||||
use conduwuit::{Err, Result, debug_error, err, trace, utils, warn};
|
||||
use reqwest::Client;
|
||||
use ruma::api::{
|
||||
appservice::Registration, IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken,
|
||||
IncomingResponse, MatrixVersion, OutgoingRequest, SendAccessToken, appservice::Registration,
|
||||
};
|
||||
|
||||
/// Sends a request to an appservice
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
at, utils,
|
||||
utils::{stream::TryIgnore, ReadyExt},
|
||||
Error, Result,
|
||||
Error, Result, at, utils,
|
||||
utils::{ReadyExt, stream::TryIgnore},
|
||||
};
|
||||
use database::{Database, Deserialized, Map};
|
||||
use futures::{Stream, StreamExt};
|
||||
use ruma::{OwnedServerName, ServerName, UserId};
|
||||
|
||||
use super::{Destination, SendingEvent};
|
||||
use crate::{globals, Dep};
|
||||
use crate::{Dep, globals};
|
||||
|
||||
pub(super) type OutgoingItem = (Key, SendingEvent, Destination);
|
||||
pub(super) type SendingItem = (Key, SendingEvent);
|
||||
|
@ -102,7 +101,7 @@ impl Data {
|
|||
pub fn active_requests_for(
|
||||
&self,
|
||||
destination: &Destination,
|
||||
) -> impl Stream<Item = SendingItem> + Send + '_ {
|
||||
) -> impl Stream<Item = SendingItem> + Send + '_ + use<'_> {
|
||||
let prefix = destination.get_prefix();
|
||||
self.servercurrentevent_data
|
||||
.raw_stream_from(&prefix)
|
||||
|
@ -156,7 +155,7 @@ impl Data {
|
|||
pub fn queued_requests(
|
||||
&self,
|
||||
destination: &Destination,
|
||||
) -> impl Stream<Item = QueueItem> + Send + '_ {
|
||||
) -> impl Stream<Item = QueueItem> + Send + '_ + use<'_> {
|
||||
let prefix = destination.get_prefix();
|
||||
self.servernameevent_data
|
||||
.raw_stream_from(&prefix)
|
||||
|
|
|
@ -12,15 +12,15 @@ use std::{
|
|||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{
|
||||
debug, debug_warn, err, error,
|
||||
Result, Server, debug, debug_warn, err, error,
|
||||
smallvec::SmallVec,
|
||||
utils::{available_parallelism, math::usize_from_u64_truncated, ReadyExt, TryReadyExt},
|
||||
warn, Result, Server,
|
||||
utils::{ReadyExt, TryReadyExt, available_parallelism, math::usize_from_u64_truncated},
|
||||
warn,
|
||||
};
|
||||
use futures::{FutureExt, Stream, StreamExt};
|
||||
use ruma::{
|
||||
api::{appservice::Registration, OutgoingRequest},
|
||||
RoomId, ServerName, UserId,
|
||||
api::{OutgoingRequest, appservice::Registration},
|
||||
};
|
||||
use tokio::{task, task::JoinSet};
|
||||
|
||||
|
@ -30,8 +30,8 @@ pub use self::{
|
|||
sender::{EDU_LIMIT, PDU_LIMIT},
|
||||
};
|
||||
use crate::{
|
||||
account_data, client, federation, globals, presence, pusher, rooms,
|
||||
rooms::timeline::RawPduId, users, Dep,
|
||||
Dep, account_data, client, federation, globals, presence, pusher, rooms,
|
||||
rooms::timeline::RawPduId, users,
|
||||
};
|
||||
|
||||
pub struct Service {
|
||||
|
|
|
@ -2,32 +2,33 @@ use std::{
|
|||
collections::{BTreeMap, HashMap, HashSet},
|
||||
fmt::Debug,
|
||||
sync::{
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicU64, AtomicUsize, Ordering},
|
||||
},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _};
|
||||
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||
use conduwuit::{
|
||||
debug, err, error,
|
||||
Error, Result, debug, err, error,
|
||||
result::LogErr,
|
||||
trace,
|
||||
utils::{
|
||||
calculate_hash, continue_exponential_backoff_secs,
|
||||
ReadyExt, calculate_hash, continue_exponential_backoff_secs,
|
||||
future::TryExtExt,
|
||||
stream::{BroadbandExt, IterStream, WidebandExt},
|
||||
ReadyExt,
|
||||
},
|
||||
warn, Error, Result,
|
||||
warn,
|
||||
};
|
||||
use futures::{
|
||||
FutureExt, StreamExt,
|
||||
future::{BoxFuture, OptionFuture},
|
||||
join, pin_mut,
|
||||
stream::FuturesUnordered,
|
||||
FutureExt, StreamExt,
|
||||
};
|
||||
use ruma::{
|
||||
CanonicalJsonObject, MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedServerName, OwnedUserId,
|
||||
RoomId, RoomVersionId, ServerName, UInt,
|
||||
api::{
|
||||
appservice::event::push_events::v1::EphemeralData,
|
||||
federation::transactions::{
|
||||
|
@ -40,18 +41,17 @@ use ruma::{
|
|||
},
|
||||
device_id,
|
||||
events::{
|
||||
push_rules::PushRulesEvent, receipt::ReceiptType, AnySyncEphemeralRoomEvent,
|
||||
GlobalAccountDataEventType,
|
||||
AnySyncEphemeralRoomEvent, GlobalAccountDataEventType, push_rules::PushRulesEvent,
|
||||
receipt::ReceiptType,
|
||||
},
|
||||
push,
|
||||
serde::Raw,
|
||||
uint, CanonicalJsonObject, MilliSecondsSinceUnixEpoch, OwnedRoomId, OwnedServerName,
|
||||
OwnedUserId, RoomId, RoomVersionId, ServerName, UInt,
|
||||
uint,
|
||||
};
|
||||
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
|
||||
use serde_json::value::{RawValue as RawJsonValue, to_raw_value};
|
||||
|
||||
use super::{
|
||||
appservice, data::QueueItem, Destination, EduBuf, EduVec, Msg, SendingEvent, Service,
|
||||
Destination, EduBuf, EduVec, Msg, SendingEvent, Service, appservice, data::QueueItem,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -146,7 +146,7 @@ impl Service {
|
|||
statuses.entry(dest).and_modify(|e| {
|
||||
*e = match e {
|
||||
| TransactionStatus::Running => TransactionStatus::Failed(1, Instant::now()),
|
||||
| TransactionStatus::Retrying(ref n) =>
|
||||
| &mut TransactionStatus::Retrying(ref n) =>
|
||||
TransactionStatus::Failed(n.saturating_add(1), Instant::now()),
|
||||
| TransactionStatus::Failed(..) => {
|
||||
panic!("Request that was not even running failed?!")
|
||||
|
@ -211,7 +211,7 @@ impl Service {
|
|||
async fn finish_responses<'a>(&'a self, futures: &mut SendingFutures<'a>) {
|
||||
use tokio::{
|
||||
select,
|
||||
time::{sleep_until, Instant},
|
||||
time::{Instant, sleep_until},
|
||||
};
|
||||
|
||||
let timeout = self.server.config.sender_shutdown_timeout;
|
||||
|
|
|
@ -7,13 +7,13 @@ use std::{
|
|||
use conduwuit::{
|
||||
debug, debug_error, debug_warn, error, implement, info, result::FlatOk, trace, warn,
|
||||
};
|
||||
use futures::{stream::FuturesUnordered, StreamExt};
|
||||
use futures::{StreamExt, stream::FuturesUnordered};
|
||||
use ruma::{
|
||||
api::federation::discovery::ServerSigningKeys, serde::Raw, CanonicalJsonObject,
|
||||
OwnedServerName, OwnedServerSigningKeyId, ServerName, ServerSigningKeyId,
|
||||
CanonicalJsonObject, OwnedServerName, OwnedServerSigningKeyId, ServerName,
|
||||
ServerSigningKeyId, api::federation::discovery::ServerSigningKeys, serde::Raw,
|
||||
};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
use tokio::time::{timeout_at, Instant};
|
||||
use tokio::time::{Instant, timeout_at};
|
||||
|
||||
use super::key_exists;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::borrow::Borrow;
|
||||
|
||||
use conduwuit::{implement, Err, Result};
|
||||
use conduwuit::{Err, Result, implement};
|
||||
use ruma::{
|
||||
api::federation::discovery::VerifyKey, CanonicalJsonObject, RoomVersionId, ServerName,
|
||||
ServerSigningKeyId,
|
||||
CanonicalJsonObject, RoomVersionId, ServerName, ServerSigningKeyId,
|
||||
api::federation::discovery::VerifyKey,
|
||||
};
|
||||
|
||||
use super::{extract_key, PubKeyMap, PubKeys};
|
||||
use super::{PubKeyMap, PubKeys, extract_key};
|
||||
|
||||
#[implement(super::Service)]
|
||||
pub async fn get_event_keys(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{debug, debug_info, err, error, utils, utils::string_from_bytes, Result};
|
||||
use conduwuit::{Result, debug, debug_info, err, error, utils, utils::string_from_bytes};
|
||||
use database::Database;
|
||||
use ruma::{api::federation::discovery::VerifyKey, serde::Base64, signatures::Ed25519KeyPair};
|
||||
|
||||
|
|
|
@ -8,22 +8,21 @@ mod verify;
|
|||
use std::{collections::BTreeMap, sync::Arc, time::Duration};
|
||||
|
||||
use conduwuit::{
|
||||
implement,
|
||||
utils::{timepoint_from_now, IterStream},
|
||||
Result, Server,
|
||||
Result, Server, implement,
|
||||
utils::{IterStream, timepoint_from_now},
|
||||
};
|
||||
use database::{Deserialized, Json, Map};
|
||||
use futures::StreamExt;
|
||||
use ruma::{
|
||||
CanonicalJsonObject, MilliSecondsSinceUnixEpoch, OwnedServerSigningKeyId, RoomVersionId,
|
||||
ServerName, ServerSigningKeyId,
|
||||
api::federation::discovery::{ServerSigningKeys, VerifyKey},
|
||||
serde::Raw,
|
||||
signatures::{Ed25519KeyPair, PublicKeyMap, PublicKeySet},
|
||||
CanonicalJsonObject, MilliSecondsSinceUnixEpoch, OwnedServerSigningKeyId, RoomVersionId,
|
||||
ServerName, ServerSigningKeyId,
|
||||
};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use crate::{globals, sending, Dep};
|
||||
use crate::{Dep, globals, sending};
|
||||
|
||||
pub struct Service {
|
||||
keypair: Box<Ed25519KeyPair>,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use std::{collections::BTreeMap, fmt::Debug};
|
||||
|
||||
use conduwuit::{debug, implement, Err, Result};
|
||||
use conduwuit::{Err, Result, debug, implement};
|
||||
use ruma::{
|
||||
api::federation::discovery::{
|
||||
get_remote_server_keys,
|
||||
get_remote_server_keys_batch::{self, v2::QueryCriteria},
|
||||
get_server_keys, ServerSigningKeys,
|
||||
},
|
||||
OwnedServerName, OwnedServerSigningKeyId, ServerName, ServerSigningKeyId,
|
||||
api::federation::discovery::{
|
||||
ServerSigningKeys, get_remote_server_keys,
|
||||
get_remote_server_keys_batch::{self, v2::QueryCriteria},
|
||||
get_server_keys,
|
||||
},
|
||||
};
|
||||
|
||||
#[implement(super::Service)]
|
||||
|
@ -79,7 +79,7 @@ pub async fn notary_request(
|
|||
&self,
|
||||
notary: &ServerName,
|
||||
target: &ServerName,
|
||||
) -> Result<impl Iterator<Item = ServerSigningKeys> + Clone + Debug + Send> {
|
||||
) -> Result<impl Iterator<Item = ServerSigningKeys> + Clone + Debug + Send + use<>> {
|
||||
use get_remote_server_keys::v2::Request;
|
||||
|
||||
let request = Request {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use conduwuit::{implement, Result};
|
||||
use conduwuit::{Result, implement};
|
||||
use ruma::{CanonicalJsonObject, RoomVersionId};
|
||||
|
||||
#[implement(super::Service)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use conduwuit::{implement, pdu::gen_event_id_canonical_json, Err, Result};
|
||||
use conduwuit::{Err, Result, implement, pdu::gen_event_id_canonical_json};
|
||||
use ruma::{
|
||||
signatures::Verified, CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, RoomVersionId,
|
||||
CanonicalJsonObject, CanonicalJsonValue, OwnedEventId, RoomVersionId, signatures::Verified,
|
||||
};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{err, error::inspect_log, utils::string::SplitInfallible, Err, Result, Server};
|
||||
use conduwuit::{Err, Result, Server, err, error::inspect_log, utils::string::SplitInfallible};
|
||||
use database::Database;
|
||||
|
||||
/// Abstract interface for a Service
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
use conduwuit::{debug, debug_info, info, trace, Result, Server};
|
||||
use conduwuit::{Result, Server, debug, debug_info, info, trace};
|
||||
use database::Database;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
|
|
|
@ -8,15 +8,15 @@ use std::{
|
|||
use conduwuit::{Result, Server};
|
||||
use database::Map;
|
||||
use ruma::{
|
||||
DeviceId, OwnedDeviceId, OwnedRoomId, OwnedUserId, UserId,
|
||||
api::client::sync::sync_events::{
|
||||
self,
|
||||
v4::{ExtensionsConfig, SyncRequestList},
|
||||
v5,
|
||||
},
|
||||
DeviceId, OwnedDeviceId, OwnedRoomId, OwnedUserId, UserId,
|
||||
};
|
||||
|
||||
use crate::{rooms, Dep};
|
||||
use crate::{Dep, rooms};
|
||||
|
||||
pub struct Service {
|
||||
db: Data,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use conduwuit::{implement, trace, Result};
|
||||
use futures::{pin_mut, stream::FuturesUnordered, FutureExt, StreamExt};
|
||||
use conduwuit::{Result, implement, trace};
|
||||
use futures::{FutureExt, StreamExt, pin_mut, stream::FuturesUnordered};
|
||||
use ruma::{DeviceId, UserId};
|
||||
|
||||
#[implement(super::Service)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use conduwuit::{implement, Result};
|
||||
use conduwuit::{Result, implement};
|
||||
use database::{Handle, Map};
|
||||
use ruma::{DeviceId, TransactionId, UserId};
|
||||
|
||||
|
|
|
@ -4,20 +4,19 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{
|
||||
err, error, implement, utils,
|
||||
Error, Result, err, error, implement, utils,
|
||||
utils::{hash, string::EMPTY},
|
||||
Error, Result,
|
||||
};
|
||||
use database::{Deserialized, Json, Map};
|
||||
use ruma::{
|
||||
CanonicalJsonValue, DeviceId, OwnedDeviceId, OwnedUserId, UserId,
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
uiaa::{AuthData, AuthType, Password, UiaaInfo, UserIdentifier},
|
||||
},
|
||||
CanonicalJsonValue, DeviceId, OwnedDeviceId, OwnedUserId, UserId,
|
||||
};
|
||||
|
||||
use crate::{config, globals, users, Dep};
|
||||
use crate::{Dep, config, globals, users};
|
||||
|
||||
pub struct Service {
|
||||
userdevicesessionid_uiaarequest: RwLock<RequestMap>,
|
||||
|
@ -144,8 +143,7 @@ pub async fn try_auth(
|
|||
};
|
||||
|
||||
#[cfg(not(feature = "element_hacks"))]
|
||||
let Some(UserIdentifier::UserIdOrLocalpart(username)) = identifier
|
||||
else {
|
||||
let Some(UserIdentifier::UserIdOrLocalpart(username)) = identifier else {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::Unrecognized,
|
||||
"Identifier type not recognized.",
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use conduwuit::{debug, info, warn, Result, Server};
|
||||
use conduwuit::{Result, Server, debug, info, warn};
|
||||
use database::{Deserialized, Map};
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
use serde::Deserialize;
|
||||
use tokio::{
|
||||
sync::Notify,
|
||||
time::{interval, MissedTickBehavior},
|
||||
time::{MissedTickBehavior, interval},
|
||||
};
|
||||
|
||||
use crate::{admin, client, globals, Dep};
|
||||
use crate::{Dep, admin, client, globals};
|
||||
|
||||
pub struct Service {
|
||||
interval: Duration,
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
use std::{collections::BTreeMap, mem, sync::Arc};
|
||||
|
||||
use conduwuit::{
|
||||
at, debug_warn, err, trace,
|
||||
utils::{self, stream::TryIgnore, string::Unquoted, ReadyExt},
|
||||
Err, Error, Result, Server,
|
||||
Err, Error, Result, Server, at, debug_warn, err, trace,
|
||||
utils::{self, ReadyExt, stream::TryIgnore, string::Unquoted},
|
||||
};
|
||||
use database::{Deserialized, Ignore, Interfix, Json, Map};
|
||||
use futures::{Stream, StreamExt, TryFutureExt};
|
||||
use ruma::{
|
||||
DeviceId, KeyId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyId,
|
||||
OneTimeKeyName, OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedUserId, RoomId, UInt, UserId,
|
||||
api::client::{device::Device, error::ErrorKind, filter::FilterDefinition},
|
||||
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
|
||||
events::{
|
||||
ignored_user_list::IgnoredUserListEvent, AnyToDeviceEvent, GlobalAccountDataEventType,
|
||||
AnyToDeviceEvent, GlobalAccountDataEventType, ignored_user_list::IgnoredUserListEvent,
|
||||
},
|
||||
serde::Raw,
|
||||
DeviceId, KeyId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyId,
|
||||
OneTimeKeyName, OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedUserId, RoomId, UInt, UserId,
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{account_data, admin, globals, rooms, Dep};
|
||||
use crate::{Dep, account_data, admin, globals, rooms};
|
||||
|
||||
pub struct Service {
|
||||
services: Services,
|
||||
|
@ -246,10 +245,13 @@ impl Service {
|
|||
|
||||
/// Sets a new avatar_url or removes it if avatar_url is None.
|
||||
pub fn set_avatar_url(&self, user_id: &UserId, avatar_url: Option<OwnedMxcUri>) {
|
||||
if let Some(avatar_url) = avatar_url {
|
||||
self.db.userid_avatarurl.insert(user_id, &avatar_url);
|
||||
} else {
|
||||
self.db.userid_avatarurl.remove(user_id);
|
||||
match avatar_url {
|
||||
| Some(avatar_url) => {
|
||||
self.db.userid_avatarurl.insert(user_id, &avatar_url);
|
||||
},
|
||||
| _ => {
|
||||
self.db.userid_avatarurl.remove(user_id);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue