Skip to content

Commit

Permalink
reach: fix only send to phone (#515)
Browse files Browse the repository at this point in the history
* reach: fix only send to phone

* update

* update
  • Loading branch information
4t145 authored Oct 28, 2023
1 parent c212ed7 commit 8755b74
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions support/reach/src/reach_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub const RBUM_SCOPE_LEVEL_APP: RbumScopeLevelKind = RbumScopeLevelKind::L2;
pub const REACH_INIT_OWNER: &str = "ReachInit";

pub const IAM_KEY_PHONE_V_CODE: &str = "PhoneVCode";
pub const IAM_KEY_MAIL_V_CODE: &str = "MailVCode";

pub const ACCOUNT_SPLIT: char = ';';

Expand Down
18 changes: 9 additions & 9 deletions support/reach/src/reach_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ pub async fn db_init() -> TardisResult<()> {
DOMAIN_REACH_ID.set(domain_id).expect("fail to set DOMAIN_REACH_ID");
let db_kind = TardisFuns::reldb().backend();
let compatible_type = TardisFuns::reldb().compatible_type();
funs.db().init(crate::domain::message_log::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::message_signature::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::message_template::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::message::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::trigger_global_config::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::trigger_instance_config::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::trigger_scene::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
funs.db().init(crate::domain::reach_vcode_strategy::ActiveModel::init(db_kind, None, compatible_type.clone())).await?;
ReachTriggerSceneService::init(&funs, &ctx).await?;
funs.db().init(crate::domain::message_log::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::message_signature::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::message_template::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::message::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::trigger_global_config::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::trigger_instance_config::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::trigger_scene::ActiveModel::init(db_kind, None, compatible_type)).await?;
funs.db().init(crate::domain::reach_vcode_strategy::ActiveModel::init(db_kind, None, compatible_type)).await?;
// ReachTriggerSceneService::init(&funs, &ctx).await?;
funs.commit().await?;
Ok(())
}
Expand Down
15 changes: 12 additions & 3 deletions support/reach/src/task/message_send_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,22 @@ impl MessageSendListener {
let mut to = HashSet::new();
let start_time = Utc::now();
let owner_path = rbum_scope_helper::get_pre_paths(RBUM_SCOPE_LEVEL_TENANT as i16, &message.own_paths).unwrap_or_default();
let cert_key = match message.rel_reach_channel {
ReachChannelKind::Sms => IAM_KEY_PHONE_V_CODE,
ReachChannelKind::Email => IAM_KEY_MAIL_V_CODE,
_ => {
// unsupported
ReachMessageServ::update_status(&message.id, ReachStatusKind::Pending, ReachStatusKind::Fail, &self.funs, &ctx).await?;
return Ok(());
}
};
for account_id in message.to_res_ids.split(ACCOUNT_SPLIT) {
if let Ok(mut resp) = iam_client.get_account(account_id, &owner_path).await {
let Some(phone) = resp.certs.remove(IAM_KEY_PHONE_V_CODE) else {
log::warn!("[Reach] Notify Phone channel send error, missing [PhoneVCode] parameters, resp: {resp:?}");
let Some(res_id) = resp.certs.remove(cert_key) else {
log::warn!("[Reach] Notify {chan} channel send error, missing [{cert_key}] parameters, resp: {resp:?}", chan = message.rel_reach_channel);
continue;
};
to.insert(phone);
to.insert(res_id);
} else {
log::warn!("[Reach] iam get account info error, account_id: {account_id}")
}
Expand Down

0 comments on commit 8755b74

Please sign in to comment.