Skip to content

Commit 3725f5f

Browse files
committed
feat: sendemail节点新增是否发送飞书选项#AI Commit#
1 parent 0b14e72 commit 3725f5f

9 files changed

Lines changed: 64 additions & 19 deletions

File tree

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/java/com/webank/wedatasphere/dss/appconn/sendemail/email/Email.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ public interface Email {
4343

4444
String getEmailType();
4545
void setEmailType(String emailType);
46+
47+
String getFeishuTo();
48+
void setFeishuTo(String feishuTo);
4649
}

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/resources/appconn.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ wds.dss.appconn.email.password=
3030
# wds.dss.appconn.email.smtp.ssl.enable=true
3131
# wds.dss.appconn.email.smtp.timeout=25000
3232

33-
33+
# Feishu connection properties. Whether to send Feishu messages is selected on each sendemail node.
34+
# wds.dss.appconn.feishu.app.id=
35+
# wds.dss.appconn.feishu.app.secret=
36+
# wds.dss.appconn.feishu.api.base.url=https://open.feishu.cn/open-apis
3437

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/resources/init.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ delete from `dss_workflow_node_to_group` where `node_id`=@sendemail_nodeId;
2020

2121
delete from `dss_workflow_node_to_ui` where `workflow_node_id`=@sendemail_nodeId;
2222

23+
select @sendemail_node_ui_send_feishu:=id from `dss_workflow_node_ui` where `key` = 'sendFeishu' limit 1;
24+
insert into `dss_workflow_node_ui`(`key`,`description`,`description_en`,`lable_name`,`lable_name_en`,`ui_type`,`required`,`value`,`default_value`,`is_hidden`,`condition`,`is_advanced`,`order`,`node_menu_type`,`is_base_info`,`position`)
25+
select 'sendFeishu','请选择是否发送飞书','Please choose whether to send Feishu message','是否发送飞书','Send Feishu','Select',0,'["true","false"]','false',0,NULL,0,1,1,0,'runtime'
26+
where @sendemail_node_ui_send_feishu is null;
27+
select @sendemail_node_ui_send_feishu:=id from `dss_workflow_node_ui` where `key` = 'sendFeishu' limit 1;
28+
29+
select @sendemail_node_ui_feishu_to:=id from `dss_workflow_node_ui` where `key` = 'feishuTo' limit 1;
30+
insert into `dss_workflow_node_ui`(`key`,`description`,`description_en`,`lable_name`,`lable_name_en`,`ui_type`,`required`,`value`,`default_value`,`is_hidden`,`condition`,`is_advanced`,`order`,`node_menu_type`,`is_base_info`,`position`)
31+
select 'feishuTo','请填写飞书接收人英文名,多个用英文分号分隔','Please enter Feishu receiver name, separated by semicolons','飞书接收人','Feishu To','Input',0,NULL,NULL,0,NULL,0,1,1,0,'runtime'
32+
where @sendemail_node_ui_feishu_to is null;
33+
select @sendemail_node_ui_feishu_to:=id from `dss_workflow_node_ui` where `key` = 'feishuTo' limit 1;
34+
2335
-- 查找节点所属组的id
2436
select @sendemail_node_groupId:=id from `dss_workflow_node_group` where `name` = '数据输出';
2537

@@ -49,3 +61,5 @@ INSERT INTO `dss_workflow_node_to_ui`(`workflow_node_id`,`ui_id`) values (@sende
4961
INSERT INTO `dss_workflow_node_to_ui`(`workflow_node_id`,`ui_id`) values (@sendemail_nodeId, @sendemail_node_ui_lable_name_9);
5062
INSERT INTO `dss_workflow_node_to_ui`(`workflow_node_id`,`ui_id`) values (@sendemail_nodeId, @sendemail_node_ui_lable_name_10);
5163
INSERT INTO `dss_workflow_node_to_ui`(`workflow_node_id`,`ui_id`) values (@sendemail_nodeId, @sendemail_node_ui_lable_name_11);
64+
INSERT INTO `dss_workflow_node_to_ui`(`workflow_node_id`,`ui_id`) values (@sendemail_nodeId, @sendemail_node_ui_send_feishu);
65+
INSERT INTO `dss_workflow_node_to_ui`(`workflow_node_id`,`ui_id`) values (@sendemail_nodeId, @sendemail_node_ui_feishu_to);

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/SendEmailRefExecutionOperation.scala

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.webank.wedatasphere.dss.appconn.sendemail
1919
import java.util
2020

2121
import com.webank.wedatasphere.dss.appconn.sendemail.conf.SendEmailAppConnInstanceConfiguration
22+
import com.webank.wedatasphere.dss.appconn.sendemail.feishu.FeishuMessageSender
2223
import com.webank.wedatasphere.dss.standard.app.development.listener.ref.ExecutionResponseRef.ExecutionResponseRefBuilder
2324
import com.webank.wedatasphere.dss.standard.app.development.listener.ref.{ExecutionResponseRef, RefExecutionRequestRef}
2425
import com.webank.wedatasphere.dss.standard.app.development.operation.{AbstractDevelopmentOperation, RefExecutionOperation}
@@ -63,9 +64,28 @@ class SendEmailRefExecutionOperation
6364
return putErrorMsg(t.getMessage, t)
6465
}
6566
Utils.tryCatch {
67+
// Step1: send email
6668
emailSender.send(email)
67-
new ExecutionResponseRefBuilder().success()
68-
}(putErrorMsg("发送邮件失败!", _))
69+
} { t =>
70+
return putErrorMsg("发送邮件失败!", t)
71+
}
72+
73+
// Step 2: Send to Feishu (optional, controlled by node runtime parameter and feishuTo field)
74+
val runtimeMap = requestRef.getExecutionRequestRefContext.getRuntimeMap
75+
val sendFeishu = Option(runtimeMap.get("sendFeishu")).exists(_.toString.equalsIgnoreCase("true"))
76+
if (sendFeishu && email.getFeishuTo != null && email.getFeishuTo.trim.nonEmpty) {
77+
logger.info(s"Feishu sending is selected and feishuTo is configured: ${email.getFeishuTo}")
78+
Utils.tryCatch {
79+
FeishuMessageSender.send(email)
80+
logger.info("Feishu sending completed successfully.")
81+
} { t =>
82+
return putErrorMsg("飞书发送失败!", t)
83+
}
84+
} else if (sendFeishu) {
85+
logger.warn("Feishu sending is selected but feishuTo is empty, skip Feishu sending.")
86+
}
87+
88+
new ExecutionResponseRefBuilder().success()
6989
}
7090

7191
protected def putErrorMsg(errorMsg: String, t: Throwable): ExecutionResponseRef = {

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/conf/SendEmailAppConnConfiguration.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,9 @@ object SendEmailAppConnConfiguration {
5656
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.visualis.VisualisEmailInfo," +
5757
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.visualis.MetaBaseEmailInfo," +
5858
"com.webank.wedatasphere.dss.appconn.sendemail.hook.entity.mlssv2.Mlssv2EmailInfo")
59+
60+
// Feishu integration configuration
61+
val FEISHU_APP_ID = CommonVars("wds.dss.appconn.feishu.app.id", "")
62+
val FEISHU_APP_SECRET = CommonVars("wds.dss.appconn.feishu.app.secret", "")
63+
val FEISHU_API_BASE_URL = CommonVars("wds.dss.appconn.feishu.api.base.url", "https://open.feishu.cn/open-apis")
5964
}

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/email/domain/AbstractEmail.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class AbstractEmail extends Email {
3030
private var cc: String = _
3131
private var bcc: String = _
3232
private var emialType: String = _
33+
private var feishuTo: String = _
3334

3435
override def getContent: String = content
3536
override def setContent(content: String): Unit = this.content = content
@@ -56,4 +57,7 @@ class AbstractEmail extends Email {
5657

5758
override def getEmailType: String = emialType
5859
override def setEmailType(emailType: String): Unit = this.emialType = emailType
60+
61+
override def getFeishuTo: String = feishuTo
62+
override def setFeishuTo(feishuTo: String): Unit = this.feishuTo = feishuTo
5963
}

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/email/generate/AbstractEmailGenerator.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ trait AbstractEmailGenerator extends EmailGenerator with Logging{
6868
email.setFrom(from)
6969
val to = if (runtimeMap.get("to") != null) runtimeMap.get("to").toString else ""
7070
email.setTo(to)
71+
val feishuTo = if (runtimeMap.get("feishuTo") != null) runtimeMap.get("feishuTo").toString else ""
72+
email.setFeishuTo(feishuTo)
7173
}
7274

7375
protected def generateEmailContent(requestRef: RefExecutionRequestRef.RefExecutionRequestRefImpl, email: AbstractEmail): Unit

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/feishu/FeishuConfig.scala

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,22 @@ import org.apache.linkis.common.utils.Logging
2525
*/
2626
object FeishuConfig extends Logging {
2727

28-
def isEnabled: Boolean = SendEmailAppConnConfiguration.FEISHU_ENABLED.getValue
29-
3028
def getAppId: String = SendEmailAppConnConfiguration.FEISHU_APP_ID.getValue
3129

3230
def getAppSecret: String = SendEmailAppConnConfiguration.FEISHU_APP_SECRET.getValue
3331

3432
def getApiBaseUrl: String = SendEmailAppConnConfiguration.FEISHU_API_BASE_URL.getValue
3533

3634
def validate(): Unit = {
37-
if (isEnabled) {
38-
if (getAppId.isEmpty) {
39-
throw new IllegalArgumentException("Feishu is enabled but app.id is not configured. " +
40-
"Please set wds.dss.appconn.feishu.app.id in appconn.properties.")
41-
}
42-
if (getAppSecret.isEmpty) {
43-
throw new IllegalArgumentException("Feishu is enabled but app.secret is not configured. " +
44-
"Please set wds.dss.appconn.feishu.app.secret in appconn.properties.")
45-
}
46-
logger.info(s"Feishu integration is enabled. App ID: ${getAppId}, API Base URL: ${getApiBaseUrl}")
47-
} else {
48-
logger.info("Feishu integration is disabled.")
35+
if (getAppId.isEmpty) {
36+
throw new IllegalArgumentException("Feishu app.id is not configured. " +
37+
"Please set wds.dss.appconn.feishu.app.id in appconn.properties.")
38+
}
39+
if (getAppSecret.isEmpty) {
40+
throw new IllegalArgumentException("Feishu app.secret is not configured. " +
41+
"Please set wds.dss.appconn.feishu.app.secret in appconn.properties.")
4942
}
43+
logger.info(s"Feishu integration config validated. App ID: ${getAppId}, API Base URL: ${getApiBaseUrl}")
5044
}
5145

5246
}

dss-appconn/appconns/dss-sendemail-appconn/sendemail-appconn-core/src/main/scala/com/webank/wedatasphere/dss/appconn/sendemail/feishu/FeishuMessageSender.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ object FeishuMessageSender extends Logging {
4343
// Validate Feishu configuration
4444
FeishuConfig.validate()
4545

46-
// Parse receiver IDs (comma separated)
47-
val receivers = feishuTo.split(",").map(_.trim).filter(_.nonEmpty)
46+
// Parse receiver IDs (semicolon separated)
47+
val receivers = feishuTo.split(";").map(_.trim).filter(_.nonEmpty)
4848
if (receivers.isEmpty) {
4949
logger.warn("No valid Feishu receiver IDs found, skip Feishu sending.")
5050
return

0 commit comments

Comments
 (0)