From 8e7f08678b2cb8cf5f03ee9d0b7c7dcc58e47d30 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Tue, 12 Sep 2023 12:56:37 -1000 Subject: [PATCH] Make endpoints bigger --- server/api/@[username]/actor.json/index.ts | 89 ++++++++++++++++++++- server/api/@[username]/outbox.json/index.ts | 58 +++++++++----- 2 files changed, 125 insertions(+), 22 deletions(-) diff --git a/server/api/@[username]/actor.json/index.ts b/server/api/@[username]/actor.json/index.ts index 6ead31d2..1a419fce 100644 --- a/server/api/@[username]/actor.json/index.ts +++ b/server/api/@[username]/actor.json/index.ts @@ -24,20 +24,103 @@ export default async ( "@context": [ "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", + { + manuallyApprovesFollowers: "as:manuallyApprovesFollowers", + toot: "http://joinmastodon.org/ns#", + featured: { + "@id": "toot:featured", + "@type": "@id", + }, + featuredTags: { + "@id": "toot:featuredTags", + "@type": "@id", + }, + alsoKnownAs: { + "@id": "as:alsoKnownAs", + "@type": "@id", + }, + movedTo: { + "@id": "as:movedTo", + "@type": "@id", + }, + schema: "http://schema.org#", + PropertyValue: "schema:PropertyValue", + value: "schema:value", + discoverable: "toot:discoverable", + Device: "toot:Device", + Ed25519Signature: "toot:Ed25519Signature", + Ed25519Key: "toot:Ed25519Key", + Curve25519Key: "toot:Curve25519Key", + EncryptedMessage: "toot:EncryptedMessage", + publicKeyBase64: "toot:publicKeyBase64", + deviceId: "toot:deviceId", + claim: { + "@type": "@id", + "@id": "toot:claim", + }, + fingerprintKey: { + "@type": "@id", + "@id": "toot:fingerprintKey", + }, + identityKey: { + "@type": "@id", + "@id": "toot:identityKey", + }, + devices: { + "@type": "@id", + "@id": "toot:devices", + }, + messageFranking: "toot:messageFranking", + messageType: "toot:messageType", + cipherText: "toot:cipherText", + suspended: "toot:suspended", + Emoji: "toot:Emoji", + focalPoint: { + "@container": "@list", + "@id": "toot:focalPoint", + }, + Hashtag: "as:Hashtag", + }, ], id: `${getHost()}/@${user.username}/actor`, type: "Person", preferredUsername: user.username, // TODO: Add user display name name: user.username, summary: user.bio, - icon: [ - // TODO: Add user avatar - ], + icon: /*{ + type: "Image", + url: user.avatar, + mediaType: mimetype + }*/ undefined, // TODO: Add avatar + image: /*{ + type: "Image", + url: user.avatar, + mediaType: mimetype + }*/ undefined, // TODO: Add banner inbox: `${getHost()}/@${user.username}/inbox`, outbox: `${getHost()}/@${user.username}/outbox`, followers: `${getHost()}/@${user.username}/followers`, following: `${getHost()}/@${user.username}/following`, liked: `${getHost()}/@${user.username}/liked`, + discoverable: true, + alsoKnownAs: [ + // TODO: Add accounts from which the user migrated + ], + manuallyApprovesFollowers: false, // TODO: Change + publicKey: { + id: `${getHost()}/@${user.username}/actor#main-key`, + owner: `${getHost()}/@${user.username}/actor`, + // TODO: Add user public key + }, + tag: [ + // TODO: Add emojis here, and hashtags + ], + attachment: [ + // TODO: Add user attachments (I.E. profile metadata) + ], + endpoints: { + sharedInbox: `${getHost()}/inbox`, + }, }) ); }; diff --git a/server/api/@[username]/outbox.json/index.ts b/server/api/@[username]/outbox.json/index.ts index fa4ce3f0..8401db1d 100644 --- a/server/api/@[username]/outbox.json/index.ts +++ b/server/api/@[username]/outbox.json/index.ts @@ -109,24 +109,44 @@ export default async ( - return jsonResponse(await compact({ - "@context": [ - "https://www.w3.org/ns/activitystreams", - "https://w3id.org/security/v1", - ], - id: `${getHost()}/@${user.username}/inbox`, - type: "OrderedCollectionPage", - totalItems: count, - partOf: `${getHost()}/@${user.username}/inbox`, - // Next is less recent posts chronologically, uses min_id - next: `${getHost()}/@${user.username}/outbox?min_id=${ - posts[posts.length - 1].id - }&page=true`, - // Prev is more recent posts chronologically, uses max_id - prev: `${getHost()}/@${user.username}/outbox?max_id=${ - posts[0].id - }&page=true`, - orderedItems: posts.slice(0, 10).map(post => post.data) as NodeObject[] - })); + return jsonResponse( + await compact({ + "@context": [ + "https://www.w3.org/ns/activitystreams", + { + ostatus: "http://ostatus.org#", + atomUri: "ostatus:atomUri", + inReplyToAtomUri: "ostatus:inReplyToAtomUri", + conversation: "ostatus:conversation", + sensitive: "as:sensitive", + toot: "http://joinmastodon.org/ns#", + votersCount: "toot:votersCount", + litepub: "http://litepub.social/ns#", + directMessage: "litepub:directMessage", + Emoji: "toot:Emoji", + focalPoint: { + "@container": "@list", + "@id": "toot:focalPoint", + }, + blurhash: "toot:blurhash", + }, + ], + id: `${getHost()}/@${user.username}/inbox`, + type: "OrderedCollectionPage", + totalItems: count, + partOf: `${getHost()}/@${user.username}/inbox`, + // Next is less recent posts chronologically, uses min_id + next: `${getHost()}/@${user.username}/outbox?min_id=${ + posts[posts.length - 1].id + }&page=true`, + // Prev is more recent posts chronologically, uses max_id + prev: `${getHost()}/@${user.username}/outbox?max_id=${ + posts[0].id + }&page=true`, + orderedItems: posts + .slice(0, 10) + .map((post) => post.data) as NodeObject[], + }) + ); } };