mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
fix: my-profile replies tab queries posts collection instead of ap_activities
The replies tab was empty because it queried ap_activities for outbound Create activities with a non-null targetUrl, but targetUrl was always null (remote actor resolution often fails). Now queries posts collection for post-type "reply" which reliably has in-reply-to URLs. Also fixes activity log to store in-reply-to URL as targetUrl instead of the resolved actor URL.
This commit is contained in:
2
index.js
2
index.js
@@ -480,7 +480,7 @@ export default class ActivityPubEndpoint {
|
||||
type: typeName,
|
||||
actorUrl: self._publicationUrl,
|
||||
objectUrl: properties.url,
|
||||
targetUrl: replyToActor?.url || undefined,
|
||||
targetUrl: properties["in-reply-to"] || undefined,
|
||||
summary: `Sent ${typeName} for ${properties.url} to ${followerCount} followers${replyNote}`,
|
||||
});
|
||||
|
||||
|
||||
@@ -137,41 +137,30 @@ export function myProfileController(plugin) {
|
||||
}
|
||||
|
||||
case "replies": {
|
||||
const apActivities = collections.get("ap_activities");
|
||||
if (apActivities) {
|
||||
// Query posts collection for reply-type posts (have in-reply-to)
|
||||
if (postsCollection) {
|
||||
const query = {
|
||||
direction: "outbound",
|
||||
type: "Create",
|
||||
targetUrl: { $exists: true, $ne: null },
|
||||
"properties.post-type": "reply",
|
||||
};
|
||||
if (before) {
|
||||
query.receivedAt = { $lt: before };
|
||||
query["properties.published"] = { $lt: before };
|
||||
}
|
||||
|
||||
const activities = await apActivities
|
||||
const replies = await postsCollection
|
||||
.find(query)
|
||||
.sort({ receivedAt: -1 })
|
||||
.sort({ "properties.published": -1 })
|
||||
.limit(PAGE_LIMIT)
|
||||
.toArray();
|
||||
|
||||
items = activities.map((a) => ({
|
||||
uid: a.objectUrl,
|
||||
url: a.objectUrl,
|
||||
content: a.content
|
||||
? { text: a.content }
|
||||
: { text: a.summary || "" },
|
||||
published: a.receivedAt,
|
||||
inReplyTo: a.targetUrl,
|
||||
type: "reply",
|
||||
author: {
|
||||
name: profile?.name || a.actorName || "",
|
||||
url: profile?.url || a.actorUrl || "",
|
||||
photo: profile?.icon || "",
|
||||
},
|
||||
}));
|
||||
items = replies.map((p) => {
|
||||
const card = postToCardItem(p, profile);
|
||||
card.inReplyTo = p.properties?.["in-reply-to"] || null;
|
||||
card.type = "reply";
|
||||
return card;
|
||||
});
|
||||
|
||||
if (activities.length === PAGE_LIMIT) {
|
||||
nextBefore = activities[activities.length - 1].receivedAt;
|
||||
if (replies.length === PAGE_LIMIT) {
|
||||
nextBefore = items[items.length - 1].published;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
||||
"version": "2.0.11",
|
||||
"version": "2.0.12",
|
||||
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||
"keywords": [
|
||||
"indiekit",
|
||||
|
||||
Reference in New Issue
Block a user