mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
fix(api): 🐛 Don't use URL in Versia entity schemas, fixes OpenAPI
This commit is contained in:
parent
0a712128a5
commit
a2e907390f
12 changed files with 131 additions and 102 deletions
|
|
@ -86,11 +86,11 @@ export default apiRoute((app) =>
|
|||
);
|
||||
|
||||
const uriCollection = new VersiaEntities.URICollection({
|
||||
author: note.author.uri,
|
||||
author: note.author.uri.href,
|
||||
first: new URL(
|
||||
`/notes/${note.id}/quotes?offset=0`,
|
||||
config.http.base_url,
|
||||
),
|
||||
).href,
|
||||
last:
|
||||
replyCount > limit
|
||||
? new URL(
|
||||
|
|
@ -98,11 +98,11 @@ export default apiRoute((app) =>
|
|||
replyCount - limit
|
||||
}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: new URL(
|
||||
`/notes/${note.id}/quotes`,
|
||||
config.http.base_url,
|
||||
),
|
||||
).href,
|
||||
next:
|
||||
offset + limit < replyCount
|
||||
? new URL(
|
||||
|
|
@ -110,7 +110,7 @@ export default apiRoute((app) =>
|
|||
offset + limit
|
||||
}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: null,
|
||||
previous:
|
||||
offset - limit >= 0
|
||||
|
|
@ -119,10 +119,10 @@ export default apiRoute((app) =>
|
|||
offset - limit
|
||||
}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: null,
|
||||
total: replyCount,
|
||||
items: replies.map((reply) => reply.getUri()),
|
||||
items: replies.map((reply) => reply.getUri().href),
|
||||
});
|
||||
|
||||
// If base_url uses https and request uses http, rewrite request to use https
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ export default apiRoute((app) =>
|
|||
);
|
||||
|
||||
const uriCollection = new VersiaEntities.URICollection({
|
||||
author: note.author.uri,
|
||||
author: note.author.uri.href,
|
||||
first: new URL(
|
||||
`/notes/${note.id}/replies?offset=0`,
|
||||
config.http.base_url,
|
||||
),
|
||||
).href,
|
||||
last:
|
||||
replyCount > limit
|
||||
? new URL(
|
||||
|
|
@ -96,11 +96,11 @@ export default apiRoute((app) =>
|
|||
replyCount - limit
|
||||
}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: new URL(
|
||||
`/notes/${note.id}/replies`,
|
||||
config.http.base_url,
|
||||
),
|
||||
).href,
|
||||
next:
|
||||
offset + limit < replyCount
|
||||
? new URL(
|
||||
|
|
@ -108,7 +108,7 @@ export default apiRoute((app) =>
|
|||
offset + limit
|
||||
}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: null,
|
||||
previous:
|
||||
offset - limit >= 0
|
||||
|
|
@ -117,10 +117,10 @@ export default apiRoute((app) =>
|
|||
offset - limit
|
||||
}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: null,
|
||||
total: replyCount,
|
||||
items: replies.map((reply) => reply.getUri()),
|
||||
items: replies.map((reply) => reply.getUri().href),
|
||||
});
|
||||
|
||||
// If base_url uses https and request uses http, rewrite request to use https
|
||||
|
|
|
|||
|
|
@ -98,28 +98,28 @@ export default apiRoute((app) =>
|
|||
first: new URL(
|
||||
`/users/${uuid}/outbox?page=1`,
|
||||
config.http.base_url,
|
||||
),
|
||||
).href,
|
||||
last: new URL(
|
||||
`/users/${uuid}/outbox?page=${Math.ceil(
|
||||
totalNotes / NOTES_PER_PAGE,
|
||||
)}`,
|
||||
config.http.base_url,
|
||||
),
|
||||
).href,
|
||||
total: totalNotes,
|
||||
author: author.uri,
|
||||
author: author.uri.href,
|
||||
next:
|
||||
notes.length === NOTES_PER_PAGE
|
||||
? new URL(
|
||||
`/users/${uuid}/outbox?page=${pageNumber + 1}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: null,
|
||||
previous:
|
||||
pageNumber > 1
|
||||
? new URL(
|
||||
`/users/${uuid}/outbox?page=${pageNumber - 1}`,
|
||||
config.http.base_url,
|
||||
)
|
||||
).href
|
||||
: null,
|
||||
items: notes.map((note) => note.toVersia()),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue