Skip to content

Commit

Permalink
fix: handle LAST dateString correctly in LIST request
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 e0f34e0 commit 2817207
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions relay/src/pubsubHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ async function handleListRequest(dateString, pageSize, from, filter, orbitdb, he
let nameOps;
console.log("Handling LIST request:", { dateString, pageSize, from, filter });

if (dateString !== "LAST") {
if (dateString === "LAST") {
nameOps = await getLastNameOps(orbitdb, pageSize, from, filter);
} else {
const date = parseDate(dateString);
if (!date) {
publishMessage(helia, "INVALID_DATE_FORMAT", CONTENT_TOPIC);
return;
}
filter = { ...filter, date }; // Add date to the filter object
nameOps = await getLastNameOps(orbitdb, pageSize, from, filter);
}

nameOps = await getLastNameOps(orbitdb, pageSize, from, filter);

if (nameOps.length > 0) {
publishMessage(helia, JSON.stringify(nameOps), CONTENT_TOPIC);
} else {
Expand Down

0 comments on commit 2817207

Please sign in to comment.