MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / isLuckmailMailNewerThanCursor

Function isLuckmailMailNewerThanCursor

luckmail-utils.js:259–289  ·  view source on GitHub ↗
(mail = {}, cursor = {})

Source from the content-addressed store, hash-verified

257 }
258
259 function isLuckmailMailNewerThanCursor(mail = {}, cursor = {}) {
260 const normalizedMail = normalizeLuckmailTokenMail(mail);
261 const normalizedCursor = normalizeLuckmailMailCursor(cursor);
262
263 if (!normalizedCursor.messageId && !normalizedCursor.receivedAt) {
264 return true;
265 }
266
267 if (normalizedMail.message_id && normalizedCursor.messageId && normalizedMail.message_id === normalizedCursor.messageId) {
268 return false;
269 }
270
271 const mailTimestamp = normalizeTimestamp(normalizedMail.received_at);
272 const cursorTimestamp = normalizeTimestamp(normalizedCursor.receivedAt);
273
274 if (mailTimestamp && cursorTimestamp) {
275 if (mailTimestamp > cursorTimestamp) return true;
276 if (mailTimestamp < cursorTimestamp) return false;
277 return Boolean(
278 normalizedMail.message_id
279 && normalizedCursor.messageId
280 && normalizedMail.message_id !== normalizedCursor.messageId
281 );
282 }
283
284 if (normalizedMail.message_id && normalizedCursor.messageId) {
285 return normalizedMail.message_id !== normalizedCursor.messageId;
286 }
287
288 return !cursorTimestamp || Boolean(mailTimestamp && mailTimestamp > cursorTimestamp);
289 }
290
291 function isLuckmailPurchaseExpired(purchase, now = Date.now()) {
292 const normalizedPurchase = normalizeLuckmailPurchase(purchase);

Callers 2

Calls 3

normalizeTimestampFunction · 0.70

Tested by

no test coverage detected