Checkable#ClearAcknowledgement(): OnAcknowledgementCleared() at most once

This commit is contained in:
Alexander A. Klimov 2019-12-05 11:54:33 +01:00
parent 798ea54173
commit da6a9174d1
1 changed files with 15 additions and 1 deletions

View File

@ -138,13 +138,27 @@ void Checkable::AcknowledgeProblem(const String& author, const String& comment,
void Checkable::ClearAcknowledgement(const String& removedBy, const MessageOrigin::Ptr& origin)
{
ObjectLock oLock (this);
bool wasAcked;
if (GetAcknowledgementRaw() == AcknowledgementNone) {
wasAcked = false;
} else {
double expiry = GetAcknowledgementExpiry();
wasAcked = expiry == 0 || expiry >= Utility::GetTime();
}
SetAcknowledgementRaw(AcknowledgementNone);
SetAcknowledgementExpiry(0);
Log(LogInformation, "Checkable")
<< "Acknowledgement cleared for checkable '" << GetName() << "'.";
OnAcknowledgementCleared(this, removedBy, origin);
if (wasAcked) {
OnAcknowledgementCleared(this, removedBy, origin);
}
}
Endpoint::Ptr Checkable::GetCommandEndpoint() const