From 8e362cc5d5adef1c7a7afca6ef6381885b7b9e79 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Fri, 5 May 2023 12:46:36 -0400 Subject: [PATCH] NotifierObserver sets continued=false for the last message to be sent --- model/NotifierObserver.inc.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/model/NotifierObserver.inc.php b/model/NotifierObserver.inc.php index 7fbf2ab1..031e097a 100644 --- a/model/NotifierObserver.inc.php +++ b/model/NotifierObserver.inc.php @@ -56,6 +56,8 @@ public static function addMessageReceiver($messageReceiver) { public static function notify($event, $type, $ids, $extraData) { + $index = 0; + $last_index = count($ids) - 1; if ($type == "library" || $type == "publications") { switch ($event) { case "modify": @@ -69,7 +71,6 @@ public static function notify($event, $type, $ids, $extraData) { default: return; } - foreach ($ids as $id) { $libraryID = $id; // For most libraries, get topic from URI @@ -102,7 +103,8 @@ public static function notify($event, $type, $ids, $extraData) { ]; if (self::$continued) { - $message['continued'] = true; + //Set continued=false for the last item + $message['continued'] = ($index != $last_index); } if (!empty($extraData[$id])) { @@ -110,6 +112,7 @@ public static function notify($event, $type, $ids, $extraData) { $message[$key] = $val; } } + $index++; self::send($topic, $message); } } @@ -140,7 +143,8 @@ public static function notify($event, $type, $ids, $extraData) { ]; if (self::$continued) { - $message['continued'] = true; + //Set continued=false for the last item + $message['continued'] = ($index != $last_index); } if (!empty($extraData[$id])) { @@ -148,7 +152,7 @@ public static function notify($event, $type, $ids, $extraData) { $message[$key] = $val; } } - + $index++; self::send("api-key:$apiKeyID", $message); } }