feat: implement on_app_start to set default exchange rate adapter in settings
This commit is contained in:
@@ -138,7 +138,31 @@ impl ExchangeRateServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
impl ServiceTrait for ExchangeRateServiceImpl {}
|
||||
#[async_trait::async_trait]
|
||||
impl ServiceTrait for ExchangeRateServiceImpl {
|
||||
async fn on_app_start(&self) -> CommandResult<()> {
|
||||
// Ensure the default adapter is set in settings if not already set
|
||||
let current_adapter = self
|
||||
.settings_service
|
||||
.get_setting(
|
||||
&Self::get_settings_key(EXCHANGE_ADAPTER_SETTING_KEY),
|
||||
DEFAULT_ADAPTER_NAME,
|
||||
)
|
||||
.await;
|
||||
|
||||
if current_adapter.is_empty() {
|
||||
self.settings_service
|
||||
.update_setting(
|
||||
Self::get_settings_key(EXCHANGE_ADAPTER_SETTING_KEY),
|
||||
DEFAULT_ADAPTER_NAME.to_string(),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl ExchangeRateService for ExchangeRateServiceImpl {
|
||||
|
||||
Reference in New Issue
Block a user