mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-09 04:40:56 +08:00
Merge pull request #1509 from chakflying/feat/mqtt-optional-message
Feat: Allow MQTT successMessage to be optional
This commit is contained in:
@@ -721,6 +721,7 @@ try {
|
||||
bean.pushToken = monitor.pushToken;
|
||||
bean.proxyId = Number.isInteger(monitor.proxyId) ? monitor.proxyId : null;
|
||||
bean.mqttUsername = monitor.mqttUsername;
|
||||
bean.mqttPassword = monitor.mqttPassword;
|
||||
bean.mqttTopic = monitor.mqttTopic;
|
||||
bean.mqttSuccessMessage = monitor.mqttSuccessMessage;
|
||||
|
||||
|
@@ -135,10 +135,10 @@ exports.mqttAsync = function (hostname, topic, okMessage, options = {}) {
|
||||
if (messageTopic == topic) {
|
||||
client.end();
|
||||
clearTimeout(timeoutID);
|
||||
if (message.toString() === okMessage) {
|
||||
resolve(`Topic: ${messageTopic}; Message: ${message.toString()}`);
|
||||
if (okMessage != null && okMessage !== "" && message.toString() !== okMessage) {
|
||||
reject(new Error(`Message Mismatch - Topic: ${messageTopic}; Message: ${message.toString()}`));
|
||||
} else {
|
||||
reject(new Error(`Error; Topic: ${messageTopic}; Message: ${message.toString()}`));
|
||||
resolve(`Topic: ${messageTopic}; Message: ${message.toString()}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user