Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feishu #851

Merged
merged 5 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from e47dd6 to 951a8f
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class SendNotification extends TriggerAction {
private static final int UTYPE_ACCOUNT20 = 20; // 外部人员-输入
private static final int UTYPE_WXWORK = 4; // 企微群
private static final int UTYPE_DINGTALK = 5; // 钉钉群
private static final int UTYPE_FEISHU = 6; // 飞书群

public SendNotification(ActionContext context) {
super(context);
Expand Down Expand Up @@ -96,6 +97,8 @@ public Object execute(OperatingContext operatingContext) {
s = sendToWxwork(operatingContext);
} else if (userType == UTYPE_DINGTALK) {
s = sendToDingtalk(operatingContext);
} else if (userType == UTYPE_FEISHU) {
s = sendToFeishu(operatingContext);
} else { // UTYPE_USER
s = sendToUsers(operatingContext);
}
Expand Down Expand Up @@ -211,6 +214,13 @@ private Set<Object> sendToDingtalk(OperatingContext operatingContext) {
return (Set<Object>) resp;
}

@SuppressWarnings("unchecked")
private Set<Object> sendToFeishu(OperatingContext operatingContext) {
Object resp = CommonsUtils.invokeMethod(
"com.rebuild.rbv.trigger.SendNotification2#sendToFeishu", actionContext, operatingContext);
return (Set<Object>) resp;
}

private File[] getMailAttach(final JSONObject content) {
String[] attachFields = getValidDefsFields(content.getJSONArray("attach"));
if (attachFields == null) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public RespBody availableTypes() {
map.put("serviceSms", SMSender.availableSMS());
map.put("serviceWxwork", RebuildConfiguration.get(ConfigurationItem.WxworkCorpid) != null);
map.put("serviceDingtalk", RebuildConfiguration.get(ConfigurationItem.DingtalkRobotCode) != null);
map.put("serviceFeishu", RebuildConfiguration.get(ConfigurationItem.FeishuAppId) != null);
return RespBody.ok(map);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/web/_include/nav-left-admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<li th:class="${active == 'integration-dingtalk'} ? 'active'">
<a th:href="@{/admin/integration/dingtalk}"><span>[[${bundle.L('钉钉')}]]</span> <sup class="rbv"></sup></a>
</li>
<li th:class="${active == 'integration-feishu'} ? 'active'" th:classappend="bosskey-show">
<li th:class="${active == 'integration-feishu'} ? 'active'">
<a th:href="@{/admin/integration/feishu}"><span>[[${bundle.L('飞书')}]]</span> <sup class="rbv"></sup></a>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/admin/integration/feishu.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="col-lg-9 col-12">
<div class="card">
<div class="card-header pb-1">
[[${bundle.L('飞书')}]] (LAB)
[[${bundle.L('飞书')}]]
<a href="###" class="float-right J_edit"><i class="icon zmdi zmdi-edit"></i> [[${bundle.L('修改')}]]</a>
<a href="###" class="float-right J_save hide"><i class="icon zmdi zmdi-check text-bold"></i> [[${bundle.L('保存')}]]</a>
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/web/assets/css/triggers.css
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ textarea.formula-code + .fields-vars {
max-width: 100% !important;
}

.send-notification .nav-tabs .nav-link span.text-danger {
display: none;
font-size: 12px;
}

.send-notification .nav-tabs .nav-link.active span.text-danger {
display: inline-block;
margin-left: 5px;
}

.create-task .user-selector,
.create-task .form-control {
max-width: 100% !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,31 @@ class ContentSendNotification extends ActionContentSpec {
<li className="nav-item">
<a className={`nav-link ${state.type === 2 && 'active'}`} onClick={() => this.setMsgType(2)}>
{$L('邮件')}
{state.serviceMail === false && <span className="text-danger fs-12"> ({$L('不可用')})</span>}
{state.serviceMail === false && <span className="text-danger">({$L('不可用')})</span>}
</a>
</li>
<li className="nav-item">
<a className={`nav-link ${state.type === 3 && 'active'}`} onClick={() => this.setMsgType(3)}>
{$L('短信')}
{state.serviceSms === false && <span className="text-danger fs-12"> ({$L('不可用')})</span>}
{state.serviceSms === false && <span className="text-danger">({$L('不可用')})</span>}
</a>
</li>
<li className="nav-item">
<a className={`nav-link ${state.type === 4 && 'active'}`} onClick={() => this.setMsgType(4)}>
{$L('企业微信群')}
{state.serviceWxwork === false && <span className="text-danger fs-12"> ({$L('不可用')})</span>} <sup className="rbv" />
{state.serviceWxwork === false && <span className="text-danger">({$L('不可用')})</span>} <sup className="rbv" />
</a>
</li>
<li className="nav-item">
<a className={`nav-link ${state.type === 5 && 'active'}`} onClick={() => this.setMsgType(5)}>
{$L('钉钉群')}
{state.serviceDingtalk === false && <span className="text-danger fs-12"> ({$L('不可用')})</span>} <sup className="rbv" />
{state.serviceDingtalk === false && <span className="text-danger">({$L('不可用')})</span>} <sup className="rbv" />
</a>
</li>
<li className="nav-item">
<a className={`nav-link ${state.type === 6 && 'active'}`} onClick={() => this.setMsgType(6)}>
{$L('飞书群')}
{state.serviceFeishu === false && <span className="text-danger">({$L('不可用')})</span>} <sup className="rbv" />
</a>
</li>
</ul>
Expand Down Expand Up @@ -82,6 +88,10 @@ class ContentSendNotification extends ActionContentSpec {
<input className="custom-control-input" name="utype" type="radio" onChange={() => this.setState({ userType: 5 })} checked={state.userType === 5} />
<span className="custom-control-label">{$L('钉钉群')}</span>
</label>
<label className={`custom-control custom-control-sm custom-radio custom-control-inline mb-1 ${state.type === 6 ? '' : 'hide'}`}>
<input className="custom-control-input" name="utype" type="radio" onChange={() => this.setState({ userType: 6 })} checked={state.userType === 6} />
<span className="custom-control-label">{$L('飞书群')}</span>
</label>
</div>
</div>
<div className="form-group row pt-0 mt-0">
Expand All @@ -100,7 +110,7 @@ class ContentSendNotification extends ActionContentSpec {
<p className="form-text">{$L('输入手机/邮箱,多个请使用逗号分开')}</p>
</div>
<div className={state.userType === 4 ? '' : 'hide'}>
<input type="text" className="form-control form-control-sm w-100" ref={(c) => (this._$webhook = c)} style={{ maxWidth: '100%' }} placeholder={$L('群 Webhook 地址')} />
<input type="text" className="form-control form-control-sm w-100" ref={(c) => (this._$webhookWxwork = c)} style={{ maxWidth: '100%' }} placeholder={$L('群 Webhook 地址')} />
<p className="form-text link">
<a href="https://getrebuild.com/docs/admin/trigger/sendnotification#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1%E7%BE%A4%20Webhook%20%E5%9C%B0%E5%9D%80" target="_blank">
{$L('如何获取群 Webhook 地址')}
Expand All @@ -115,6 +125,14 @@ class ContentSendNotification extends ActionContentSpec {
</a>
</p>
</div>
<div className={state.userType === 6 ? '' : 'hide'}>
<input type="text" className="form-control form-control-sm w-100" ref={(c) => (this._$webhookFeishu = c)} style={{ maxWidth: '100%' }} placeholder={$L('群 Webhook 地址')} />
<p className="form-text link">
<a href="https://getrebuild.com/docs/admin/trigger/sendnotification#%E8%8E%B7%E5%8F%96%E9%A3%9E%E4%B9%A6%E7%BE%A4%20Webhook%20%E5%9C%B0%E5%9D%80" target="_blank">
{$L('如何获取群 Webhook 地址')}
</a>
</p>
</div>
</div>
</div>

Expand Down Expand Up @@ -162,9 +180,11 @@ class ContentSendNotification extends ActionContentSpec {
if (content) {
if (content.sendTo) {
if (content.type === 4) {
$(this._$webhook).val(content.sendTo)
$(this._$webhookWxwork).val(content.sendTo)
} else if (content.type === 5) {
$(this._$groupId).val(content.sendTo)
} else if (content.type === 6) {
$(this._$webhookFeishu).val(content.sendTo)
} else if (content.userType === 20) {
$(this._sendTo20).val(content.sendTo)
} else {
Expand Down Expand Up @@ -213,7 +233,7 @@ class ContentSendNotification extends ActionContentSpec {
if (this.state.userType === 20) sendTo = $val(this._sendTo20)

if (this.state.type === 4) {
sendTo = $(this._$webhook).val()
sendTo = $(this._$webhookWxwork).val()
if (!sendTo || !$regex.isUrl(sendTo)) {
RbHighbar.create($L('请输入有效的群 Webhook 地址'))
return false
Expand All @@ -224,6 +244,12 @@ class ContentSendNotification extends ActionContentSpec {
RbHighbar.create($L('请输入群号'))
return false
}
} else if (this.state.type === 6) {
sendTo = $(this._$webhookFeishu).val()
if (!sendTo || !$regex.isUrl(sendTo)) {
RbHighbar.create($L('请输入有效的群 Webhook 地址'))
return false
}
} else {
if ((sendTo || []).length === 0) {
RbHighbar.create($L('请选择发送给谁'))
Expand Down
Loading