1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-27 11:04:35 +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]]
name = "conduit"
version = "0.4.0-next"
version = "0.5.0-alpha.next"
dependencies = [
"async-trait",
"axum",

View file

@ -7,7 +7,7 @@ homepage = "https://conduit.rs"
repository = "https://gitlab.com/famedly/conduit"
readme = "README.md"
version = "0.4.0-next"
rust-version = "1.63"
rust-version = "1.64"
edition = "2021"
# 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()
.media
.create(
mxc.to_string(),
mxc.to_owned(),
content_response.content_disposition.as_deref(),
content_response.content_type.as_deref(),
&content_response.file,

View file

@ -183,7 +183,7 @@ impl fmt::Display for Config {
("Turn TTL", &self.turn_ttl.to_string()),
("Turn URIs", {
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;
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() {
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();
key.push(0xff);
key.extend_from_slice(ids.pushkey.as_bytes());
return self
.senderkey_pusher
self.senderkey_pusher
.remove(&key)
.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 fn services<'a>() -> &'static Services {
pub fn services() -> &'static Services {
SERVICES
.read()
.unwrap()

View file

@ -599,7 +599,8 @@ impl Service {
}
}
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
let user_id = match UserId::parse_with_server_name(
username.as_str().to_lowercase(),
@ -732,9 +733,8 @@ impl Service {
}
for &user_id in &user_ids {
match services().users.deactivate_account(user_id) {
Ok(_) => deactivation_count += 1,
Err(_) => {}
if services().users.deactivate_account(user_id).is_ok() {
deactivation_count += 1
}
}

View file

@ -42,7 +42,7 @@ impl Service {
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)
}
@ -296,8 +296,8 @@ impl Service {
Ok(())
}
// TODO: Handle email
PusherKind::Email(_) => return Ok(()),
_ => return Ok(()),
PusherKind::Email(_) => Ok(()),
_ => Ok(()),
}
}
}

View file

@ -2,7 +2,7 @@ use crate::Result;
use ruma::RoomId;
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>(
&'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>>>;
/// Replace the forward extremities of the room.
fn set_forward_extremities<'a>(
fn set_forward_extremities(
&self,
room_id: &RoomId,
event_ids: Vec<OwnedEventId>,

View file

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

View file

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