@rmdes/indiekit-endpoint-activitypub 3.13.3 → 3.13.4

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.
@@ -19,19 +19,32 @@ export async function cleanupTimeline(collections, retentionLimit) {
19
19
  return { removed: 0, interactionsRemoved: 0 };
20
20
  }
21
21
 
22
- const totalCount = await collections.ap_timeline.countDocuments();
23
- if (totalCount <= retentionLimit) {
22
+ // Get the local profile URL to exempt own posts from cleanup.
23
+ // Own posts are your content — they should never be deleted by retention.
24
+ const profile = collections.ap_profile
25
+ ? await collections.ap_profile.findOne({})
26
+ : null;
27
+ const ownerUrl = profile?.url || null;
28
+
29
+ // Only count remote posts toward retention limit
30
+ const remoteFilter = ownerUrl
31
+ ? { "author.url": { $ne: ownerUrl } }
32
+ : {};
33
+ const remoteCount = await collections.ap_timeline.countDocuments(remoteFilter);
34
+ if (remoteCount <= retentionLimit) {
24
35
  return { removed: 0, interactionsRemoved: 0 };
25
36
  }
26
37
 
27
- // Use aggregation to get exact UIDs beyond the retention limit.
28
- // This avoids race conditions: we delete by UID, not by date.
38
+ // Find remote items beyond the retention limit, sorted newest-first.
39
+ // Own posts are excluded from the aggregation pipeline entirely.
40
+ const pipeline = [
41
+ ...(ownerUrl ? [{ $match: { "author.url": { $ne: ownerUrl } } }] : []),
42
+ { $sort: { published: -1 } },
43
+ { $skip: retentionLimit },
44
+ { $project: { uid: 1 } },
45
+ ];
29
46
  const toDelete = await collections.ap_timeline
30
- .aggregate([
31
- { $sort: { published: -1 } },
32
- { $skip: retentionLimit },
33
- { $project: { uid: 1 } },
34
- ])
47
+ .aggregate(pipeline)
35
48
  .toArray();
36
49
 
37
50
  if (!toDelete.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "3.13.3",
3
+ "version": "3.13.4",
4
4
  "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
5
5
  "keywords": [
6
6
  "indiekit",