mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
feat: expose signed avatar resolver for cross-plugin use
Register resolveActorAvatar() on Indiekit.config.application during init(). Uses Fedify's authenticated document loader to fetch actor profiles from servers with Authorized Fetch enabled (e.g., hachyderm.io, indieweb.social). Called by the conversations plugin's avatar backfill.
This commit is contained in:
23
index.js
23
index.js
@@ -1047,6 +1047,29 @@ export default class ActivityPubEndpoint {
|
||||
this._federation = federation;
|
||||
this._fedifyMiddleware = createFedifyMiddleware(federation, () => ({}));
|
||||
|
||||
// Expose signed avatar resolver for cross-plugin use (e.g., conversations backfill)
|
||||
Indiekit.config.application.resolveActorAvatar = async (actorUrl) => {
|
||||
try {
|
||||
const handle = this.options.actor.handle;
|
||||
const ctx = this._federation.createContext(
|
||||
new URL(this._publicationUrl),
|
||||
{ handle, publicationUrl: this._publicationUrl },
|
||||
);
|
||||
const documentLoader = await ctx.getDocumentLoader({
|
||||
identifier: handle,
|
||||
});
|
||||
const actor = await ctx.lookupObject(new URL(actorUrl), {
|
||||
documentLoader,
|
||||
});
|
||||
if (!actor) return "";
|
||||
const { extractActorInfo } = await import("./lib/timeline-store.js");
|
||||
const info = await extractActorInfo(actor, { documentLoader });
|
||||
return info.photo || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
// Register as endpoint (mounts routesPublic, routesWellKnown, routes)
|
||||
Indiekit.addEndpoint(this);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rmdes/indiekit-endpoint-activitypub",
|
||||
"version": "2.0.29",
|
||||
"version": "2.0.30",
|
||||
"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