Create get_configured_provider(), remove delete_server_after == "1" check

This commit is contained in:
Hocuri
2021-01-20 13:31:42 +01:00
parent 687db252b6
commit b67fbedcef
3 changed files with 17 additions and 22 deletions

View File

@@ -3,7 +3,6 @@
use strum::{EnumProperty, IntoEnumIterator};
use strum_macros::{AsRefStr, Display, EnumIter, EnumProperty, EnumString};
use crate::blob::BlobObject;
use crate::chat::ChatId;
use crate::constants::DC_VERSION_STR;
use crate::context::Context;
@@ -13,6 +12,10 @@ use crate::job;
use crate::message::MsgId;
use crate::mimefactory::RECOMMENDED_FILE_SIZE;
use crate::stock::StockMessage;
use crate::{
blob::BlobObject,
provider::{get_provider_by_id, Provider},
};
/// The available configuration keys.
#[derive(
@@ -212,6 +215,14 @@ impl Context {
}
}
/// Gets the configured provider, as saved in the `configured_provider` value.
///
/// The provider is determined by `get_provider_info()` during configuration and then saved
/// to the db in `param.save_to_database()`, together with all the other `configured_*` values.
pub async fn get_configured_provider(&self) -> Option<&'static Provider> {
get_provider_by_id(&self.get_config(Config::ConfiguredProvider).await?)
}
/// Gets configured "delete_device_after" value.
///
/// `None` means never delete the message, `Some(x)` means delete