@@ -64,12 +76,21 @@ export default {
callback()
}
}
+ const validateWechatRobotWebhook = (rule, value, callback) => {
+ if (!value) return callback()
+ if (!value.match(/^https:\/\/qyapi.weixin.qq.com\/cgi-bin\/webhook\/send\?key=.+/i)) {
+ callback(new Error(this.$t('DingTalk Robot Webhook format invalid')))
+ } else {
+ callback()
+ }
+ }
return {
- userInfo: { setting: {} },
+ userInfo: { setting: { enabled_notifications: [] } },
rules: {
password: [{ trigger: 'blur', validator: validatePass }],
email: [{ trigger: 'blur', validator: validateEmail }],
- 'setting.ding_talk_robot_webhook': [{ trigger: 'blur', validator: validateDingTalkRobotWebhook }]
+ 'setting.ding_talk_robot_webhook': [{ trigger: 'blur', validator: validateDingTalkRobotWebhook }],
+ 'setting.wechat_robot_webhook': [{ trigger: 'blur', validator: validateWechatRobotWebhook }]
},
isShowDingTalkAppSecret: false
}
@@ -80,16 +101,12 @@ export default {
if (!data) return {}
this.userInfo = JSON.parse(data)
if (!this.userInfo.setting) this.userInfo.setting = {}
+ if (!this.userInfo.setting.enabled_notifications) this.userInfo.setting.enabled_notifications = []
},
saveUserInfo () {
this.$refs['setting-form'].validate(async valid => {
if (!valid) return
- const res = await this.$store.dispatch('user/postInfo', {
- password: this.userInfo.password,
- email: this.userInfo.email,
- notification_trigger: this.userInfo.setting.notification_trigger,
- ding_talk_robot_webhook: this.userInfo.setting.ding_talk_robot_webhook
- })
+ const res = await this.$store.dispatch('user/postInfo', this.userInfo)
if (!res || res.error) {
this.$message.error(res.error)
} else {