allow trailing "*" as wildcard for circuit and name in /list topic
This commit is contained in:
committed by
John-Michael Baier
parent
5e97d0864d
commit
6168af1f5a
@@ -647,9 +647,21 @@ void MqttHandler::notifyTopic(const string& topic, const string& data) {
|
|||||||
if (isList) {
|
if (isList) {
|
||||||
logOtherInfo("mqtt", "received list topic for %s %s", circuit.c_str(), name.c_str());
|
logOtherInfo("mqtt", "received list topic for %s %s", circuit.c_str(), name.c_str());
|
||||||
deque<Message*> messages;
|
deque<Message*> messages;
|
||||||
m_messages->findAll(circuit, name, m_levels, true, true, true, true, true, true, 0, 0, false, &messages);
|
bool circuitPrefix = circuit.length()>0 && circuit.find_last_of('*')==circuit.length()-1;
|
||||||
|
if (circuitPrefix) {
|
||||||
|
circuit = circuit.substr(0, circuit.length()-1);
|
||||||
|
}
|
||||||
|
bool namePrefix = name.length()>0 && name.find_last_of('*')==name.length()-1;
|
||||||
|
if (namePrefix) {
|
||||||
|
name = name.substr(0, name.length()-1);
|
||||||
|
}
|
||||||
|
m_messages->findAll(circuit, name, m_levels, !(circuitPrefix || namePrefix), true, true, true, true, true, 0, 0, false, &messages);
|
||||||
bool onlyWithData = !data.empty();
|
bool onlyWithData = !data.empty();
|
||||||
for (const auto message : messages) {
|
for (const auto message : messages) {
|
||||||
|
if (circuitPrefix && (message->getCircuit().substr(0, circuit.length())!=circuit || !namePrefix && name.length()>0 && message->getName()!=name)
|
||||||
|
|| namePrefix && (message->getName().substr(0, name.length())!=name || !circuitPrefix && circuit.length()>0 && message->getCircuit()!=circuit)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
time_t lastup = message->getLastUpdateTime();
|
time_t lastup = message->getLastUpdateTime();
|
||||||
if (onlyWithData && lastup == 0) {
|
if (onlyWithData && lastup == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user