Testability ddd repository (#55)

This commit is contained in:
kos-for-juspay
2022-12-03 07:18:51 +02:00
committed by GitHub
parent 35289df715
commit 200a085fd0
116 changed files with 3551 additions and 1653 deletions

View File

@ -1,21 +1,24 @@
use crate::{connection::RedisPool, types::api};
use crate::{
db::{get_and_deserialize_key, StorageInterface},
types::api,
};
fn default_webhook_config() -> api::MerchantWebhookConfig {
std::collections::HashSet::from([api::IncomingWebhookEvent::PaymentIntentSuccess])
}
pub async fn lookup_webhook_event(
db: &dyn StorageInterface,
connector_id: &str,
merchant_id: &str,
event: &api::IncomingWebhookEvent,
conn: RedisPool,
) -> bool {
let redis_key = format!("whconf_{}_{}", merchant_id, connector_id);
let webhook_config: api::MerchantWebhookConfig = conn
.get_and_deserialize_key(&redis_key, "MerchantWebhookConfig")
.await
.map(|h| &h | &default_webhook_config())
.unwrap_or_else(|_| default_webhook_config());
let webhook_config: api::MerchantWebhookConfig =
get_and_deserialize_key(db, &redis_key, "MerchantWebhookConfig")
.await
.map(|h| &h | &default_webhook_config())
.unwrap_or_else(|_| default_webhook_config());
webhook_config.contains(event)
}