@rmdes/indiekit-endpoint-rss 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controllers/dashboard.js +1 -1
- package/lib/sync.js +5 -5
- package/lib/utils.js +17 -4
- package/package.json +1 -1
package/lib/sync.js
CHANGED
|
@@ -93,7 +93,7 @@ export async function runSync(dbOrIndiekit, options) {
|
|
|
93
93
|
const feeds = await feedsCollection.find({ enabled: true }).toArray();
|
|
94
94
|
|
|
95
95
|
if (feeds.length === 0) {
|
|
96
|
-
syncState.lastSync = new Date();
|
|
96
|
+
syncState.lastSync = new Date().toISOString();
|
|
97
97
|
syncState.syncing = false;
|
|
98
98
|
return { feedsProcessed: 0, itemsAdded: 0 };
|
|
99
99
|
}
|
|
@@ -124,7 +124,7 @@ export async function runSync(dbOrIndiekit, options) {
|
|
|
124
124
|
retentionDays,
|
|
125
125
|
);
|
|
126
126
|
|
|
127
|
-
syncState.lastSync = new Date();
|
|
127
|
+
syncState.lastSync = new Date().toISOString();
|
|
128
128
|
syncState.syncing = false;
|
|
129
129
|
|
|
130
130
|
console.log(
|
|
@@ -176,7 +176,7 @@ async function syncFeed(
|
|
|
176
176
|
siteUrl: feedMeta.siteUrl,
|
|
177
177
|
description: feedMeta.description,
|
|
178
178
|
imageUrl: feedMeta.imageUrl,
|
|
179
|
-
lastFetchedAt: new Date(),
|
|
179
|
+
lastFetchedAt: new Date().toISOString(),
|
|
180
180
|
lastError: null,
|
|
181
181
|
},
|
|
182
182
|
}
|
|
@@ -196,7 +196,7 @@ async function syncFeed(
|
|
|
196
196
|
feedId: feed._id,
|
|
197
197
|
feedTitle: feedMeta.title,
|
|
198
198
|
...item,
|
|
199
|
-
fetchedAt: new Date(),
|
|
199
|
+
fetchedAt: new Date().toISOString(),
|
|
200
200
|
},
|
|
201
201
|
},
|
|
202
202
|
{ upsert: true }
|
|
@@ -230,7 +230,7 @@ async function syncFeed(
|
|
|
230
230
|
{ _id: feed._id },
|
|
231
231
|
{
|
|
232
232
|
$set: {
|
|
233
|
-
lastFetchedAt: new Date(),
|
|
233
|
+
lastFetchedAt: new Date().toISOString(),
|
|
234
234
|
lastError: lastError,
|
|
235
235
|
},
|
|
236
236
|
}
|
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import sanitizeHtmlLib from "sanitize-html";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Ensure a value is an ISO 8601 date string.
|
|
5
|
+
* Handles both Date objects (old MongoDB data) and strings (new data).
|
|
6
|
+
* @param {*} value - Date object, ISO string, or null
|
|
7
|
+
* @returns {string|null} ISO string or null
|
|
8
|
+
*/
|
|
9
|
+
function toISO(value) {
|
|
10
|
+
if (!value) return null;
|
|
11
|
+
if (value instanceof Date) return value.toISOString();
|
|
12
|
+
if (typeof value === "string") return value;
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
/**
|
|
4
17
|
* Sanitize HTML content - strip dangerous tags, keep basic formatting
|
|
5
18
|
* @param {string} html - Raw HTML
|
|
@@ -116,10 +129,10 @@ export function formatItem(item, options = {}) {
|
|
|
116
129
|
link: item.link,
|
|
117
130
|
description: description || "",
|
|
118
131
|
author: item.author,
|
|
119
|
-
pubDate: item.pubDate
|
|
132
|
+
pubDate: toISO(item.pubDate),
|
|
120
133
|
imageUrl: item.imageUrl,
|
|
121
134
|
categories: item.categories || [],
|
|
122
|
-
fetchedAt: item.fetchedAt
|
|
135
|
+
fetchedAt: toISO(item.fetchedAt),
|
|
123
136
|
// Source info for aggregators (like FreshRSS) - represents the original feed
|
|
124
137
|
sourceTitle: item.sourceTitle || null,
|
|
125
138
|
sourceUrl: item.sourceUrl || null,
|
|
@@ -155,8 +168,8 @@ export function formatFeed(feed) {
|
|
|
155
168
|
description: feed.description,
|
|
156
169
|
imageUrl: feed.imageUrl,
|
|
157
170
|
enabled: feed.enabled,
|
|
158
|
-
addedAt: feed.addedAt
|
|
159
|
-
lastFetchedAt: feed.lastFetchedAt
|
|
171
|
+
addedAt: toISO(feed.addedAt),
|
|
172
|
+
lastFetchedAt: toISO(feed.lastFetchedAt),
|
|
160
173
|
lastError: feed.lastError,
|
|
161
174
|
itemCount: feed.itemCount || 0,
|
|
162
175
|
};
|
package/package.json
CHANGED