mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
Fix nightly clippy warnings
This commit is contained in:
committed by
link2xt
parent
92b304dee4
commit
332a387c98
@@ -3438,7 +3438,7 @@ pub unsafe extern "C" fn dc_accounts_select_account(
|
|||||||
let accounts = &*accounts;
|
let accounts = &*accounts;
|
||||||
block_on(accounts.select_account(id))
|
block_on(accounts.select_account(id))
|
||||||
.map(|_| 1)
|
.map(|_| 1)
|
||||||
.unwrap_or_else(|_| 0)
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@@ -3450,7 +3450,7 @@ pub unsafe extern "C" fn dc_accounts_add_account(accounts: *mut dc_accounts_t) -
|
|||||||
|
|
||||||
let accounts = &*accounts;
|
let accounts = &*accounts;
|
||||||
|
|
||||||
block_on(accounts.add_account()).unwrap_or_else(|_| 0)
|
block_on(accounts.add_account()).unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|||||||
@@ -70,10 +70,7 @@ impl ChatId {
|
|||||||
///
|
///
|
||||||
/// This kind of chat ID can not be used for real chats.
|
/// This kind of chat ID can not be used for real chats.
|
||||||
pub fn is_special(self) -> bool {
|
pub fn is_special(self) -> bool {
|
||||||
match self.0 {
|
matches!(self.0, 0..=DC_CHAT_ID_LAST_SPECIAL)
|
||||||
0..=DC_CHAT_ID_LAST_SPECIAL => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Chat ID which represents the deaddrop chat.
|
/// Chat ID which represents the deaddrop chat.
|
||||||
|
|||||||
@@ -1530,7 +1530,7 @@ async fn create_adhoc_grp_id(context: &Context, member_ids: &[u32]) -> String {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|_| member_cs);
|
.unwrap_or(member_cs);
|
||||||
|
|
||||||
hex_hash(&members)
|
hex_hash(&members)
|
||||||
}
|
}
|
||||||
@@ -1558,7 +1558,7 @@ async fn search_chat_ids_by_contact_ids(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !contact_ids.is_empty() {
|
if !contact_ids.is_empty() {
|
||||||
contact_ids.sort();
|
contact_ids.sort_unstable();
|
||||||
let contact_ids_str = join(contact_ids.iter().map(|x| x.to_string()), ",");
|
let contact_ids_str = join(contact_ids.iter().map(|x| x.to_string()), ",");
|
||||||
context.sql.query_map(
|
context.sql.query_map(
|
||||||
format!(
|
format!(
|
||||||
|
|||||||
@@ -476,16 +476,8 @@ impl Imap {
|
|||||||
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
||||||
let mut parts = entry.split(':');
|
let mut parts = entry.split(':');
|
||||||
(
|
(
|
||||||
parts
|
parts.next().unwrap_or_default().parse().unwrap_or(0),
|
||||||
.next()
|
parts.next().unwrap_or_default().parse().unwrap_or(0),
|
||||||
.unwrap_or_default()
|
|
||||||
.parse()
|
|
||||||
.unwrap_or_else(|_| 0),
|
|
||||||
parts
|
|
||||||
.next()
|
|
||||||
.unwrap_or_default()
|
|
||||||
.parse()
|
|
||||||
.unwrap_or_else(|_| 0),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(0, 0)
|
(0, 0)
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ async fn generate_keypair(context: &Context) -> Result<KeyPair> {
|
|||||||
let addr = context
|
let addr = context
|
||||||
.get_config(Config::ConfiguredAddr)
|
.get_config(Config::ConfiguredAddr)
|
||||||
.await
|
.await
|
||||||
.ok_or_else(|| Error::NoConfiguredAddr)?;
|
.ok_or(Error::NoConfiguredAddr)?;
|
||||||
let addr = EmailAddress::new(&addr)?;
|
let addr = EmailAddress::new(&addr)?;
|
||||||
let _guard = context.generating_key_mutex.lock().await;
|
let _guard = context.generating_key_mutex.lock().await;
|
||||||
|
|
||||||
|
|||||||
@@ -866,13 +866,13 @@ impl From<MessageState> for LotState {
|
|||||||
|
|
||||||
impl MessageState {
|
impl MessageState {
|
||||||
pub fn can_fail(self) -> bool {
|
pub fn can_fail(self) -> bool {
|
||||||
match self {
|
matches!(
|
||||||
|
self,
|
||||||
MessageState::OutPreparing
|
MessageState::OutPreparing
|
||||||
| MessageState::OutPending
|
| MessageState::OutPending
|
||||||
| MessageState::OutDelivered
|
| MessageState::OutDelivered
|
||||||
| MessageState::OutMdnRcvd => true, // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
|
| MessageState::OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
|
||||||
_ => false,
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
|||||||
selfstatus: context
|
selfstatus: context
|
||||||
.get_config(Config::Selfstatus)
|
.get_config(Config::Selfstatus)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|| default_str),
|
.unwrap_or(default_str),
|
||||||
recipients,
|
recipients,
|
||||||
timestamp: msg.timestamp_sort,
|
timestamp: msg.timestamp_sort,
|
||||||
loaded: Loaded::Message { chat },
|
loaded: Loaded::Message { chat },
|
||||||
@@ -183,7 +183,7 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
|||||||
let selfstatus = context
|
let selfstatus = context
|
||||||
.get_config(Config::Selfstatus)
|
.get_config(Config::Selfstatus)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|| default_str);
|
.unwrap_or(default_str);
|
||||||
let timestamp = dc_create_smeared_timestamp(context).await;
|
let timestamp = dc_create_smeared_timestamp(context).await;
|
||||||
|
|
||||||
let res = MimeFactory::<'a, 'b> {
|
let res = MimeFactory::<'a, 'b> {
|
||||||
|
|||||||
@@ -1153,11 +1153,21 @@ pub(crate) fn parse_message_id(ids: &str) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_known(key: &str) -> bool {
|
fn is_known(key: &str) -> bool {
|
||||||
match key {
|
matches!(
|
||||||
"return-path" | "date" | "from" | "sender" | "reply-to" | "to" | "cc" | "bcc"
|
key,
|
||||||
| "message-id" | "in-reply-to" | "references" | "subject" => true,
|
"return-path"
|
||||||
_ => false,
|
| "date"
|
||||||
}
|
| "from"
|
||||||
|
| "sender"
|
||||||
|
| "reply-to"
|
||||||
|
| "to"
|
||||||
|
| "cc"
|
||||||
|
| "bcc"
|
||||||
|
| "message-id"
|
||||||
|
| "in-reply-to"
|
||||||
|
| "references"
|
||||||
|
| "subject"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ impl Oauth2 {
|
|||||||
|
|
||||||
let mut fqdn: String = String::from(domain.as_ref());
|
let mut fqdn: String = String::from(domain.as_ref());
|
||||||
if !fqdn.ends_with('.') {
|
if !fqdn.ends_with('.') {
|
||||||
fqdn.push_str(".");
|
fqdn.push('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(res) = resolver.mx_lookup(fqdn).await {
|
if let Ok(res) = resolver.mx_lookup(fqdn).await {
|
||||||
@@ -323,7 +323,7 @@ impl Oauth2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_addr(&self, context: &Context, access_token: impl AsRef<str>) -> Option<String> {
|
async fn get_addr(&self, context: &Context, access_token: impl AsRef<str>) -> Option<String> {
|
||||||
let userinfo_url = self.get_userinfo.unwrap_or_else(|| "");
|
let userinfo_url = self.get_userinfo.unwrap_or("");
|
||||||
let userinfo_url = replace_in_uri(&userinfo_url, "$ACCESS_TOKEN", access_token);
|
let userinfo_url = replace_in_uri(&userinfo_url, "$ACCESS_TOKEN", access_token);
|
||||||
|
|
||||||
// should returns sth. as
|
// should returns sth. as
|
||||||
|
|||||||
@@ -415,10 +415,7 @@ impl Scheduler {
|
|||||||
|
|
||||||
/// Check if the scheduler is running.
|
/// Check if the scheduler is running.
|
||||||
pub fn is_running(&self) -> bool {
|
pub fn is_running(&self) -> bool {
|
||||||
match self {
|
matches!(self, Scheduler::Running { .. })
|
||||||
Scheduler::Running { .. } => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ impl Sql {
|
|||||||
&self,
|
&self,
|
||||||
) -> Result<r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>> {
|
) -> Result<r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>> {
|
||||||
let lock = self.pool.read().await;
|
let lock = self.pool.read().await;
|
||||||
let pool = lock.as_ref().ok_or_else(|| Error::SqlNoConnection)?;
|
let pool = lock.as_ref().ok_or(Error::SqlNoConnection)?;
|
||||||
let conn = pool.get()?;
|
let conn = pool.get()?;
|
||||||
|
|
||||||
Ok(conn)
|
Ok(conn)
|
||||||
@@ -156,7 +156,7 @@ impl Sql {
|
|||||||
+ FnOnce(r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>) -> Result<H>,
|
+ FnOnce(r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>) -> Result<H>,
|
||||||
{
|
{
|
||||||
let lock = self.pool.read().await;
|
let lock = self.pool.read().await;
|
||||||
let pool = lock.as_ref().ok_or_else(|| Error::SqlNoConnection)?;
|
let pool = lock.as_ref().ok_or(Error::SqlNoConnection)?;
|
||||||
let conn = pool.get()?;
|
let conn = pool.get()?;
|
||||||
|
|
||||||
g(conn)
|
g(conn)
|
||||||
@@ -168,7 +168,7 @@ impl Sql {
|
|||||||
Fut: Future<Output = Result<H>> + Send,
|
Fut: Future<Output = Result<H>> + Send,
|
||||||
{
|
{
|
||||||
let lock = self.pool.read().await;
|
let lock = self.pool.read().await;
|
||||||
let pool = lock.as_ref().ok_or_else(|| Error::SqlNoConnection)?;
|
let pool = lock.as_ref().ok_or(Error::SqlNoConnection)?;
|
||||||
|
|
||||||
let conn = pool.get()?;
|
let conn = pool.get()?;
|
||||||
g(conn).await
|
g(conn).await
|
||||||
|
|||||||
Reference in New Issue
Block a user