Notification grace period - bugfix

NotificationGracePeriodService.inGracePeriod() method does not update cache if lastEventTime.isPresent() is true, but the period is over.
I would suggest the following change:

public boolean inGracePeriod(EventDefinition definition, String notificationId, Event event) {
    if (definition.notificationSettings().gracePeriodMs() <= 0) {
        return false;
    }
    final Optional<DateTime> lastEventTime = get(definition.id(), notificationId, event.toDto().key());
    final boolean isInGracePeriod = lastEventTime.isPresent() ?
            lastEventTime.get().isAfter(event.getEventTimestamp().minus(definition.notificationSettings().gracePeriodMs())) :
            false;
    put(definition.id(), notificationId, event.toDto().key(), event.getEventTimestamp());
    return isInGracePeriod;
}

Regards,

SM

do you mind opening a pull request over at github?

feel free to do anything you like.
i just solved my problem.

ср, 6 мая 2020 г., 17:23 Jan Doberstein via Graylog Community <graylog@discoursemail.com>:

Thank you @sergei.melnichenko for the fix. :slight_smile:
You can track it’s progress here: https://github.com/Graylog2/graylog2-server/pull/8067

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.