refactor(set_protection_for_timestamp_sort): do not log bubbled up errors

Otherwise error may be logged twice.
This commit is contained in:
link2xt
2024-10-14 05:28:39 +00:00
parent 287256693c
commit 57871bbaf8

View File

@@ -589,8 +589,10 @@ impl ChatId {
timestamp_sort: i64, timestamp_sort: i64,
contact_id: Option<ContactId>, contact_id: Option<ContactId>,
) -> Result<()> { ) -> Result<()> {
match self.inner_set_protection(context, protect).await { let protection_status_modified = self
Ok(protection_status_modified) => { .inner_set_protection(context, protect)
.await
.with_context(|| format!("Cannot set protection for {self}"))?;
if protection_status_modified { if protection_status_modified {
self.add_protection_msg(context, protect, contact_id, timestamp_sort) self.add_protection_msg(context, protect, contact_id, timestamp_sort)
.await?; .await?;
@@ -598,12 +600,6 @@ impl ChatId {
} }
Ok(()) Ok(())
} }
Err(e) => {
error!(context, "Cannot set protection: {e:#}."); // make error user-visible
Err(e)
}
}
}
/// Sets protection and sends or adds a message. /// Sets protection and sends or adds a message.
/// ///