mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
fix: store actorAvatar in ap_activities for inbox interactions
Moved extractActorInfo() before logActivity() in Like, Announce, and Reply handlers so the actor's avatar URL is persisted in ap_activities. Previously only stored in ap_notifications, leaving conversation_items without photos for non-followers.
This commit is contained in:
@@ -253,17 +253,20 @@ export function registerInboxListeners(inboxChain, options) {
|
|||||||
actorObj?.preferredUsername?.toString() ||
|
actorObj?.preferredUsername?.toString() ||
|
||||||
actorUrl;
|
actorUrl;
|
||||||
|
|
||||||
|
// Extract actor info (including avatar) before logging so we can store it
|
||||||
|
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
|
||||||
|
|
||||||
await logActivity(collections, storeRawActivities, {
|
await logActivity(collections, storeRawActivities, {
|
||||||
direction: "inbound",
|
direction: "inbound",
|
||||||
type: "Like",
|
type: "Like",
|
||||||
actorUrl,
|
actorUrl,
|
||||||
actorName,
|
actorName,
|
||||||
|
actorAvatar: actorInfo.photo || "",
|
||||||
objectUrl: objectId,
|
objectUrl: objectId,
|
||||||
summary: `${actorName} liked ${objectId}`,
|
summary: `${actorName} liked ${objectId}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Store notification
|
// Store notification
|
||||||
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
|
|
||||||
await addNotification(collections, {
|
await addNotification(collections, {
|
||||||
uid: like.id?.href || `like:${actorUrl}:${objectId}`,
|
uid: like.id?.href || `like:${actorUrl}:${objectId}`,
|
||||||
type: "like",
|
type: "like",
|
||||||
@@ -301,18 +304,21 @@ export function registerInboxListeners(inboxChain, options) {
|
|||||||
actorObj?.preferredUsername?.toString() ||
|
actorObj?.preferredUsername?.toString() ||
|
||||||
actorUrl;
|
actorUrl;
|
||||||
|
|
||||||
|
// Extract actor info (including avatar) before logging so we can store it
|
||||||
|
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
|
||||||
|
|
||||||
// Log the boost activity
|
// Log the boost activity
|
||||||
await logActivity(collections, storeRawActivities, {
|
await logActivity(collections, storeRawActivities, {
|
||||||
direction: "inbound",
|
direction: "inbound",
|
||||||
type: "Announce",
|
type: "Announce",
|
||||||
actorUrl,
|
actorUrl,
|
||||||
actorName,
|
actorName,
|
||||||
|
actorAvatar: actorInfo.photo || "",
|
||||||
objectUrl: objectId,
|
objectUrl: objectId,
|
||||||
summary: `${actorName} boosted ${objectId}`,
|
summary: `${actorName} boosted ${objectId}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create notification
|
// Create notification
|
||||||
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
|
|
||||||
await addNotification(collections, {
|
await addNotification(collections, {
|
||||||
uid: announce.id?.href || `${actorUrl}#boost-${objectId}`,
|
uid: announce.id?.href || `${actorUrl}#boost-${objectId}`,
|
||||||
type: "boost",
|
type: "boost",
|
||||||
@@ -392,11 +398,16 @@ export function registerInboxListeners(inboxChain, options) {
|
|||||||
const pubUrl = collections._publicationUrl;
|
const pubUrl = collections._publicationUrl;
|
||||||
if (inReplyTo) {
|
if (inReplyTo) {
|
||||||
const content = object.content?.toString() || "";
|
const content = object.content?.toString() || "";
|
||||||
|
|
||||||
|
// Extract actor info (including avatar) before logging so we can store it
|
||||||
|
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
|
||||||
|
|
||||||
await logActivity(collections, storeRawActivities, {
|
await logActivity(collections, storeRawActivities, {
|
||||||
direction: "inbound",
|
direction: "inbound",
|
||||||
type: "Reply",
|
type: "Reply",
|
||||||
actorUrl,
|
actorUrl,
|
||||||
actorName,
|
actorName,
|
||||||
|
actorAvatar: actorInfo.photo || "",
|
||||||
objectUrl: object.id?.href || "",
|
objectUrl: object.id?.href || "",
|
||||||
targetUrl: inReplyTo,
|
targetUrl: inReplyTo,
|
||||||
content,
|
content,
|
||||||
@@ -405,7 +416,6 @@ export function registerInboxListeners(inboxChain, options) {
|
|||||||
|
|
||||||
// Create notification if reply is to one of OUR posts
|
// Create notification if reply is to one of OUR posts
|
||||||
if (pubUrl && inReplyTo.startsWith(pubUrl)) {
|
if (pubUrl && inReplyTo.startsWith(pubUrl)) {
|
||||||
const actorInfo = await extractActorInfo(actorObj, { documentLoader: authLoader });
|
|
||||||
const rawHtml = object.content?.toString() || "";
|
const rawHtml = object.content?.toString() || "";
|
||||||
const contentHtml = sanitizeContent(rawHtml);
|
const contentHtml = sanitizeContent(rawHtml);
|
||||||
const contentText = rawHtml.replace(/<[^>]*>/g, "").substring(0, 200);
|
const contentText = rawHtml.replace(/<[^>]*>/g, "").substring(0, 200);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
||||||
"version": "2.0.26",
|
"version": "2.0.27",
|
||||||
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"indiekit",
|
"indiekit",
|
||||||
|
|||||||
Reference in New Issue
Block a user