Skip to content

Commit

Permalink
Merge pull request #28 from fledge-iot/1.9.2RC
Browse files Browse the repository at this point in the history
1.9.2RC
  • Loading branch information
dianomicbot authored Oct 4, 2021
2 parents 8ba06b1 + 744f6ef commit 31544c7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
4 changes: 2 additions & 2 deletions C/services/common/notification_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ bool NotificationInstance::handleState(bool evalRet)
else
{
// Try sending "triggered" when evaluation is true
ret = evalRet && (diffTime > nType.retriggerTime);
ret = evalRet && (diffTime >= nType.retriggerTime);
// Here state change depends on sending value
setTriggered = ret;
}
Expand All @@ -689,7 +689,7 @@ bool NotificationInstance::handleState(bool evalRet)
// Set state depends on evalRet
setTriggered = evalRet;
// Try sending "triggered" when evaluation is true
ret = evalRet && diffTime > nType.retriggerTime;
ret = evalRet && diffTime >= nType.retriggerTime;
break;

default:
Expand Down
29 changes: 29 additions & 0 deletions C/services/common/notification_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,32 @@ void NotificationQueue::setSumValues(map<string, ResultData>& result,
}
}

/**
* Add the data that caused the notification to trigger to the reason
* document that will be sent to the notification delivery plugin.
*
* This is a bit of a cheap cheat as we don;t parse the two documents we
* simply use string manipulation. We can do this as these two documents
* are of well done formats.
*
* @param reason The reason JSON document
* @param data The data document
*/
static void addDataToReason(string& reason, const string& data)
{
Logger::getLogger()->debug("Reason is '%s'", reason.c_str());
Logger::getLogger()->debug("Data is '%s'", data.c_str());
auto p = reason.find_last_of("}");
if (p != string::npos)
{
string sstr = reason.substr(0, p);
sstr.append(", \"data\" : ");
sstr.append(data);
sstr.append(" }");
Logger::getLogger()->debug("Reason becomes '%s'", sstr.c_str());
reason = sstr;
}
}

/**
* Deliver notification data
Expand Down Expand Up @@ -1210,6 +1236,9 @@ static void deliverNotification(NotificationRule* rule,
// Call rule "plugin_reason"
string reason = rule->getPlugin()->reason();

// Add the data that trigger the event to the reason document
addDataToReason(reason, data);

// Call delivery "plugin_deliver"
DeliveryPlugin* plugin = instance->getDeliveryPlugin();

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
fledge_version>=1.9
notification_version=1.9.1
notification_version=1.9.2

0 comments on commit 31544c7

Please sign in to comment.