@rmdes/indiekit-endpoint-blogroll 1.0.16 → 1.0.17
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/storage/blogs.js +7 -7
- package/lib/storage/items.js +1 -1
- package/lib/storage/sources.js +4 -4
- package/lib/sync/feed.js +8 -4
- package/lib/sync/microsub.js +4 -4
- package/lib/sync/scheduler.js +1 -1
- package/package.json +1 -1
package/lib/storage/blogs.js
CHANGED
|
@@ -86,7 +86,7 @@ export async function getBlogByFeedUrl(application, feedUrl) {
|
|
|
86
86
|
*/
|
|
87
87
|
export async function createBlog(application, data) {
|
|
88
88
|
const collection = getCollection(application);
|
|
89
|
-
const now = new Date();
|
|
89
|
+
const now = new Date().toISOString();
|
|
90
90
|
|
|
91
91
|
const blog = {
|
|
92
92
|
sourceId: data.sourceId ? new ObjectId(data.sourceId) : null,
|
|
@@ -127,7 +127,7 @@ export async function updateBlog(application, id, data) {
|
|
|
127
127
|
|
|
128
128
|
const update = {
|
|
129
129
|
...data,
|
|
130
|
-
updatedAt: new Date(),
|
|
130
|
+
updatedAt: new Date().toISOString(),
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
// Remove fields that shouldn't be updated directly
|
|
@@ -162,8 +162,8 @@ export async function deleteBlog(application, id) {
|
|
|
162
162
|
$set: {
|
|
163
163
|
status: "deleted",
|
|
164
164
|
hidden: true,
|
|
165
|
-
deletedAt: new Date(),
|
|
166
|
-
updatedAt: new Date(),
|
|
165
|
+
deletedAt: new Date().toISOString(),
|
|
166
|
+
updatedAt: new Date().toISOString(),
|
|
167
167
|
},
|
|
168
168
|
}
|
|
169
169
|
);
|
|
@@ -181,12 +181,12 @@ export async function updateBlogStatus(application, id, status) {
|
|
|
181
181
|
const objectId = typeof id === "string" ? new ObjectId(id) : id;
|
|
182
182
|
|
|
183
183
|
const update = {
|
|
184
|
-
updatedAt: new Date(),
|
|
184
|
+
updatedAt: new Date().toISOString(),
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
if (status.success) {
|
|
188
188
|
update.status = "active";
|
|
189
|
-
update.lastFetchAt = new Date();
|
|
189
|
+
update.lastFetchAt = new Date().toISOString();
|
|
190
190
|
update.lastError = null;
|
|
191
191
|
if (status.itemCount !== undefined) {
|
|
192
192
|
update.itemCount = status.itemCount;
|
|
@@ -246,7 +246,7 @@ export async function getCategories(application) {
|
|
|
246
246
|
*/
|
|
247
247
|
export async function upsertBlog(application, data) {
|
|
248
248
|
const collection = getCollection(application);
|
|
249
|
-
const now = new Date();
|
|
249
|
+
const now = new Date().toISOString();
|
|
250
250
|
|
|
251
251
|
// Skip if a blog with this feedUrl was soft-deleted
|
|
252
252
|
const deleted = await collection.findOne({
|
package/lib/storage/items.js
CHANGED
|
@@ -206,7 +206,7 @@ export async function countItems(application, options = {}) {
|
|
|
206
206
|
*/
|
|
207
207
|
export async function upsertItem(application, data) {
|
|
208
208
|
const collection = getCollection(application);
|
|
209
|
-
const now = new Date();
|
|
209
|
+
const now = new Date().toISOString();
|
|
210
210
|
|
|
211
211
|
const result = await collection.updateOne(
|
|
212
212
|
{ blogId: new ObjectId(data.blogId), uid: data.uid },
|
package/lib/storage/sources.js
CHANGED
|
@@ -45,7 +45,7 @@ export async function getSource(application, id) {
|
|
|
45
45
|
*/
|
|
46
46
|
export async function createSource(application, data) {
|
|
47
47
|
const collection = getCollection(application);
|
|
48
|
-
const now = new Date();
|
|
48
|
+
const now = new Date().toISOString();
|
|
49
49
|
|
|
50
50
|
const source = {
|
|
51
51
|
type: data.type, // "opml_url" | "opml_file" | "manual" | "json_feed" | "microsub"
|
|
@@ -80,7 +80,7 @@ export async function updateSource(application, id, data) {
|
|
|
80
80
|
|
|
81
81
|
const update = {
|
|
82
82
|
...data,
|
|
83
|
-
updatedAt: new Date(),
|
|
83
|
+
updatedAt: new Date().toISOString(),
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
// Remove fields that shouldn't be updated directly
|
|
@@ -135,11 +135,11 @@ export async function updateSourceSyncStatus(application, id, status) {
|
|
|
135
135
|
const objectId = typeof id === "string" ? new ObjectId(id) : id;
|
|
136
136
|
|
|
137
137
|
const update = {
|
|
138
|
-
updatedAt: new Date(),
|
|
138
|
+
updatedAt: new Date().toISOString(),
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
if (status.success) {
|
|
142
|
-
update.lastSyncAt = new Date();
|
|
142
|
+
update.lastSyncAt = new Date().toISOString();
|
|
143
143
|
update.lastSyncError = null;
|
|
144
144
|
} else {
|
|
145
145
|
update.lastSyncError = status.error;
|
package/lib/sync/feed.js
CHANGED
|
@@ -142,8 +142,8 @@ function parseJsonFeed(content, feedUrl, maxItems) {
|
|
|
142
142
|
text: item.content_text,
|
|
143
143
|
},
|
|
144
144
|
summary: decodeEntities(item.summary) || truncateText(item.content_text, 300),
|
|
145
|
-
published: item.date_published ? new Date(item.date_published) : new Date(),
|
|
146
|
-
updated: item.date_modified ? new Date(item.date_modified) : undefined,
|
|
145
|
+
published: item.date_published ? new Date(item.date_published).toISOString() : new Date().toISOString(),
|
|
146
|
+
updated: item.date_modified ? new Date(item.date_modified).toISOString() : undefined,
|
|
147
147
|
author: item.author || (item.authors?.[0]),
|
|
148
148
|
photo: item.image ? [item.image] : undefined,
|
|
149
149
|
categories: item.tags || [],
|
|
@@ -168,6 +168,10 @@ function parseJsonFeed(content, feedUrl, maxItems) {
|
|
|
168
168
|
function normalizeItem(item, feedUrl) {
|
|
169
169
|
const description = item.description || item.summary || "";
|
|
170
170
|
|
|
171
|
+
// Convert dates to ISO strings - feedparser returns Date objects
|
|
172
|
+
const published = item.pubdate || item.date;
|
|
173
|
+
const updated = item.date;
|
|
174
|
+
|
|
171
175
|
return {
|
|
172
176
|
uid: generateUid(feedUrl, item.guid || item.link),
|
|
173
177
|
url: item.link || item.origlink,
|
|
@@ -177,8 +181,8 @@ function normalizeItem(item, feedUrl) {
|
|
|
177
181
|
text: stripHtml(description),
|
|
178
182
|
},
|
|
179
183
|
summary: truncateText(stripHtml(item.summary || description), 300),
|
|
180
|
-
published:
|
|
181
|
-
updated:
|
|
184
|
+
published: published ? (published instanceof Date ? published.toISOString() : new Date(published).toISOString()) : new Date().toISOString(),
|
|
185
|
+
updated: updated ? (updated instanceof Date ? updated.toISOString() : new Date(updated).toISOString()) : undefined,
|
|
182
186
|
author: item.author ? { name: item.author } : undefined,
|
|
183
187
|
photo: extractPhotos(item),
|
|
184
188
|
categories: item.categories || [],
|
package/lib/sync/microsub.js
CHANGED
|
@@ -100,8 +100,8 @@ export async function syncMicrosubSource(application, source) {
|
|
|
100
100
|
$set: {
|
|
101
101
|
status: "deleted",
|
|
102
102
|
hidden: true,
|
|
103
|
-
deletedAt: new Date(),
|
|
104
|
-
updatedAt: new Date(),
|
|
103
|
+
deletedAt: new Date().toISOString(),
|
|
104
|
+
updatedAt: new Date().toISOString(),
|
|
105
105
|
},
|
|
106
106
|
}
|
|
107
107
|
);
|
|
@@ -227,8 +227,8 @@ export async function handleMicrosubWebhook(application, data) {
|
|
|
227
227
|
{
|
|
228
228
|
$set: {
|
|
229
229
|
status: "inactive",
|
|
230
|
-
unsubscribedAt: new Date(),
|
|
231
|
-
updatedAt: new Date(),
|
|
230
|
+
unsubscribedAt: new Date().toISOString(),
|
|
231
|
+
updatedAt: new Date().toISOString(),
|
|
232
232
|
},
|
|
233
233
|
}
|
|
234
234
|
);
|
package/lib/sync/scheduler.js
CHANGED