@rmdes/indiekit-endpoint-blogroll 1.0.22 → 1.0.23
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/api.js +1 -0
- package/lib/storage/blogs.js +4 -0
- package/lib/sync/feed.js +9 -0
- package/package.json +1 -1
package/lib/controllers/api.js
CHANGED
package/lib/storage/blogs.js
CHANGED
|
@@ -110,6 +110,7 @@ export async function createBlog(application, data) {
|
|
|
110
110
|
author: data.author || null,
|
|
111
111
|
status: "active",
|
|
112
112
|
lastFetchAt: null,
|
|
113
|
+
lastItemAt: null,
|
|
113
114
|
lastError: null,
|
|
114
115
|
itemCount: 0,
|
|
115
116
|
pinned: data.pinned || false,
|
|
@@ -200,6 +201,7 @@ export async function updateBlogStatus(application, id, status) {
|
|
|
200
201
|
if (status.itemCount !== undefined) {
|
|
201
202
|
update.itemCount = status.itemCount;
|
|
202
203
|
}
|
|
204
|
+
if (status.lastItemAt) update.lastItemAt = status.lastItemAt;
|
|
203
205
|
if (status.title) update.title = status.title;
|
|
204
206
|
if (status.photo) update.photo = status.photo;
|
|
205
207
|
if (status.siteUrl) update.siteUrl = status.siteUrl;
|
|
@@ -289,6 +291,7 @@ export async function upsertBlog(application, data) {
|
|
|
289
291
|
if (data.skipItemFetch !== undefined) setFields.skipItemFetch = data.skipItemFetch;
|
|
290
292
|
if (data.photo !== undefined) setFields.photo = data.photo;
|
|
291
293
|
if (data.lastFetchAt !== undefined) setFields.lastFetchAt = data.lastFetchAt;
|
|
294
|
+
if (data.lastItemAt !== undefined) setFields.lastItemAt = data.lastItemAt;
|
|
292
295
|
if (data.status !== undefined) setFields.status = data.status;
|
|
293
296
|
|
|
294
297
|
// $setOnInsert only for fields NOT already in $set (avoids MongoDB path conflicts)
|
|
@@ -312,6 +315,7 @@ export async function upsertBlog(application, data) {
|
|
|
312
315
|
if (!("skipItemFetch" in setFields)) insertDefaults.skipItemFetch = false;
|
|
313
316
|
if (!("photo" in setFields)) insertDefaults.photo = null;
|
|
314
317
|
if (!("lastFetchAt" in setFields)) insertDefaults.lastFetchAt = null;
|
|
318
|
+
if (!("lastItemAt" in setFields)) insertDefaults.lastItemAt = null;
|
|
315
319
|
if (!("status" in setFields)) insertDefaults.status = "active";
|
|
316
320
|
|
|
317
321
|
const result = await collection.updateOne(
|
package/lib/sync/feed.js
CHANGED
|
@@ -307,10 +307,19 @@ export async function syncBlogItems(application, blog, options = {}) {
|
|
|
307
307
|
if (result.upserted) added++;
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
// Compute newest item publish date
|
|
311
|
+
let newestDate = null;
|
|
312
|
+
for (const item of feed.items) {
|
|
313
|
+
if (item.published && (!newestDate || item.published > newestDate)) {
|
|
314
|
+
newestDate = item.published;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
310
318
|
// Update blog metadata
|
|
311
319
|
const updateData = {
|
|
312
320
|
success: true,
|
|
313
321
|
itemCount: feed.items.length,
|
|
322
|
+
lastItemAt: newestDate,
|
|
314
323
|
};
|
|
315
324
|
|
|
316
325
|
// Update title if not manually set (still has feedUrl as title)
|