Clippy fixes
This commit is contained in:
@@ -48,10 +48,10 @@ impl StateManager for Server {
|
||||
if_in_state: &Option<State>,
|
||||
) -> trc::Result<State> {
|
||||
let old_state: State = self.get_state(account_id, collection).await?;
|
||||
if let Some(if_in_state) = if_in_state {
|
||||
if &old_state != if_in_state {
|
||||
return Err(trc::JmapEvent::StateMismatch.into_err());
|
||||
}
|
||||
if let Some(if_in_state) = if_in_state
|
||||
&& &old_state != if_in_state
|
||||
{
|
||||
return Err(trc::JmapEvent::StateMismatch.into_err());
|
||||
}
|
||||
|
||||
Ok(old_state)
|
||||
@@ -69,10 +69,10 @@ impl MessageCacheState for MessageStoreCache {
|
||||
|
||||
fn assert_state(&self, is_mailbox: bool, if_in_state: &Option<State>) -> trc::Result<State> {
|
||||
let old_state: State = self.get_state(is_mailbox);
|
||||
if let Some(if_in_state) = if_in_state {
|
||||
if &old_state != if_in_state {
|
||||
return Err(trc::JmapEvent::StateMismatch.into_err());
|
||||
}
|
||||
if let Some(if_in_state) = if_in_state
|
||||
&& &old_state != if_in_state
|
||||
{
|
||||
return Err(trc::JmapEvent::StateMismatch.into_err());
|
||||
}
|
||||
Ok(old_state)
|
||||
}
|
||||
|
||||
@@ -86,11 +86,11 @@ impl JmapMethods for Server {
|
||||
}
|
||||
|
||||
async fn build_query_response<T: Sync + Send>(
|
||||
&self,
|
||||
&'_ self,
|
||||
result_set: &ResultSet,
|
||||
query_state: State,
|
||||
request: &QueryRequest<T>,
|
||||
) -> trc::Result<(QueryResponse, Option<Pagination>)> {
|
||||
) -> trc::Result<(QueryResponse, Option<Pagination<'_>>)> {
|
||||
let total = result_set.results.len() as usize;
|
||||
let (limit_total, limit) = if let Some(limit) = request.limit {
|
||||
if limit > 0 {
|
||||
@@ -182,11 +182,11 @@ pub trait JmapMethods: Sync + Send {
|
||||
) -> impl Future<Output = trc::Result<RoaringBitmap>> + Send;
|
||||
|
||||
fn build_query_response<T: Sync + Send>(
|
||||
&self,
|
||||
&'_ self,
|
||||
result_set: &ResultSet,
|
||||
query_state: State,
|
||||
request: &QueryRequest<T>,
|
||||
) -> impl Future<Output = trc::Result<(QueryResponse, Option<Pagination>)>> + Send;
|
||||
) -> impl Future<Output = trc::Result<(QueryResponse, Option<Pagination<'_>>)>> + Send;
|
||||
|
||||
fn sort(
|
||||
&self,
|
||||
|
||||
@@ -182,10 +182,10 @@ impl MailboxQuery for Server {
|
||||
if response.total.is_some() {
|
||||
response.total = Some(total);
|
||||
}
|
||||
if let Some(paginate) = &mut paginate {
|
||||
if paginate.limit > total {
|
||||
paginate.limit = total;
|
||||
}
|
||||
if let Some(paginate) = &mut paginate
|
||||
&& paginate.limit > total
|
||||
{
|
||||
paginate.limit = total;
|
||||
}
|
||||
result_set.results = filtered_ids;
|
||||
}
|
||||
|
||||
@@ -391,8 +391,7 @@ impl SieveScriptSet for Server {
|
||||
} else if update
|
||||
.as_ref()
|
||||
.is_none_or(|(_, obj)| obj.inner.name != value)
|
||||
{
|
||||
if let Some(id) = self
|
||||
&& let Some(id) = self
|
||||
.filter(
|
||||
ctx.resource_token.account_id,
|
||||
Collection::SieveScript,
|
||||
@@ -401,14 +400,13 @@ impl SieveScriptSet for Server {
|
||||
.await?
|
||||
.results
|
||||
.min()
|
||||
{
|
||||
return Ok(Err(SetError::already_exists()
|
||||
.with_existing_id(id.into())
|
||||
.with_description(format!(
|
||||
"A sieve script with name '{}' already exists.",
|
||||
value
|
||||
))));
|
||||
}
|
||||
{
|
||||
return Ok(Err(SetError::already_exists()
|
||||
.with_existing_id(id.into())
|
||||
.with_description(format!(
|
||||
"A sieve script with name '{}' already exists.",
|
||||
value
|
||||
))));
|
||||
}
|
||||
|
||||
changes.name = value;
|
||||
|
||||
@@ -103,39 +103,39 @@ impl EmailSubmissionGet for Server {
|
||||
.map(|(k, v)| (k.to_string(), DeliveryStatus::from(v)))
|
||||
.collect::<VecMap<_, _>>();
|
||||
let mut is_pending = false;
|
||||
if let Some(queue_id) = submission.queue_id.as_ref().map(u64::from) {
|
||||
if let Some(queued_message_) = self
|
||||
if let Some(queue_id) = submission.queue_id.as_ref().map(u64::from)
|
||||
&& let Some(queued_message_) = self
|
||||
.read_message_archive(queue_id)
|
||||
.await
|
||||
.caused_by(trc::location!())?
|
||||
{
|
||||
let queued_message = queued_message_
|
||||
.unarchive::<Message>()
|
||||
.caused_by(trc::location!())?;
|
||||
for rcpt in queued_message.recipients.iter() {
|
||||
*delivery_status.get_mut_or_insert(rcpt.address().to_string()) =
|
||||
DeliveryStatus {
|
||||
smtp_reply: match &rcpt.status {
|
||||
ArchivedStatus::Completed(reply) => {
|
||||
format_archived_response(&reply.response)
|
||||
}
|
||||
ArchivedStatus::TemporaryFailure(reply)
|
||||
| ArchivedStatus::PermanentFailure(reply) => {
|
||||
format_archived_error_details(reply)
|
||||
}
|
||||
ArchivedStatus::Scheduled => "250 2.1.5 Queued".to_string(),
|
||||
},
|
||||
delivered: match &rcpt.status {
|
||||
ArchivedStatus::Scheduled
|
||||
| ArchivedStatus::TemporaryFailure(_) => Delivered::Queued,
|
||||
ArchivedStatus::Completed(_) => Delivered::Yes,
|
||||
ArchivedStatus::PermanentFailure(_) => Delivered::No,
|
||||
},
|
||||
displayed: false,
|
||||
};
|
||||
}
|
||||
is_pending = true;
|
||||
{
|
||||
let queued_message = queued_message_
|
||||
.unarchive::<Message>()
|
||||
.caused_by(trc::location!())?;
|
||||
for rcpt in queued_message.recipients.iter() {
|
||||
*delivery_status.get_mut_or_insert(rcpt.address().to_string()) =
|
||||
DeliveryStatus {
|
||||
smtp_reply: match &rcpt.status {
|
||||
ArchivedStatus::Completed(reply) => {
|
||||
format_archived_response(&reply.response)
|
||||
}
|
||||
ArchivedStatus::TemporaryFailure(reply)
|
||||
| ArchivedStatus::PermanentFailure(reply) => {
|
||||
format_archived_error_details(reply)
|
||||
}
|
||||
ArchivedStatus::Scheduled => "250 2.1.5 Queued".to_string(),
|
||||
},
|
||||
delivered: match &rcpt.status {
|
||||
ArchivedStatus::Scheduled | ArchivedStatus::TemporaryFailure(_) => {
|
||||
Delivered::Queued
|
||||
}
|
||||
ArchivedStatus::Completed(_) => Delivered::Yes,
|
||||
ArchivedStatus::PermanentFailure(_) => Delivered::No,
|
||||
},
|
||||
displayed: false,
|
||||
};
|
||||
}
|
||||
is_pending = true;
|
||||
}
|
||||
|
||||
let mut result = Object::with_capacity(properties.len());
|
||||
|
||||
@@ -511,17 +511,17 @@ impl EmailSubmissionSet for Server {
|
||||
}
|
||||
if let ArchivedHeaderValue::Address(addr) = &header.value {
|
||||
for address in addr.iter() {
|
||||
if let Some(address) = address.address().and_then(sanitize_email) {
|
||||
if !rcpt_to.iter().any(|rcpt| rcpt.address == address) {
|
||||
submission.envelope.rcpt_to.push(Address {
|
||||
email: address.to_string(),
|
||||
parameters: None,
|
||||
});
|
||||
rcpt_to.push(RcptTo {
|
||||
address,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
if let Some(address) = address.address().and_then(sanitize_email)
|
||||
&& !rcpt_to.iter().any(|rcpt| rcpt.address == address)
|
||||
{
|
||||
submission.envelope.rcpt_to.push(Address {
|
||||
email: address.to_string(),
|
||||
parameters: None,
|
||||
});
|
||||
rcpt_to.push(RcptTo {
|
||||
address,
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -696,19 +696,19 @@ fn parse_envelope_address(
|
||||
let mut params_list = VecMap::with_capacity(params.0.len());
|
||||
|
||||
for (k, v) in params.0 {
|
||||
if let Property::_T(k) = k {
|
||||
if !k.is_empty() {
|
||||
if !params_text.is_empty() {
|
||||
params_text.push(' ');
|
||||
}
|
||||
params_text.push_str(&k);
|
||||
if let Value::Text(v) = v {
|
||||
params_text.push('=');
|
||||
params_text.push_str(&v);
|
||||
params_list.append(k, Some(v));
|
||||
} else {
|
||||
params_list.append(k, None);
|
||||
}
|
||||
if let Property::_T(k) = k
|
||||
&& !k.is_empty()
|
||||
{
|
||||
if !params_text.is_empty() {
|
||||
params_text.push(' ');
|
||||
}
|
||||
params_text.push_str(&k);
|
||||
if let Value::Text(v) = v {
|
||||
params_text.push('=');
|
||||
params_text.push_str(&v);
|
||||
params_list.append(k, Some(v));
|
||||
} else {
|
||||
params_list.append(k, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,14 +315,13 @@ impl VacationResponseSet for Server {
|
||||
}
|
||||
} else if !will_destroy.is_empty() {
|
||||
for id in will_destroy {
|
||||
if id.is_singleton() {
|
||||
if let Some(document_id) = self.get_vacation_sieve_script_id(account_id).await?
|
||||
{
|
||||
self.sieve_script_delete(&resource_token, document_id, false, &mut batch)
|
||||
.await?;
|
||||
response.destroyed.push(id);
|
||||
continue;
|
||||
}
|
||||
if id.is_singleton()
|
||||
&& let Some(document_id) = self.get_vacation_sieve_script_id(account_id).await?
|
||||
{
|
||||
self.sieve_script_delete(&resource_token, document_id, false, &mut batch)
|
||||
.await?;
|
||||
response.destroyed.push(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
response.not_destroyed.append(id, SetError::not_found());
|
||||
|
||||
Reference in New Issue
Block a user