mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-30 18:24:03 +00:00
Merge pull request #1509 from chakflying/feat/mqtt-optional-message
Feat: Allow MQTT successMessage to be optional
This commit is contained in:
commit
e2c45f93bf
3 changed files with 5 additions and 4 deletions
|
@ -721,6 +721,7 @@ try {
|
||||||
bean.pushToken = monitor.pushToken;
|
bean.pushToken = monitor.pushToken;
|
||||||
bean.proxyId = Number.isInteger(monitor.proxyId) ? monitor.proxyId : null;
|
bean.proxyId = Number.isInteger(monitor.proxyId) ? monitor.proxyId : null;
|
||||||
bean.mqttUsername = monitor.mqttUsername;
|
bean.mqttUsername = monitor.mqttUsername;
|
||||||
|
bean.mqttPassword = monitor.mqttPassword;
|
||||||
bean.mqttTopic = monitor.mqttTopic;
|
bean.mqttTopic = monitor.mqttTopic;
|
||||||
bean.mqttSuccessMessage = monitor.mqttSuccessMessage;
|
bean.mqttSuccessMessage = monitor.mqttSuccessMessage;
|
||||||
|
|
||||||
|
|
|
@ -135,10 +135,10 @@ exports.mqttAsync = function (hostname, topic, okMessage, options = {}) {
|
||||||
if (messageTopic == topic) {
|
if (messageTopic == topic) {
|
||||||
client.end();
|
client.end();
|
||||||
clearTimeout(timeoutID);
|
clearTimeout(timeoutID);
|
||||||
if (message.toString() === okMessage) {
|
if (okMessage != null && okMessage !== "" && message.toString() !== okMessage) {
|
||||||
resolve(`Topic: ${messageTopic}; Message: ${message.toString()}`);
|
reject(new Error(`Message Mismatch - Topic: ${messageTopic}; Message: ${message.toString()}`));
|
||||||
} else {
|
} else {
|
||||||
reject(new Error(`Error; Topic: ${messageTopic}; Message: ${message.toString()}`));
|
resolve(`Topic: ${messageTopic}; Message: ${message.toString()}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -141,7 +141,7 @@
|
||||||
|
|
||||||
<div class="my-3">
|
<div class="my-3">
|
||||||
<label for="mqttSuccessMessage" class="form-label">MQTT {{ $t("successMessage") }}</label>
|
<label for="mqttSuccessMessage" class="form-label">MQTT {{ $t("successMessage") }}</label>
|
||||||
<input id="mqttSuccessMessage" v-model="monitor.mqttSuccessMessage" type="text" class="form-control" required>
|
<input id="mqttSuccessMessage" v-model="monitor.mqttSuccessMessage" type="text" class="form-control">
|
||||||
<div class="form-text">
|
<div class="form-text">
|
||||||
{{ $t("successMessageExplanation") }}
|
{{ $t("successMessageExplanation") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue