1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-28 03:44:31 +01:00

Merge branch 'Nyaaori/cleanup' into 'next'

misc. cleanup

See merge request famedly/conduit!420
This commit is contained in:
Timo Kösters 2022-11-21 19:59:45 +00:00
commit e3dabdf525
12 changed files with 21 additions and 22 deletions

2
Cargo.lock generated
View file

@ -372,7 +372,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]] [[package]]
name = "conduit" name = "conduit"
version = "0.4.0-next" version = "0.5.0-alpha.next"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"axum", "axum",

View file

@ -7,7 +7,7 @@ homepage = "https://conduit.rs"
repository = "https://gitlab.com/famedly/conduit" repository = "https://gitlab.com/famedly/conduit"
readme = "README.md" readme = "README.md"
version = "0.4.0-next" version = "0.4.0-next"
rust-version = "1.63" rust-version = "1.64"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -74,7 +74,7 @@ pub async fn get_remote_content(
services() services()
.media .media
.create( .create(
mxc.to_string(), mxc.to_owned(),
content_response.content_disposition.as_deref(), content_response.content_disposition.as_deref(),
content_response.content_type.as_deref(), content_response.content_type.as_deref(),
&content_response.file, &content_response.file,

View file

@ -183,7 +183,7 @@ impl fmt::Display for Config {
("Turn TTL", &self.turn_ttl.to_string()), ("Turn TTL", &self.turn_ttl.to_string()),
("Turn URIs", { ("Turn URIs", {
let mut lst = vec![]; let mut lst = vec![];
for item in self.turn_uris.to_vec().into_iter().enumerate() { for item in self.turn_uris.iter().cloned().enumerate() {
let (_, uri): (usize, String) = item; let (_, uri): (usize, String) = item;
lst.push(uri); lst.push(uri);
} }
@ -191,7 +191,7 @@ impl fmt::Display for Config {
}), }),
]; ];
let mut msg: String = "Active config values:\n\n".to_string(); let mut msg: String = "Active config values:\n\n".to_owned();
for line in lines.into_iter().enumerate() { for line in lines.into_iter().enumerate() {
msg += &format!("{}: {}\n", line.1 .0, line.1 .1); msg += &format!("{}: {}\n", line.1 .0, line.1 .1);

View file

@ -22,11 +22,10 @@ impl service::pusher::Data for KeyValueDatabase {
let mut key = sender.as_bytes().to_vec(); let mut key = sender.as_bytes().to_vec();
key.push(0xff); key.push(0xff);
key.extend_from_slice(ids.pushkey.as_bytes()); key.extend_from_slice(ids.pushkey.as_bytes());
return self self.senderkey_pusher
.senderkey_pusher
.remove(&key) .remove(&key)
.map(|_| ()) .map(|_| ())
.map_err(Into::into); .map_err(Into::into)
} }
} }
} }

View file

@ -23,7 +23,7 @@ pub use utils::error::{Error, Result};
pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None); pub static SERVICES: RwLock<Option<&'static Services>> = RwLock::new(None);
pub fn services<'a>() -> &'static Services { pub fn services() -> &'static Services {
SERVICES SERVICES
.read() .read()
.unwrap() .unwrap()

View file

@ -599,7 +599,8 @@ impl Service {
} }
} }
AdminCommand::CreateUser { username, password } => { AdminCommand::CreateUser { username, password } => {
let password = password.unwrap_or(utils::random_string(AUTO_GEN_PASSWORD_LENGTH)); let password =
password.unwrap_or_else(|| utils::random_string(AUTO_GEN_PASSWORD_LENGTH));
// Validate user id // Validate user id
let user_id = match UserId::parse_with_server_name( let user_id = match UserId::parse_with_server_name(
username.as_str().to_lowercase(), username.as_str().to_lowercase(),
@ -732,9 +733,8 @@ impl Service {
} }
for &user_id in &user_ids { for &user_id in &user_ids {
match services().users.deactivate_account(user_id) { if services().users.deactivate_account(user_id).is_ok() {
Ok(_) => deactivation_count += 1, deactivation_count += 1
Err(_) => {}
} }
} }

View file

@ -42,7 +42,7 @@ impl Service {
self.db.get_pushers(sender) self.db.get_pushers(sender)
} }
pub fn get_pushkeys<'a>(&'a self, sender: &UserId) -> Box<dyn Iterator<Item = Result<String>>> { pub fn get_pushkeys(&self, sender: &UserId) -> Box<dyn Iterator<Item = Result<String>>> {
self.db.get_pushkeys(sender) self.db.get_pushkeys(sender)
} }
@ -296,8 +296,8 @@ impl Service {
Ok(()) Ok(())
} }
// TODO: Handle email // TODO: Handle email
PusherKind::Email(_) => return Ok(()), PusherKind::Email(_) => Ok(()),
_ => return Ok(()), _ => Ok(()),
} }
} }
} }

View file

@ -2,7 +2,7 @@ use crate::Result;
use ruma::RoomId; use ruma::RoomId;
pub trait Data: Send + Sync { pub trait Data: Send + Sync {
fn index_pdu<'a>(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()>; fn index_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()>;
fn search_pdus<'a>( fn search_pdus<'a>(
&'a self, &'a self,

View file

@ -22,7 +22,7 @@ pub trait Data: Send + Sync {
fn get_forward_extremities(&self, room_id: &RoomId) -> Result<HashSet<Arc<EventId>>>; fn get_forward_extremities(&self, room_id: &RoomId) -> Result<HashSet<Arc<EventId>>>;
/// Replace the forward extremities of the room. /// Replace the forward extremities of the room.
fn set_forward_extremities<'a>( fn set_forward_extremities(
&self, &self,
room_id: &RoomId, room_id: &RoomId,
event_ids: Vec<OwnedEventId>, event_ids: Vec<OwnedEventId>,

View file

@ -343,7 +343,7 @@ impl Service {
self.db.get_forward_extremities(room_id) self.db.get_forward_extremities(room_id)
} }
pub fn set_forward_extremities<'a>( pub fn set_forward_extremities(
&self, &self,
room_id: &RoomId, room_id: &RoomId,
event_ids: Vec<OwnedEventId>, event_ids: Vec<OwnedEventId>,

View file

@ -40,10 +40,10 @@ impl Service {
self.db.get_token_shortstatehash(room_id, token) self.db.get_token_shortstatehash(room_id, token)
} }
pub fn get_shared_rooms<'a>( pub fn get_shared_rooms(
&'a self, &self,
users: Vec<OwnedUserId>, users: Vec<OwnedUserId>,
) -> Result<impl Iterator<Item = Result<OwnedRoomId>> + 'a> { ) -> Result<impl Iterator<Item = Result<OwnedRoomId>>> {
self.db.get_shared_rooms(users) self.db.get_shared_rooms(users)
} }
} }