@rmdes/indiekit-endpoint-conversations 2.1.3 → 2.1.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.
@@ -100,10 +100,12 @@ export async function runPollCycle(indiekit, options) {
100
100
  }
101
101
 
102
102
  /**
103
- * Backfill empty author.photo fields in conversation_items using ap_notifications.
104
- * The AP endpoint stores actorPhoto in notifications for all interactions,
105
- * so we can use those to enrich conversation_items that were stored before
106
- * the actorAvatar field was added to ap_activities.
103
+ * Backfill empty author.photo fields in conversation_items.
104
+ * Tries four strategies in order:
105
+ * 1. ap_notifications (actorPhoto)
106
+ * 2. ap_activities (actorAvatar — new field from inbox handler fix)
107
+ * 3. ap_followers (avatar)
108
+ * 4. Live fetch of the actor's ActivityPub profile (icon field)
107
109
  */
108
110
  async function backfillMissingAvatars(indiekit, stateCollection) {
109
111
  try {
@@ -178,6 +180,25 @@ async function backfillMissingAvatars(indiekit, stateCollection) {
178
180
  } catch { /* ignore */ }
179
181
  }
180
182
 
183
+ // Strategy 4: Fetch actor profile from the fediverse (last resort)
184
+ if (!photo && actorUrl) {
185
+ try {
186
+ const resp = await fetch(actorUrl, {
187
+ headers: { Accept: "application/activity+json, application/ld+json" },
188
+ signal: AbortSignal.timeout(5000),
189
+ });
190
+ if (resp.ok) {
191
+ const actor = await resp.json();
192
+ const icon = actor.icon;
193
+ if (typeof icon === "string") {
194
+ photo = icon;
195
+ } else if (icon?.url) {
196
+ photo = icon.url;
197
+ }
198
+ }
199
+ } catch { /* timeout or network error — skip */ }
200
+ }
201
+
181
202
  if (photo) {
182
203
  await itemsCollection.updateMany(
183
204
  { "author.url": actorUrl, "author.photo": { $in: ["", null] } },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-conversations",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
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",