Bug: Add checks in Prod Intent to not sent mail




diff --git a/crates/router/src/core/user/dashboard_metadata.rs b/crates/router/src/core/user/dashboard_metadata.rs
index 82f95564768..7318f9973f1 100644
--- a/crates/router/src/core/user/dashboard_metadata.rs
+++ b/crates/router/src/core/user/dashboard_metadata.rs
@@ -4,10 +4,10 @@ use diesel_models::{
 };
 use error_stack::ResultExt;
 #[cfg(feature = "email")]
+use masking::ExposeInterface;
+#[cfg(feature = "email")]
 use router_env::logger;
 
-#[cfg(feature = "email")]
-use crate::services::email::types as email_types;
 use crate::{
     core::errors::{UserErrors, UserResponse, UserResult},
     routes::AppState,
@@ -15,6 +15,8 @@ use crate::{
     types::domain::{user::dashboard_metadata as types, MerchantKeyStore},
     utils::user::dashboard_metadata as utils,
 };
+#[cfg(feature = "email")]
+use crate::{services::email::types as email_types, types::domain};
 
 pub async fn set_metadata(
     state: AppState,
@@ -446,8 +448,8 @@ async fn insert_metadata(
                 metadata = utils::update_user_scoped_metadata(
                     state,
                     user.user_id.clone(),
-                    user.merchant_id,
-                    user.org_id,
+                    user.merchant_id.clone(),
+                    user.org_id.clone(),
                     metadata_key,
                     data.clone(),
                 )
@@ -457,7 +459,13 @@ async fn insert_metadata(
 
             #[cfg(feature = "email")]
             {
-                if utils::is_prod_email_required(&data) {
+                let user_data = user.get_user(state).await?;
+                let user_email = domain::UserEmail::from_pii_email(user_data.email.clone())
+                    .change_context(UserErrors::InternalServerError)?
+                    .get_secret()
+                    .expose();
+
+                if utils::is_prod_email_required(&data, user_email) {
                     let email_contents = email_types::BizEmailProd::new(state, data)?;
                     let send_email_result = state
                         .email_client
diff --git a/crates/router/src/utils/user/dashboard_metadata.rs b/crates/router/src/utils/user/dashboard_metadata.rs
index ac3d918a34f..58841580244 100644
--- a/crates/router/src/utils/user/dashboard_metadata.rs
+++ b/crates/router/src/utils/user/dashboard_metadata.rs
@@ -279,9 +279,15 @@ pub fn parse_string_to_enums(query: String) -> UserResult<GetMultipleMetaDataPay
     })
 }
 
-pub fn is_prod_email_required(data: &ProdIntent) -> bool {
-    !(data
-        .poc_email
+fn not_contains_string(value: &Option<String>, value_to_be_checked: &str) -> bool {
+    value
         .as_ref()
-        .map_or(true, |mail| mail.contains("juspay")))
+        .map_or(false, |mail| !mail.contains(value_to_be_checked))
+}
+
+pub fn is_prod_email_required(data: &ProdIntent, user_email: String) -> bool {
+    not_contains_string(&data.poc_email, "juspay")
+        && not_contains_string(&data.business_website, "juspay")
+        && not_contains_string(&data.business_website, "hyperswitch")
+        && not_contains_string(&Some(user_email), "juspay")
 }

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
Added some checks so unnecessary biz emails won't be sent.


### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->


## How did you test it?

When we hit this URL the email is sent to biz@hyperswitch.io so to restrict the unnecessary test mails added some checks.
```
curl --location 'http://localhost:8080/user/data' \
--header 'api-key: hyperswitch' \
--header 'Content-Type: text/plain' \
--header 'Authorization: Bearer JWT' \
--data-raw '{
    "ProdIntent": {
        "poc_email": "---",
        "is_completed": true,
        "legal_business_name": "---",
        "business_location": "AX",
        "business_website": "---",
        "poc_name": "---",
        "comments": "---"
    }
}'
```


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
