less duplicate code on calling inner_set_protection()

This commit is contained in:
B. Petersen
2020-10-13 14:04:38 +02:00
parent 50f3af58f8
commit 7f882a6406

View File

@@ -715,25 +715,15 @@ async fn add_parts(
} }
// change chat protection // change chat protection
if mime_parser.is_system_message == SystemMessage::ChatProtectionEnabled { if let Some(new_status) = match mime_parser.is_system_message {
chat_id SystemMessage::ChatProtectionEnabled => Some(ProtectionStatus::Protected),
.inner_set_protection(context, ProtectionStatus::Protected) SystemMessage::ChatProtectionDisabled => Some(ProtectionStatus::Unprotected),
.await?; _ => None,
} {
chat_id.inner_set_protection(context, new_status).await?;
set_better_msg( set_better_msg(
mime_parser, mime_parser,
context context.stock_protection_msg(new_status, from_id).await,
.stock_protection_msg(ProtectionStatus::Protected, from_id)
.await,
);
} else if mime_parser.is_system_message == SystemMessage::ChatProtectionDisabled {
chat_id
.inner_set_protection(context, ProtectionStatus::Unprotected)
.await?;
set_better_msg(
mime_parser,
context
.stock_protection_msg(ProtectionStatus::Unprotected, from_id)
.await,
); );
} }