mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
chore: fix clippy warnings
This commit is contained in:
@@ -246,8 +246,7 @@ async fn test_sync() -> Result<()> {
|
|||||||
alice1
|
alice1
|
||||||
.get_config(Config::Selfavatar)
|
.get_config(Config::Selfavatar)
|
||||||
.await?
|
.await?
|
||||||
.filter(|path| path.ends_with(".png"))
|
.is_some_and(|path| path.ends_with(".png"))
|
||||||
.is_some()
|
|
||||||
);
|
);
|
||||||
alice0.set_config(Config::Selfavatar, None).await?;
|
alice0.set_config(Config::Selfavatar, None).await?;
|
||||||
sync(&alice0, &alice1).await;
|
sync(&alice0, &alice1).await;
|
||||||
@@ -305,16 +304,14 @@ async fn test_no_sync_on_self_sent_msg() -> Result<()> {
|
|||||||
alice1
|
alice1
|
||||||
.get_config(Config::Selfavatar)
|
.get_config(Config::Selfavatar)
|
||||||
.await?
|
.await?
|
||||||
.filter(|path| path.ends_with(".jpg"))
|
.is_some_and(|path| path.ends_with(".jpg"))
|
||||||
.is_some()
|
|
||||||
);
|
);
|
||||||
sync(alice1, alice0).await;
|
sync(alice1, alice0).await;
|
||||||
assert!(
|
assert!(
|
||||||
alice0
|
alice0
|
||||||
.get_config(Config::Selfavatar)
|
.get_config(Config::Selfavatar)
|
||||||
.await?
|
.await?
|
||||||
.filter(|path| path.ends_with(".jpg"))
|
.is_some_and(|path| path.ends_with(".jpg"))
|
||||||
.is_some()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -266,15 +266,11 @@ fn dehtml_endtag_cb(event: &BytesEnd, dehtml: &mut Dehtml) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"b" | "strong" => {
|
"b" | "strong" if dehtml.get_add_text() != AddText::No => {
|
||||||
if dehtml.get_add_text() != AddText::No {
|
*dehtml.get_buf() += "*";
|
||||||
*dehtml.get_buf() += "*";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"i" | "em" => {
|
"i" | "em" if dehtml.get_add_text() != AddText::No => {
|
||||||
if dehtml.get_add_text() != AddText::No {
|
*dehtml.get_buf() += "_";
|
||||||
*dehtml.get_buf() += "_";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"blockquote" => pop_tag(&mut dehtml.blockquotes_since_blockquote),
|
"blockquote" => pop_tag(&mut dehtml.blockquotes_since_blockquote),
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -341,15 +337,11 @@ fn dehtml_starttag_cb<B: std::io::BufRead>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"b" | "strong" => {
|
"b" | "strong" if dehtml.get_add_text() != AddText::No => {
|
||||||
if dehtml.get_add_text() != AddText::No {
|
*dehtml.get_buf() += "*";
|
||||||
*dehtml.get_buf() += "*";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"i" | "em" => {
|
"i" | "em" if dehtml.get_add_text() != AddText::No => {
|
||||||
if dehtml.get_add_text() != AddText::No {
|
*dehtml.get_buf() += "_";
|
||||||
*dehtml.get_buf() += "_";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"blockquote" => dehtml.blockquotes_since_blockquote += 1,
|
"blockquote" => dehtml.blockquotes_since_blockquote += 1,
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|||||||
@@ -881,7 +881,7 @@ fn merge_with_cache(
|
|||||||
) -> Vec<SocketAddr> {
|
) -> Vec<SocketAddr> {
|
||||||
let rest = resolved_addrs.split_off(std::cmp::min(resolved_addrs.len(), 2));
|
let rest = resolved_addrs.split_off(std::cmp::min(resolved_addrs.len(), 2));
|
||||||
|
|
||||||
for addr in cache.into_iter().chain(rest.into_iter()) {
|
for addr in cache.into_iter().chain(rest) {
|
||||||
if !resolved_addrs.contains(&addr) {
|
if !resolved_addrs.contains(&addr) {
|
||||||
resolved_addrs.push(addr);
|
resolved_addrs.push(addr);
|
||||||
if resolved_addrs.len() >= 10 {
|
if resolved_addrs.len() >= 10 {
|
||||||
|
|||||||
@@ -109,10 +109,9 @@ impl Context {
|
|||||||
/// called.
|
/// called.
|
||||||
pub(crate) async fn quota_needs_update(&self, transport_id: u32, ratelimit_secs: u64) -> bool {
|
pub(crate) async fn quota_needs_update(&self, transport_id: u32, ratelimit_secs: u64) -> bool {
|
||||||
let quota = self.quota.read().await;
|
let quota = self.quota.read().await;
|
||||||
quota
|
quota.get(&transport_id).is_none_or(|quota| {
|
||||||
.get(&transport_id)
|
time_elapsed("a.modified) >= Duration::from_secs(ratelimit_secs)
|
||||||
.filter(|quota| time_elapsed("a.modified) < Duration::from_secs(ratelimit_secs))
|
})
|
||||||
.is_none()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates `quota.recent`, sets `quota.modified` to the current time
|
/// Updates `quota.recent`, sets `quota.modified` to the current time
|
||||||
|
|||||||
@@ -347,8 +347,7 @@ impl Chat {
|
|||||||
if self
|
if self
|
||||||
.param
|
.param
|
||||||
.get_i64(Param::LastReactionTimestamp)
|
.get_i64(Param::LastReactionTimestamp)
|
||||||
.filter(|&reaction_timestamp| reaction_timestamp > timestamp)
|
.is_none_or(|reaction_timestamp| reaction_timestamp <= timestamp)
|
||||||
.is_none()
|
|
||||||
{
|
{
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -879,8 +879,7 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1
|
|||||||
let instance = if mime_parser
|
let instance = if mime_parser
|
||||||
.parts
|
.parts
|
||||||
.first()
|
.first()
|
||||||
.filter(|part| part.typ == Viewtype::Webxdc)
|
.is_some_and(|part| part.typ == Viewtype::Webxdc)
|
||||||
.is_some()
|
|
||||||
{
|
{
|
||||||
can_info_msg = false;
|
can_info_msg = false;
|
||||||
Some(
|
Some(
|
||||||
|
|||||||
@@ -876,7 +876,7 @@ impl Scheduler {
|
|||||||
let timeout_duration = std::time::Duration::from_secs(30);
|
let timeout_duration = std::time::Duration::from_secs(30);
|
||||||
|
|
||||||
let tracker = TaskTracker::new();
|
let tracker = TaskTracker::new();
|
||||||
for b in self.inboxes.into_iter().chain(self.oboxes.into_iter()) {
|
for b in self.inboxes.into_iter().chain(self.oboxes) {
|
||||||
let context = context.clone();
|
let context = context.clone();
|
||||||
tracker.spawn(async move {
|
tracker.spawn(async move {
|
||||||
tokio::time::timeout(timeout_duration, b.handle)
|
tokio::time::timeout(timeout_duration, b.handle)
|
||||||
|
|||||||
@@ -34,12 +34,10 @@ pub(crate) fn remove_message_footer<'a>(
|
|||||||
// some providers encode `-- ` to `=2D-` which results in only `--`;
|
// some providers encode `-- ` to `=2D-` which results in only `--`;
|
||||||
// use that only when no other footer is found
|
// use that only when no other footer is found
|
||||||
// and if the line before is empty and the line after is not empty
|
// and if the line before is empty and the line after is not empty
|
||||||
"--" => {
|
"--" if (ix == 0 || lines.get(ix.saturating_sub(1)).is_none_or_empty())
|
||||||
if (ix == 0 || lines.get(ix.saturating_sub(1)).is_none_or_empty())
|
&& !lines.get(ix + 1).is_none_or_empty() =>
|
||||||
&& !lines.get(ix + 1).is_none_or_empty()
|
{
|
||||||
{
|
nearly_standard_footer = Some(ix);
|
||||||
nearly_standard_footer = Some(ix);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user