send last fetched at as a unix timestamp in ms

This commit is contained in:
Hongbo Wu 2023-07-19 14:09:38 +08:00
parent 234b51af28
commit cd440a77c3
2 changed files with 5 additions and 5 deletions

View file

@ -573,7 +573,7 @@ export const enqueueRssFeedFetch = async (
const payload = {
subscriptionId: rssFeedSubscription.id,
feedUrl: rssFeedSubscription.url,
lastFetchedAt: rssFeedSubscription.lastFetchedAt,
lastFetchedAt: rssFeedSubscription.lastFetchedAt?.getTime() || 0, // unix timestamp in milliseconds
}
const headers = {

View file

@ -9,7 +9,7 @@ import { CONTENT_FETCH_URL, createCloudTask } from './task'
interface RssFeedRequest {
subscriptionId: string
feedUrl: string
lastFetchedAt: string
lastFetchedAt: number // unix timestamp in milliseconds
}
interface ValidRssFeedItem {
@ -180,10 +180,10 @@ export const rssHandler = Sentry.GCPFunction.wrapHttpFunction(
// skip old items and items that were published before 24h
const publishedAt = new Date(item.isoDate)
if (
publishedAt < new Date(Date.now() - 24 * 60 * 60 * 1000) ||
publishedAt < new Date(lastFetchedAt)
publishedAt < new Date(lastFetchedAt) ||
publishedAt < new Date(Date.now() - 24 * 60 * 60 * 1000)
) {
console.log('Skipping old feed item', item.link)
console.log('Skipping old feed item', lastValidItem.link)
continue
}