refactor: cleanup
This commit is contained in:
parent
6786c44f4d
commit
66bc41125c
11 changed files with 20 additions and 21 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -372,7 +372,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
|||
|
||||
[[package]]
|
||||
name = "conduit"
|
||||
version = "0.4.0-next"
|
||||
version = "0.5.0-alpha.next"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"axum",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -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>,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue