@rmdes/indiekit-endpoint-microsub 1.0.0-beta.10 → 1.0.0-beta.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/storage/feeds.js +15 -2
- package/package.json +1 -1
package/lib/storage/feeds.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
import { ObjectId } from "mongodb";
|
|
7
7
|
|
|
8
|
+
import { deleteItemsForFeed } from "./items.js";
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Get feeds collection from application
|
|
10
12
|
* @param {object} application - Indiekit application
|
|
@@ -122,7 +124,7 @@ export async function updateFeed(application, id, updates) {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/**
|
|
125
|
-
* Delete a feed subscription
|
|
127
|
+
* Delete a feed subscription and all its items
|
|
126
128
|
* @param {object} application - Indiekit application
|
|
127
129
|
* @param {ObjectId|string} channelId - Channel ObjectId
|
|
128
130
|
* @param {string} url - Feed URL
|
|
@@ -133,7 +135,18 @@ export async function deleteFeed(application, channelId, url) {
|
|
|
133
135
|
const objectId =
|
|
134
136
|
typeof channelId === "string" ? new ObjectId(channelId) : channelId;
|
|
135
137
|
|
|
136
|
-
|
|
138
|
+
// Find the feed first to get its ID for cascade delete
|
|
139
|
+
const feed = await collection.findOne({ channelId: objectId, url });
|
|
140
|
+
if (!feed) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Delete all items from this feed
|
|
145
|
+
const itemsDeleted = await deleteItemsForFeed(application, feed._id);
|
|
146
|
+
console.info(`[Microsub] Deleted ${itemsDeleted} items from feed ${url}`);
|
|
147
|
+
|
|
148
|
+
// Delete the feed itself
|
|
149
|
+
const result = await collection.deleteOne({ _id: feed._id });
|
|
137
150
|
return result.deletedCount > 0;
|
|
138
151
|
}
|
|
139
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-microsub",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "Microsub endpoint for Indiekit. Enables subscribing to feeds and reading content using the Microsub protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|