Skip to content

Commit

Permalink
fix: improve LIST request handling for empty nameOps
Browse files Browse the repository at this point in the history
Co-Authored-By: Nico Krause <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and silkroadnomad committed Dec 21, 2024
1 parent 6bb1fd5 commit ead370d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions relay/src/pubsubHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async function handleListRequest(dateString, pageSize, from, filter, orbitdb, he
publishMessage(helia, "LAST_100_CIDS:NONE", CONTENT_TOPIC);
return;
}
publishMessage(helia, JSON.stringify(nameOps), CONTENT_TOPIC);
} else {
const date = parseDate(dateString);
if (!date) {
Expand All @@ -67,12 +68,11 @@ async function handleListRequest(dateString, pageSize, from, filter, orbitdb, he
}
filter = { ...filter, date }; // Add date to the filter object
nameOps = await getLastNameOps(orbitdb, pageSize, from, filter);
}

if (nameOps.length > 0) {
publishMessage(helia, JSON.stringify(nameOps), CONTENT_TOPIC);
} else {
publishMessage(helia, `${dateString}_CIDS:NONE`, CONTENT_TOPIC);
if (nameOps.length > 0) {
publishMessage(helia, JSON.stringify(nameOps), CONTENT_TOPIC);
} else {
publishMessage(helia, `${dateString}_CIDS:NONE`, CONTENT_TOPIC);
}
}
} catch (error) {
logger.error('Error fetching NameOps:', error);
Expand Down

0 comments on commit ead370d

Please sign in to comment.