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

Added option to @Everyone in DingTalk notification method #4712

Closed
wants to merge 11 commits into from
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions server/notification-providers/dingding.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class DingDing extends NotificationProvider {
markdown: {
title: `[${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}`,
text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]} \n> ${heartbeatJSON["msg"]}\n> Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
},

"at": {
"isAtAll": notification.isAtAll === "true"
}
};
if (await this.sendToDingDing(notification, params)) {
Expand Down
6 changes: 6 additions & 0 deletions src/components/notifications/DingDing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<label for="secretKey" class="form-label">{{ $t("SecretKey") }}<span style="color: red;"><sup>*</sup></span></label>
<input id="secretKey" v-model="$parent.notification.secretKey" type="text" class="form-control" required>

<label for="isAtAll" class="form-label">{{ $t("isAtAll") }}<span style="color: red;"><sup>*</sup></span></label>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this to a selection box with the options Don't mention people, Notify <code>@everyone</code> (see https://vue-i18n.intlify.dev/guide/advanced/component.html)
With a selection box, implemneting things like @userId is possible (=> "future-proof")

<select id="isAtAll" v-model="$parent.notification.isAtAll" class="form-select" required>
<option value="false">{{ $t("false") }}</option>
<option value="true">{{ $t("true") }}</option>
</select>
Comment on lines +9 to +13
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I meant was something like this, but

  • with the respective translations in en.json,
  • the respective changes to dingding.js and
  • testing that I did not make a typo in the github webeditor ^^^

What do you think about the label? Is this self-explaiantory enough? Do we need to add an helptext? (would not know what to put there, but still would like to have your oppinon on this one)

Suggested change
<label for="isAtAll" class="form-label">{{ $t("isAtAll") }}<span style="color: red;"><sup>*</sup></span></label>
<select id="isAtAll" v-model="$parent.notification.isAtAll" class="form-select" required>
<option value="false">{{ $t("false") }}</option>
<option value="true">{{ $t("true") }}</option>
</select>
<label for="metioning" class="form-label">{{ $t("Mentioning") }}<span style="color: red;"><sup>*</sup></span></label>
<select id="metioning" v-model="$parent.notification.metioning" class="form-select" required>
<option value="nobody">{{ $t("Don't mention people") }}</option>
<i18n-t keypath="Notify everyone" tag="option" value="@everyone">
<code>@everyone</code>
</i18n-t>
</select>


<div class="form-text">
<p>{{ $t("For safety, must use secret key") }}</p>
<i18n-t tag="p" keypath="Read more:">
Expand Down
3 changes: 3 additions & 0 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@
"WebHookUrl": "WebHookUrl",
"SecretKey": "SecretKey",
"For safety, must use secret key": "For safety, must use secret key",
"isAtAll":"Whether to notify everyone",
"true":"true",
"false":"false",
"Device Token": "Device Token",
"Platform": "Platform",
"Huawei": "Huawei",
Expand Down
3 changes: 3 additions & 0 deletions src/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@
"WebHookUrl": "钉钉自定义机器人 Webhook 地址",
"SecretKey": "钉钉自定义机器人加签密钥",
"For safety, must use secret key": "出于安全考虑,必须使用加签密钥",
"isAtAll":"是否通知所有人",
"true":"是",
"false":"否",
Comment on lines +456 to +458
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent merge conflicts with weblate (more painfull than worth it), we only allow adding translation keys in en.json.
Please translate this after the PR is merged on weblate.kuma.pet

Suggested change
"isAtAll":"是否通知所有人",
"true":"",
"false":"",

"Device Token": "Apple Device Token",
"Platform": "平台",
"Huawei": "华为",
Expand Down
Loading