@rmdes/indiekit-endpoint-conversations 2.1.1 → 2.1.2

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.
@@ -323,6 +323,16 @@ async function pollActivityPub(indiekit, stateCollection, state) {
323
323
 
324
324
  if (!ap_activities) return;
325
325
 
326
+ // Resolve the site URL so we only store interactions about OUR content.
327
+ // indiekit may be the Indiekit class (from startPolling) or the
328
+ // application object (from triggerPoll via controller).
329
+ const siteUrl = (
330
+ indiekit.publication?.me ||
331
+ indiekit.url ||
332
+ process.env.PUBLICATION_URL ||
333
+ ""
334
+ ).replace(/\/$/, "");
335
+
326
336
  const result = await fetchActivityPubInteractions({
327
337
  ap_activities,
328
338
  ap_followers,
@@ -330,22 +340,30 @@ async function pollActivityPub(indiekit, stateCollection, state) {
330
340
  });
331
341
 
332
342
  let stored = 0;
343
+ let skipped = 0;
333
344
 
334
345
  for (const interaction of result.items) {
335
- if (interaction.canonical_url) {
336
- await upsertConversationItem(indiekit, {
337
- canonical_url: interaction.canonical_url,
338
- source: "activitypub",
339
- type: interaction.type,
340
- author: interaction.author,
341
- content: interaction.content,
342
- url: interaction.url,
343
- bridgy_url: null,
344
- platform_id: interaction.platform_id,
345
- created_at: interaction.created_at,
346
- });
347
- stored++;
346
+ if (!interaction.canonical_url) continue;
347
+
348
+ // Only store interactions targeting our own content — skip activities
349
+ // about posts on other domains (e.g. forwarded via shared inbox).
350
+ if (siteUrl && !interaction.canonical_url.startsWith(siteUrl)) {
351
+ skipped++;
352
+ continue;
348
353
  }
354
+
355
+ await upsertConversationItem(indiekit, {
356
+ canonical_url: interaction.canonical_url,
357
+ source: "activitypub",
358
+ type: interaction.type,
359
+ author: interaction.author,
360
+ content: interaction.content,
361
+ url: interaction.url,
362
+ bridgy_url: null,
363
+ platform_id: interaction.platform_id,
364
+ created_at: interaction.created_at,
365
+ });
366
+ stored++;
349
367
  }
350
368
 
351
369
  // Update cursor and status
@@ -363,9 +381,9 @@ async function pollActivityPub(indiekit, stateCollection, state) {
363
381
  { upsert: true },
364
382
  );
365
383
 
366
- if (stored > 0) {
384
+ if (stored > 0 || skipped > 0) {
367
385
  console.info(
368
- `[Conversations] ActivityPub: stored ${stored}/${result.items.length} interactions`,
386
+ `[Conversations] ActivityPub: stored ${stored}, skipped ${skipped} (not our content) of ${result.items.length} interactions`,
369
387
  );
370
388
  }
371
389
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-conversations",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Conversation aggregation endpoint for Indiekit. Backend enrichment service that polls Mastodon/Bluesky notifications and serves JF2-compatible data for the interactions page.",
5
5
  "keywords": [
6
6
  "indiekit",