Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotifierObserver sets continued=false for the last message to be sent #137

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions model/NotifierObserver.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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
Expand Down Expand Up @@ -102,14 +103,16 @@ 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])) {
foreach ($extraData[$id] as $key => $val) {
$message[$key] = $val;
}
}
$index++;
self::send($topic, $message);
}
}
Expand Down Expand Up @@ -140,15 +143,16 @@ 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])) {
foreach ($extraData[$id] as $key => $val) {
$message[$key] = $val;
}
}

$index++;
self::send("api-key:$apiKeyID", $message);
}
}
Expand Down