Clippy fixes
This commit is contained in:
@@ -98,11 +98,11 @@ pub fn spawn_housekeeper(inner: Arc<Inner>, mut rx: mpsc::Receiver<HousekeeperEv
|
||||
}
|
||||
|
||||
// OTEL Push Metrics
|
||||
if server.core.network.roles.push_metrics {
|
||||
if let Some(otel) = &server.core.metrics.otel {
|
||||
OtelMetrics::enable_errors();
|
||||
queue.schedule(Instant::now() + otel.interval, ActionClass::OtelMetrics);
|
||||
}
|
||||
if server.core.network.roles.push_metrics
|
||||
&& let Some(otel) = &server.core.metrics.otel
|
||||
{
|
||||
OtelMetrics::enable_errors();
|
||||
queue.schedule(Instant::now() + otel.interval, ActionClass::OtelMetrics);
|
||||
}
|
||||
|
||||
// Calculate expensive metrics
|
||||
@@ -199,13 +199,13 @@ pub fn spawn_housekeeper(inner: Arc<Inner>, mut rx: mpsc::Receiver<HousekeeperEv
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(metrics_store) = enterprise.metrics_store.as_ref() {
|
||||
if !queue.has_action(&ActionClass::InternalMetrics) {
|
||||
queue.schedule(
|
||||
Instant::now() + metrics_store.interval.time_to_next(),
|
||||
ActionClass::InternalMetrics,
|
||||
);
|
||||
}
|
||||
if let Some(metrics_store) = enterprise.metrics_store.as_ref()
|
||||
&& !queue.has_action(&ActionClass::InternalMetrics)
|
||||
{
|
||||
queue.schedule(
|
||||
Instant::now() + metrics_store.interval.time_to_next(),
|
||||
ActionClass::InternalMetrics,
|
||||
);
|
||||
}
|
||||
|
||||
if !enterprise.metrics_alerts.is_empty()
|
||||
@@ -719,17 +719,17 @@ impl Purge for Server {
|
||||
// SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
|
||||
// SPDX-License-Identifier: LicenseRef-SEL
|
||||
#[cfg(feature = "enterprise")]
|
||||
if let Some(trace_retention) = trace_retention {
|
||||
if let Err(err) = store.purge_spans(trace_retention).await {
|
||||
trc::error!(err.details("Failed to purge tracing spans"));
|
||||
}
|
||||
if let Some(trace_retention) = trace_retention
|
||||
&& let Err(err) = store.purge_spans(trace_retention).await
|
||||
{
|
||||
trc::error!(err.details("Failed to purge tracing spans"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "enterprise")]
|
||||
if let Some(metrics_retention) = metrics_retention {
|
||||
if let Err(err) = store.purge_metrics(metrics_retention).await {
|
||||
trc::error!(err.details("Failed to purge metrics"));
|
||||
}
|
||||
if let Some(metrics_retention) = metrics_retention
|
||||
&& let Err(err) = store.purge_metrics(metrics_retention).await
|
||||
{
|
||||
trc::error!(err.details("Failed to purge metrics"));
|
||||
}
|
||||
// SPDX-SnippetEnd
|
||||
}
|
||||
@@ -767,17 +767,16 @@ impl Purge for Server {
|
||||
);
|
||||
|
||||
// Remove lock
|
||||
if let Some(lock_name) = &lock_name {
|
||||
if let Err(err) = self
|
||||
if let Some(lock_name) = &lock_name
|
||||
&& let Err(err) = self
|
||||
.in_memory_store()
|
||||
.remove_lock(KV_LOCK_HOUSEKEEPER, lock_name)
|
||||
.await
|
||||
{
|
||||
trc::error!(
|
||||
err.details("Failed to delete task lock.")
|
||||
.details(lock_type)
|
||||
);
|
||||
}
|
||||
{
|
||||
trc::error!(
|
||||
err.details("Failed to delete task lock.")
|
||||
.details(lock_type)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,14 +75,12 @@ pub fn spawn_state_manager(inner: Arc<Inner>, mut change_rx: mpsc::Receiver<Stat
|
||||
.access_to
|
||||
.iter()
|
||||
.any(|(id, _)| *id == *shared_account_id)
|
||||
{
|
||||
if let Some(shared_list) =
|
||||
&& let Some(shared_list) =
|
||||
shared_accounts_map.get_mut(shared_account_id)
|
||||
{
|
||||
shared_list.remove(&account_id);
|
||||
if shared_list.is_empty() {
|
||||
shared_accounts_map.remove(shared_account_id);
|
||||
}
|
||||
{
|
||||
shared_list.remove(&account_id);
|
||||
if shared_list.is_empty() {
|
||||
shared_accounts_map.remove(shared_account_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,20 +138,18 @@ pub fn spawn_state_manager(inner: Arc<Inner>, mut change_rx: mpsc::Receiver<Stat
|
||||
broadcast,
|
||||
} => {
|
||||
// Publish event to cluster
|
||||
if broadcast {
|
||||
if let Some(broadcast_tx) = &inner.ipc.broadcast_tx.clone() {
|
||||
if broadcast_tx
|
||||
.send(BroadcastEvent::StateChange(state_change))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
trc::event!(
|
||||
Server(trc::ServerEvent::ThreadError),
|
||||
Details = "Error sending broadcast event.",
|
||||
CausedBy = trc::location!()
|
||||
);
|
||||
}
|
||||
}
|
||||
if broadcast
|
||||
&& let Some(broadcast_tx) = &inner.ipc.broadcast_tx.clone()
|
||||
&& broadcast_tx
|
||||
.send(BroadcastEvent::StateChange(state_change))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
trc::event!(
|
||||
Server(trc::ServerEvent::ThreadError),
|
||||
Details = "Error sending broadcast event.",
|
||||
CausedBy = trc::location!()
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(shared_accounts) = shared_accounts_map.get(&state_change.account_id)
|
||||
@@ -247,14 +243,14 @@ pub fn spawn_state_manager(inner: Arc<Inner>, mut change_rx: mpsc::Receiver<Stat
|
||||
let mut remove_ids = Vec::new();
|
||||
|
||||
for subscriber_id in subscribers.keys() {
|
||||
if let SubscriberId::Push(push_id) = subscriber_id {
|
||||
if !subscriptions.iter().any(|s| {
|
||||
if let SubscriberId::Push(push_id) = subscriber_id
|
||||
&& !subscriptions.iter().any(|s| {
|
||||
matches!(s, UpdateSubscription::Verified(
|
||||
PushSubscription { id, .. }
|
||||
) if id == push_id)
|
||||
}) {
|
||||
remove_ids.push(*subscriber_id);
|
||||
}
|
||||
})
|
||||
{
|
||||
remove_ids.push(*subscriber_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -476,82 +476,79 @@ pub async fn build_itip_template(
|
||||
if let Some(guests) = fields
|
||||
.iter()
|
||||
.find(|e| e.name == ICalendarProperty::Attendee)
|
||||
&& let ArchivedItipValue::Participants(guests) = &guests.value
|
||||
{
|
||||
if let ArchivedItipValue::Participants(guests) = &guests.value {
|
||||
variables.insert_single(
|
||||
CalendarTemplateVariable::AttendeesTitle,
|
||||
locale.calendar_attendees.to_string(),
|
||||
);
|
||||
variables.insert_block(
|
||||
CalendarTemplateVariable::Attendees,
|
||||
guests.iter().map(|guest| {
|
||||
[
|
||||
(
|
||||
CalendarTemplateVariable::Key,
|
||||
if guest.is_organizer {
|
||||
if let Some(name) = guest.name.as_ref() {
|
||||
format!("{name} - {}", locale.calendar_organizer)
|
||||
} else {
|
||||
locale.calendar_organizer.to_string()
|
||||
}
|
||||
variables.insert_single(
|
||||
CalendarTemplateVariable::AttendeesTitle,
|
||||
locale.calendar_attendees.to_string(),
|
||||
);
|
||||
variables.insert_block(
|
||||
CalendarTemplateVariable::Attendees,
|
||||
guests.iter().map(|guest| {
|
||||
[
|
||||
(
|
||||
CalendarTemplateVariable::Key,
|
||||
if guest.is_organizer {
|
||||
if let Some(name) = guest.name.as_ref() {
|
||||
format!("{name} - {}", locale.calendar_organizer)
|
||||
} else {
|
||||
guest
|
||||
.name
|
||||
.as_ref()
|
||||
.map(|n| n.as_str())
|
||||
.unwrap_or_default()
|
||||
.to_string()
|
||||
},
|
||||
),
|
||||
(CalendarTemplateVariable::Value, guest.email.to_string()),
|
||||
]
|
||||
}),
|
||||
);
|
||||
}
|
||||
locale.calendar_organizer.to_string()
|
||||
}
|
||||
} else {
|
||||
guest
|
||||
.name
|
||||
.as_ref()
|
||||
.map(|n| n.as_str())
|
||||
.unwrap_or_default()
|
||||
.to_string()
|
||||
},
|
||||
),
|
||||
(CalendarTemplateVariable::Value, guest.email.to_string()),
|
||||
]
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Add RSVP buttons
|
||||
if matches!(
|
||||
summary,
|
||||
ArchivedItipSummary::Invite(_) | ArchivedItipSummary::Update { .. }
|
||||
) {
|
||||
if let Some(rsvp_url) = server
|
||||
.http_rsvp_url(task.account_id, task.document_id, to)
|
||||
.await
|
||||
{
|
||||
variables.insert_single(
|
||||
CalendarTemplateVariable::Rsvp,
|
||||
locale.calendar_reply_as.replace("$name", to),
|
||||
);
|
||||
variables.insert_block(
|
||||
CalendarTemplateVariable::Actions,
|
||||
) && let Some(rsvp_url) = server
|
||||
.http_rsvp_url(task.account_id, task.document_id, to)
|
||||
.await
|
||||
{
|
||||
variables.insert_single(
|
||||
CalendarTemplateVariable::Rsvp,
|
||||
locale.calendar_reply_as.replace("$name", to),
|
||||
);
|
||||
variables.insert_block(
|
||||
CalendarTemplateVariable::Actions,
|
||||
[
|
||||
(
|
||||
ICalendarParticipationStatus::Accepted,
|
||||
locale.calendar_yes.to_string(),
|
||||
"info",
|
||||
),
|
||||
(
|
||||
ICalendarParticipationStatus::Declined,
|
||||
locale.calendar_no.to_string(),
|
||||
"danger",
|
||||
),
|
||||
(
|
||||
ICalendarParticipationStatus::Tentative,
|
||||
locale.calendar_maybe.to_string(),
|
||||
"warning",
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(status, title, color)| {
|
||||
[
|
||||
(
|
||||
ICalendarParticipationStatus::Accepted,
|
||||
locale.calendar_yes.to_string(),
|
||||
"info",
|
||||
),
|
||||
(
|
||||
ICalendarParticipationStatus::Declined,
|
||||
locale.calendar_no.to_string(),
|
||||
"danger",
|
||||
),
|
||||
(
|
||||
ICalendarParticipationStatus::Tentative,
|
||||
locale.calendar_maybe.to_string(),
|
||||
"warning",
|
||||
),
|
||||
(CalendarTemplateVariable::ActionName, title.to_string()),
|
||||
(CalendarTemplateVariable::ActionUrl, rsvp_url.url(&status)),
|
||||
(CalendarTemplateVariable::Color, color.to_string()),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(status, title, color)| {
|
||||
[
|
||||
(CalendarTemplateVariable::ActionName, title.to_string()),
|
||||
(CalendarTemplateVariable::ActionUrl, rsvp_url.url(&status)),
|
||||
(CalendarTemplateVariable::Color, color.to_string()),
|
||||
]
|
||||
}),
|
||||
);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// Add footer
|
||||
|
||||
Reference in New Issue
Block a user