Make endpoints bigger

This commit is contained in:
Jesse Wierzbinski 2023-09-12 12:56:37 -10:00
parent 6d77c8edc7
commit 8e7f08678b
No known key found for this signature in database
GPG key ID: F9A1E418934E40B0
2 changed files with 125 additions and 22 deletions

View file

@ -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`,
},
})
);
};

View file

@ -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[],
})
);
}
};