diff --git a/lib/mastodon/helpers/resolve-account.js b/lib/mastodon/helpers/resolve-account.js index 811090c..74bc3c9 100644 --- a/lib/mastodon/helpers/resolve-account.js +++ b/lib/mastodon/helpers/resolve-account.js @@ -24,7 +24,9 @@ export async function resolveRemoteAccount(acct, pluginOptions, baseUrl) { { handle, publicationUrl }, ); - // Determine lookup URI + // Determine lookup URI. + // acct:user@domain — kept as a string; Fedify resolves it via WebFinger. + // HTTP URLs — converted to URL objects for type-correct AP object fetch. let actorUri; if (acct.includes("@")) { const parts = acct.replace(/^@/, "").split("@"); @@ -33,7 +35,7 @@ export async function resolveRemoteAccount(acct, pluginOptions, baseUrl) { if (!username || !domain) return null; actorUri = `acct:${username}@${domain}`; } else if (acct.startsWith("http")) { - actorUri = acct; + actorUri = new URL(acct); } else { return null; } diff --git a/lib/mastodon/routes/accounts.js b/lib/mastodon/routes/accounts.js index 07a0ddb..10ee6b7 100644 --- a/lib/mastodon/routes/accounts.js +++ b/lib/mastodon/routes/accounts.js @@ -112,7 +112,7 @@ router.get("/api/v1/accounts/lookup", async (req, res, next) => { if (follower) { return res.json( serializeAccount( - { name: follower.name, url: follower.actorUrl, photo: follower.avatar, handle: follower.handle, bannerUrl: follower.banner || "" }, + { name: follower.name, url: follower.actorUrl, photo: follower.avatar, handle: follower.handle, bannerUrl: follower.banner || "", createdAt: follower.createdAt || undefined }, { baseUrl }, ), ); @@ -128,7 +128,7 @@ router.get("/api/v1/accounts/lookup", async (req, res, next) => { if (following) { return res.json( serializeAccount( - { name: following.name, url: following.actorUrl, photo: following.avatar, handle: following.handle }, + { name: following.name, url: following.actorUrl, photo: following.avatar, handle: following.handle, createdAt: following.createdAt || undefined }, { baseUrl }, ), ); @@ -396,7 +396,7 @@ router.get("/api/v1/accounts/:id/followers", async (req, res, next) => { const accounts = followers.map((f) => serializeAccount( - { name: f.name, url: f.actorUrl, photo: f.avatar, handle: f.handle, bannerUrl: f.banner || "" }, + { name: f.name, url: f.actorUrl, photo: f.avatar, handle: f.handle, bannerUrl: f.banner || "", createdAt: f.createdAt || undefined }, { baseUrl }, ), ); @@ -429,7 +429,7 @@ router.get("/api/v1/accounts/:id/following", async (req, res, next) => { const accounts = following.map((f) => serializeAccount( - { name: f.name, url: f.actorUrl, photo: f.avatar, handle: f.handle, bannerUrl: f.banner || "" }, + { name: f.name, url: f.actorUrl, photo: f.avatar, handle: f.handle, bannerUrl: f.banner || "", createdAt: f.createdAt || undefined }, { baseUrl }, ), ); @@ -786,6 +786,7 @@ async function resolveActorData(id, collections) { photo: f.avatar, handle: f.handle, bannerUrl: f.banner || "", + createdAt: f.createdAt || undefined, }, actorUrl: f.actorUrl, }; @@ -803,6 +804,7 @@ async function resolveActorData(id, collections) { photo: f.avatar, handle: f.handle, bannerUrl: f.banner || "", + createdAt: f.createdAt || undefined, }, actorUrl: f.actorUrl, };