@rmdes/indiekit-endpoint-conversations 2.1.6 → 2.1.7
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.
|
@@ -165,6 +165,58 @@ async function apiMentions(request, response) {
|
|
|
165
165
|
|
|
166
166
|
const children = items.map(conversationItemToJf2);
|
|
167
167
|
|
|
168
|
+
// Enrich with owner replies from the posts collection
|
|
169
|
+
// Owner replies are Micropub posts with in-reply-to matching an interaction URL
|
|
170
|
+
const replyUrls = children
|
|
171
|
+
.filter((c) => c["wm-property"] === "in-reply-to")
|
|
172
|
+
.map((c) => c.url)
|
|
173
|
+
.filter(Boolean);
|
|
174
|
+
|
|
175
|
+
if (replyUrls.length > 0) {
|
|
176
|
+
const postsCollection = application.collections?.get("posts");
|
|
177
|
+
if (postsCollection) {
|
|
178
|
+
const siteUrl = application.publication?.me || application.url || "";
|
|
179
|
+
const ownerName =
|
|
180
|
+
process.env.AUTHOR_NAME ||
|
|
181
|
+
(siteUrl ? new URL(siteUrl).hostname : "Owner");
|
|
182
|
+
|
|
183
|
+
const ownerPosts = await postsCollection
|
|
184
|
+
.find({
|
|
185
|
+
"properties.in-reply-to": { $in: replyUrls },
|
|
186
|
+
})
|
|
187
|
+
.sort({ "properties.published": -1 })
|
|
188
|
+
.limit(50)
|
|
189
|
+
.toArray();
|
|
190
|
+
|
|
191
|
+
for (const post of ownerPosts) {
|
|
192
|
+
const inReplyTo = post.properties?.["in-reply-to"];
|
|
193
|
+
if (!inReplyTo || typeof inReplyTo !== "string") continue;
|
|
194
|
+
|
|
195
|
+
children.push({
|
|
196
|
+
type: "entry",
|
|
197
|
+
"wm-id": `owner-reply-${post._id}`,
|
|
198
|
+
"wm-property": "in-reply-to",
|
|
199
|
+
"wm-target": target || "",
|
|
200
|
+
"wm-received": post.properties?.published || "",
|
|
201
|
+
author: {
|
|
202
|
+
type: "card",
|
|
203
|
+
name: ownerName,
|
|
204
|
+
url: siteUrl,
|
|
205
|
+
photo: process.env.AUTHOR_AVATAR || "",
|
|
206
|
+
},
|
|
207
|
+
url: post.properties?.url || "",
|
|
208
|
+
published: post.properties?.published || "",
|
|
209
|
+
content: {
|
|
210
|
+
text: post.properties?.content?.text || "",
|
|
211
|
+
html: post.properties?.content?.html || "",
|
|
212
|
+
},
|
|
213
|
+
is_owner: true,
|
|
214
|
+
parent_url: inReplyTo,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
168
220
|
response.set("Cache-Control", "public, max-age=60");
|
|
169
221
|
response.json({
|
|
170
222
|
type: "feed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-conversations",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
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",
|