mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 19:06:35 +03:00
Fix nightly clippy warnings
This commit is contained in:
committed by
link2xt
parent
92b304dee4
commit
332a387c98
@@ -70,10 +70,7 @@ impl ChatId {
|
||||
///
|
||||
/// This kind of chat ID can not be used for real chats.
|
||||
pub fn is_special(self) -> bool {
|
||||
match self.0 {
|
||||
0..=DC_CHAT_ID_LAST_SPECIAL => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self.0, 0..=DC_CHAT_ID_LAST_SPECIAL)
|
||||
}
|
||||
|
||||
/// Chat ID which represents the deaddrop chat.
|
||||
|
||||
@@ -1530,7 +1530,7 @@ async fn create_adhoc_grp_id(context: &Context, member_ids: &[u32]) -> String {
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap_or_else(|_| member_cs);
|
||||
.unwrap_or(member_cs);
|
||||
|
||||
hex_hash(&members)
|
||||
}
|
||||
@@ -1558,7 +1558,7 @@ async fn search_chat_ids_by_contact_ids(
|
||||
}
|
||||
}
|
||||
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()), ",");
|
||||
context.sql.query_map(
|
||||
format!(
|
||||
|
||||
@@ -476,16 +476,8 @@ impl Imap {
|
||||
// the entry has the format `imap.mailbox.<folder>=<uidvalidity>:<lastseenuid>`
|
||||
let mut parts = entry.split(':');
|
||||
(
|
||||
parts
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.parse()
|
||||
.unwrap_or_else(|_| 0),
|
||||
parts
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.parse()
|
||||
.unwrap_or_else(|_| 0),
|
||||
parts.next().unwrap_or_default().parse().unwrap_or(0),
|
||||
parts.next().unwrap_or_default().parse().unwrap_or(0),
|
||||
)
|
||||
} else {
|
||||
(0, 0)
|
||||
|
||||
@@ -222,7 +222,7 @@ async fn generate_keypair(context: &Context) -> Result<KeyPair> {
|
||||
let addr = context
|
||||
.get_config(Config::ConfiguredAddr)
|
||||
.await
|
||||
.ok_or_else(|| Error::NoConfiguredAddr)?;
|
||||
.ok_or(Error::NoConfiguredAddr)?;
|
||||
let addr = EmailAddress::new(&addr)?;
|
||||
let _guard = context.generating_key_mutex.lock().await;
|
||||
|
||||
|
||||
@@ -866,13 +866,13 @@ impl From<MessageState> for LotState {
|
||||
|
||||
impl MessageState {
|
||||
pub fn can_fail(self) -> bool {
|
||||
match self {
|
||||
matches!(
|
||||
self,
|
||||
MessageState::OutPreparing
|
||||
| MessageState::OutPending
|
||||
| MessageState::OutDelivered
|
||||
| MessageState::OutMdnRcvd => true, // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
|
||||
_ => false,
|
||||
}
|
||||
| MessageState::OutPending
|
||||
| MessageState::OutDelivered
|
||||
| MessageState::OutMdnRcvd // OutMdnRcvd can still fail because it could be a group message and only some recipients failed.
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
||||
selfstatus: context
|
||||
.get_config(Config::Selfstatus)
|
||||
.await
|
||||
.unwrap_or_else(|| default_str),
|
||||
.unwrap_or(default_str),
|
||||
recipients,
|
||||
timestamp: msg.timestamp_sort,
|
||||
loaded: Loaded::Message { chat },
|
||||
@@ -183,7 +183,7 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
||||
let selfstatus = context
|
||||
.get_config(Config::Selfstatus)
|
||||
.await
|
||||
.unwrap_or_else(|| default_str);
|
||||
.unwrap_or(default_str);
|
||||
let timestamp = dc_create_smeared_timestamp(context).await;
|
||||
|
||||
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 {
|
||||
match key {
|
||||
"return-path" | "date" | "from" | "sender" | "reply-to" | "to" | "cc" | "bcc"
|
||||
| "message-id" | "in-reply-to" | "references" | "subject" => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
key,
|
||||
"return-path"
|
||||
| "date"
|
||||
| "from"
|
||||
| "sender"
|
||||
| "reply-to"
|
||||
| "to"
|
||||
| "cc"
|
||||
| "bcc"
|
||||
| "message-id"
|
||||
| "in-reply-to"
|
||||
| "references"
|
||||
| "subject"
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
||||
@@ -305,7 +305,7 @@ impl Oauth2 {
|
||||
|
||||
let mut fqdn: String = String::from(domain.as_ref());
|
||||
if !fqdn.ends_with('.') {
|
||||
fqdn.push_str(".");
|
||||
fqdn.push('.');
|
||||
}
|
||||
|
||||
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> {
|
||||
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);
|
||||
|
||||
// should returns sth. as
|
||||
|
||||
@@ -415,10 +415,7 @@ impl Scheduler {
|
||||
|
||||
/// Check if the scheduler is running.
|
||||
pub fn is_running(&self) -> bool {
|
||||
match self {
|
||||
Scheduler::Running { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
matches!(self, Scheduler::Running { .. })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ impl Sql {
|
||||
&self,
|
||||
) -> Result<r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>> {
|
||||
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()?;
|
||||
|
||||
Ok(conn)
|
||||
@@ -156,7 +156,7 @@ impl Sql {
|
||||
+ FnOnce(r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>) -> Result<H>,
|
||||
{
|
||||
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()?;
|
||||
|
||||
g(conn)
|
||||
@@ -168,7 +168,7 @@ impl Sql {
|
||||
Fut: Future<Output = Result<H>> + Send,
|
||||
{
|
||||
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()?;
|
||||
g(conn).await
|
||||
|
||||
Reference in New Issue
Block a user