Skip to content

Commit

Permalink
reach: fix cannot add trigger config with empty id (#517)
Browse files Browse the repository at this point in the history
* reach: fix only send to phone

* update

* update

* fix cannot add trigger config with empty id
  • Loading branch information
4t145 authored Oct 28, 2023
1 parent 059904f commit 8f455ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion support/reach/src/serv/message_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub async fn message_send(send_req: ReachMsgSendReq, funs: &TardisFunsInst, ctx:

for (_kind, gc) in global_configs {
for (receive_kind, to_res_ids) in &other_receive_collect {
if other_group_code.contains(&gc.rel_reach_channel) {
if other_group_code.contains(&gc.rel_reach_channel) && !gc.rel_reach_msg_signature_id.is_empty() && !gc.rel_reach_msg_template_id.is_empty() {
ReachMessageServ::add_rbum(
&mut ReachMessageAddReq {
rbum_item_add_req: RbumItemAddReq {
Expand Down
13 changes: 9 additions & 4 deletions support/reach/src/serv/trigger_global_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tardis::basic::result::TardisResult;
use tardis::db::reldb_client::TardisActiveModel;
use tardis::db::sea_orm::sea_query::{Query, SelectStatement};
use tardis::db::sea_orm::*;
use tardis::{TardisFuns, TardisFunsInst};
use tardis::{TardisFuns, TardisFunsInst, log};

pub struct ReachTriggerGlobalConfigService;

Expand Down Expand Up @@ -50,7 +50,8 @@ impl
.and_where(message_signature::Column::Id.eq(&add_req.rel_reach_msg_signature_id)),
)
.await? {
return Err(funs.err().bad_request("reach_trigger_global_config", "before_add_rbum", "rel_reach_msg_signature_id doesn't exist", ""));
return Ok(())
// return Err(funs.err().bad_request("reach_trigger_global_config", "before_add_rbum", "rel_reach_msg_signature_id doesn't exist", ""));
}
if 1 != funs
.db()
Expand All @@ -59,7 +60,8 @@ impl
)
.await?
{
return Err(funs.err().bad_request("reach_trigger_global_config", "before_add_rbum", "rel_reach_msg_template_id doesn't exist", ""));
return Ok(());
// return Err(funs.err().bad_request("reach_trigger_global_config", "before_add_rbum", "rel_reach_msg_template_id doesn't exist", ""));
}
let mut filter = ReachTriggerGlobalConfigFilterReq {
rel_reach_trigger_scene_id: Some(add_req.rel_reach_trigger_scene_id.clone()),
Expand All @@ -69,7 +71,9 @@ impl
filter.base_filter.basic.with_sub_own_paths = true;

if 0 != Self::count_rbums(&filter, funs, ctx).await? {
return Err(funs.err().bad_request("reach_trigger_global_config", "before_add_rbum", "reach_trigger_scene_id and reach_channel is exist", ""));
log::warn!("[Reach] reach_trigger_scene_id {id} and reach_channel {chan} is exist", id = add_req.rel_reach_trigger_scene_id, chan = add_req.rel_reach_channel);
return Ok(());
// return Err(funs.err().bad_request("reach_trigger_global_config", "before_add_rbum", "reach_trigger_scene_id and reach_channel is exist", ""));
}
Ok(())
}
Expand Down Expand Up @@ -115,6 +119,7 @@ impl ReachTriggerGlobalConfigService {
}
pub async fn add_or_modify_global_config(agg_req: ReachTriggerGlobalConfigAddOrModifyAggReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> {
for req in agg_req.global_config {

Self::add_or_modify_by_single_req(req, funs, ctx).await?;
}
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions support/reach/src/task/message_send_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ impl Default for MessageSendListener {
}

impl MessageSendListener {
async fn execute_send_account(&self, message: message::Model, template: message_template::Model, _signarure: Option<message_signature::Model>) -> TardisResult<()> {
let content_replace: ContentReplace = message.content_replace.parse()?;
async fn execute_send_account(&self, content_replace: ContentReplace, message: message::Model, template: message_template::Model, _signarure: Option<message_signature::Model>) -> TardisResult<()> {
let cfg = self.funs.conf::<ReachConfig>();
let _lock = self.sync.lock().await;
let ctx = TardisContext {
Expand Down Expand Up @@ -150,9 +149,10 @@ impl MessageSendListener {
// .and_where(message_signature::Column::Id.eq(&message.rel_reach_msg_signature_id)),
// )
// .await?;
let content_replace: ContentReplace = message.content_replace.parse()?;
match message.receive_kind {
ReachReceiveKind::Account => {
let _res = self.execute_send_account(message, template, None).await;
let _res = self.execute_send_account(content_replace, message, template, None).await;
}
ReachReceiveKind::Tenant => {
// do nothing
Expand Down

0 comments on commit 8f455ff

Please sign in to comment.