-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
feat:Allow templating in AliyunSMS #6002
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to allow templating instead of just custom static texts.
Just a staitc custom up/down text is not ideal as you can imagine.
Please see the following PR for the things that need to be changed:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closer, but I am still not quite happy with this
| <label for="msgTemplate" class="form-label">{{ $t("${msg} Template") }}</label> | ||
| <textarea id="msgTemplate" v-model="$parent.notification.msgTemplate" class="form-control" rows="2" placeholder="{% if status == 'UP' %}请查看钉钉{% else %}请及时处理{% endif %}"></textarea> | ||
| </div> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can explain the limitation that templates are fixed and only the content can be changed more clearly.
| <div class="form-check form-switch mb-3"> | ||
| <input id="enableCustomTemplate" v-model="$parent.notification.enableCustomTemplate" class="form-check-input" type="checkbox"> | ||
| <label for="enableCustomTemplate" class="form-check-label">{{ $t("Enable Custom Template") }}</label> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a quick helptext to explain in which circumstances this setting is usefull?
I think currently a lot of people would not know when to use this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, I will add it later.
| <label for="statusTemplate" class="form-label">{{ $t("${status} Template") }}</label> | ||
| <textarea id="statusTemplate" v-model="$parent.notification.statusTemplate" class="form-control" rows="2" placeholder="{% if status == 'UP' %}[在线]{% else %}[故障]{% endif %}"></textarea> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess with the added context that you cannot send a full template, I don't think this makes that much sense anymore to template the status.
Given that aliyun seems to be quite focussed on china, I think simplifying this to just respond with chinese (no translation) is fair.
Alternatively, just providing 3 inputs (up,down,message) are likely better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, as only 4 variables can be sent to aliyun API, my initial solution was to forcefully overwrite the original English fields, allowing users to set them to any content. The content of the SMS is mainly to remind operation and maintenance personnel that there is a serious system failure, prompting them to pay attention in a timely manner.
| <label for="msgTemplate" class="form-label">{{ $t("${msg} Template") }}</label> | ||
| <textarea id="msgTemplate" v-model="$parent.notification.msgTemplate" class="form-control" rows="2" placeholder="{% if status == 'UP' %}请查看钉钉{% else %}请及时处理{% endif %}"></textarea> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't re-invent the weel here.
Use renderTemplate in the backend and TemplatedTextarea in the frontend.
See the PR I linked previously for an usage example


📋 Overview
Enable Custom Variablestoggle to allow full customization of Aliyun SMSnameandmsgvariables and custom UP/DOWN Text .🛠️ Type of change
📄 Checklist
📷 Screenshots or Visual Changes
Aliyun-SMS settingSMS Text