Fix id replacement not assigning id if no notification has it

In previous releases when a replace request came in with an id that
doesn't exist we created a new notification with it anyway.
This is used by some to imitate the behaviour of `stack_tag` and while
not recommended (as it will break if another notification gets assigned
that id) we want to avoid such subtle breakages without consideration.

This bug was introduced in d879d70da060ea78fe735d62249a0afdf3e61bc8.
This commit is contained in:
Nikos Tsipinakis 2018-11-15 13:42:05 +02:00 committed by Benedikt Heine
parent 28f30d182b
commit 5f3960b171

View File

@ -124,8 +124,6 @@ static bool queues_notification_is_ready(const struct notification *n, bool full
/* see queues.h */
int queues_notification_insert(struct notification *n)
{
bool inserted = false;
/* do not display the message, if the message is empty */
if (STR_EMPTY(n->msg)) {
if (settings.always_run_script) {
@ -148,15 +146,23 @@ int queues_notification_insert(struct notification *n)
return 0;
}
if (!inserted && n->id != 0 && queues_notification_replace_id(n))
bool inserted = false;
if (n->id != 0) {
if (!queues_notification_replace_id(n)) {
// Requested id was not valid, but play nice and assign it anyway
g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL);
}
inserted = true;
else
} else {
n->id = ++next_notification_id;
}
if (!inserted && STR_FULL(n->stack_tag) && queues_stack_by_tag(n))
inserted = true;
if (!inserted && settings.stack_duplicates && queues_stack_duplicate(n))
inserted = true;
if (!inserted)
g_queue_insert_sorted(waiting, n, notification_cmp_data, NULL);