cargo clippy/fix
This commit is contained in:
@@ -182,7 +182,7 @@ impl Daemon {
|
||||
// Fetch conversations from server
|
||||
let fetched_conversations = client.get_conversations().await?;
|
||||
let db_conversations: Vec<kordophone_db::models::Conversation> = fetched_conversations.into_iter()
|
||||
.map(|c| kordophone_db::models::Conversation::from(c))
|
||||
.map(kordophone_db::models::Conversation::from)
|
||||
.collect();
|
||||
|
||||
// Process each conversation
|
||||
@@ -205,7 +205,7 @@ impl Daemon {
|
||||
|
||||
let messages = client.get_messages(&conversation_id, None, None, last_message_id).await?;
|
||||
let db_messages: Vec<kordophone_db::models::Message> = messages.into_iter()
|
||||
.map(|m| kordophone_db::models::Message::from(m))
|
||||
.map(kordophone_db::models::Message::from)
|
||||
.collect();
|
||||
|
||||
// Insert each message
|
||||
@@ -221,8 +221,7 @@ impl Daemon {
|
||||
}
|
||||
|
||||
async fn get_settings(&mut self) -> Result<Settings> {
|
||||
let settings = self.database.with_settings(|s|
|
||||
Settings::from_db(s)
|
||||
let settings = self.database.with_settings(Settings::from_db
|
||||
).await?;
|
||||
|
||||
Ok(settings)
|
||||
@@ -237,8 +236,7 @@ impl Daemon {
|
||||
}
|
||||
|
||||
async fn get_client_impl(database: &mut Arc<Mutex<Database>>) -> Result<HTTPAPIClient<DatabaseTokenStore>> {
|
||||
let settings = database.with_settings(|s|
|
||||
Settings::from_db(s)
|
||||
let settings = database.with_settings(Settings::from_db
|
||||
).await?;
|
||||
|
||||
let server_url = settings.server_url
|
||||
|
||||
@@ -8,6 +8,7 @@ mod keys {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Default)]
|
||||
pub struct Settings {
|
||||
pub server_url: Option<String>,
|
||||
pub username: Option<String>,
|
||||
@@ -41,12 +42,3 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
server_url: None,
|
||||
username: None,
|
||||
credential_item: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use log::info;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
|
||||
use dbus_crossroads::Crossroads;
|
||||
use dbus_tokio::connection;
|
||||
|
||||
@@ -9,7 +9,6 @@ use crate::daemon::{
|
||||
DaemonResult,
|
||||
events::{Event, Reply},
|
||||
settings::Settings,
|
||||
signals::Signal,
|
||||
};
|
||||
|
||||
use crate::dbus::interface::NetBuzzertKordophoneRepository as DbusRepository;
|
||||
@@ -54,9 +53,11 @@ impl DbusRepository for ServerImpl {
|
||||
|
||||
fn get_conversations(&mut self) -> Result<Vec<arg::PropMap>, dbus::MethodErr> {
|
||||
self.send_event_sync(Event::GetAllConversations)
|
||||
.and_then(|conversations| {
|
||||
.map(|conversations| {
|
||||
// Convert conversations to DBus property maps
|
||||
let result = conversations.into_iter().map(|conv| {
|
||||
|
||||
|
||||
conversations.into_iter().map(|conv| {
|
||||
let mut map = arg::PropMap::new();
|
||||
map.insert("guid".into(), arg::Variant(Box::new(conv.guid)));
|
||||
map.insert("display_name".into(), arg::Variant(Box::new(conv.display_name.unwrap_or_default())));
|
||||
@@ -65,9 +66,7 @@ impl DbusRepository for ServerImpl {
|
||||
map.insert("participants".into(), arg::Variant(Box::new(conv.participants.into_iter().map(|p| p.display_name()).collect::<Vec<String>>())));
|
||||
map.insert("date".into(), arg::Variant(Box::new(conv.date.and_utc().timestamp())));
|
||||
map
|
||||
}).collect();
|
||||
|
||||
Ok(result)
|
||||
}).collect()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -83,17 +82,17 @@ impl DbusRepository for ServerImpl {
|
||||
};
|
||||
|
||||
self.send_event_sync(|r| Event::GetMessages(conversation_id, last_message_id_opt, r))
|
||||
.and_then(|messages| {
|
||||
let result = messages.into_iter().map(|msg| {
|
||||
.map(|messages| {
|
||||
|
||||
|
||||
messages.into_iter().map(|msg| {
|
||||
let mut map = arg::PropMap::new();
|
||||
map.insert("id".into(), arg::Variant(Box::new(msg.id)));
|
||||
map.insert("text".into(), arg::Variant(Box::new(msg.text)));
|
||||
map.insert("date".into(), arg::Variant(Box::new(msg.date.and_utc().timestamp())));
|
||||
map.insert("sender".into(), arg::Variant(Box::new(msg.sender.display_name())));
|
||||
map
|
||||
}).collect();
|
||||
|
||||
Ok(result)
|
||||
}).collect()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -121,9 +120,7 @@ impl DbusSettings for ServerImpl {
|
||||
|
||||
fn server_url(&self) -> Result<String, dbus::MethodErr> {
|
||||
self.send_event_sync(Event::GetAllSettings)
|
||||
.and_then(|settings| {
|
||||
Ok(settings.server_url.unwrap_or_default())
|
||||
})
|
||||
.map(|settings| settings.server_url.unwrap_or_default())
|
||||
}
|
||||
|
||||
fn set_server_url(&self, value: String) -> Result<(), dbus::MethodErr> {
|
||||
@@ -138,9 +135,7 @@ impl DbusSettings for ServerImpl {
|
||||
|
||||
fn username(&self) -> Result<String, dbus::MethodErr> {
|
||||
self.send_event_sync(Event::GetAllSettings)
|
||||
.and_then(|settings| {
|
||||
Ok(settings.username.unwrap_or_default())
|
||||
})
|
||||
.map(|settings| settings.username.unwrap_or_default())
|
||||
}
|
||||
|
||||
fn set_username(&self, value: String) -> Result<(), dbus::MethodErr> {
|
||||
@@ -155,12 +150,7 @@ impl DbusSettings for ServerImpl {
|
||||
|
||||
fn credential_item(&self) -> Result<dbus::Path<'static>, dbus::MethodErr> {
|
||||
self.send_event_sync(Event::GetAllSettings)
|
||||
.and_then(|settings| {
|
||||
Ok(settings.credential_item.unwrap_or_default())
|
||||
})
|
||||
.and_then(|item| {
|
||||
Ok(dbus::Path::new(item).unwrap_or_default())
|
||||
})
|
||||
.map(|settings| settings.credential_item.unwrap_or_default()).map(|item| dbus::Path::new(item).unwrap_or_default())
|
||||
}
|
||||
|
||||
fn set_credential_item(&self, value: dbus::Path<'static>) -> Result<(), dbus::MethodErr> {
|
||||
|
||||
Reference in New Issue
Block a user