mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
feat(federation): Finalize Versia 0.6 port
This commit is contained in:
parent
fca30b4dad
commit
b7e77097ba
20 changed files with 2788 additions and 439 deletions
|
|
@ -50,10 +50,7 @@ export default apiRoute((app) =>
|
|||
throw new ApiError(400, "Cannot refetch a local user");
|
||||
}
|
||||
|
||||
const newUser = await User.fromVersia(
|
||||
otherUser.reference,
|
||||
otherUser.reference.domain as string,
|
||||
);
|
||||
const newUser = await User.fromVersia(otherUser.reference);
|
||||
|
||||
return context.json(newUser.toApi(false), 200);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -106,10 +106,7 @@ export default apiRoute((app) =>
|
|||
VersiaEntities.User,
|
||||
);
|
||||
|
||||
const foundAccount = await User.fromVersia(
|
||||
accountData,
|
||||
instance.data.baseUrl,
|
||||
);
|
||||
const foundAccount = await User.fromVersia(accountData, instance);
|
||||
|
||||
return context.json(foundAccount.toApi(), 200);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ export default apiRoute((app) =>
|
|||
|
||||
const foundAccount = await User.fromVersia(
|
||||
accountData,
|
||||
instance.data.baseUrl,
|
||||
instance,
|
||||
);
|
||||
|
||||
accounts.push(foundAccount);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ export default apiRoute((app) =>
|
|||
|
||||
const newUser = await User.fromVersia(
|
||||
accountData,
|
||||
instance.data.baseUrl,
|
||||
instance,
|
||||
);
|
||||
|
||||
return context.json(
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ export default apiRoute((app) => {
|
|||
|
||||
const jwtPayload = (await verify(state, config.authentication.key, {
|
||||
iss: config.http.base_url.toString(),
|
||||
alg: "HS256",
|
||||
})) as {
|
||||
flow: string;
|
||||
link?: boolean;
|
||||
|
|
|
|||
25
packages/api/routes/versia/v0.6/inbox.test.ts
vendored
25
packages/api/routes/versia/v0.6/inbox.test.ts
vendored
|
|
@ -40,6 +40,17 @@ mock(new URL("/.well-known/versia", instanceUrl).href, {
|
|||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: {
|
||||
versions: ["0.6.0"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
mock(new URL("/.versia/v0.6/instance", instanceUrl).href, {
|
||||
response: {
|
||||
headers: {
|
||||
"Content-Type": "application/vnd.versia+json; charset=utf-8",
|
||||
},
|
||||
data: new VersiaEntities.InstanceMetadata({
|
||||
type: "InstanceMetadata",
|
||||
name: "Versia",
|
||||
|
|
@ -70,7 +81,7 @@ mock(new URL("/.well-known/versia", instanceUrl).href, {
|
|||
mock(new URL(`/.versia/v0.6/entities/User/${userId}`, instanceUrl).href, {
|
||||
response: {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Type": "application/vnd.versia+json; charset=utf-8",
|
||||
},
|
||||
data: new VersiaEntities.User({
|
||||
id: userId,
|
||||
|
|
@ -132,7 +143,7 @@ describe("Inbox Tests", () => {
|
|||
|
||||
const signedRequest = await sign(
|
||||
instanceKeys.privateKey,
|
||||
new URL(exampleNote.data.author),
|
||||
instanceUrl,
|
||||
new Request(inboxUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
@ -151,6 +162,8 @@ describe("Inbox Tests", () => {
|
|||
body: signedRequest.body,
|
||||
});
|
||||
|
||||
console.log(await response.text());
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
|
||||
await sleep(500);
|
||||
|
|
@ -174,7 +187,7 @@ describe("Inbox Tests", () => {
|
|||
|
||||
const signedRequest = await sign(
|
||||
instanceKeys.privateKey,
|
||||
new URL(exampleRequest.data.author),
|
||||
instanceUrl,
|
||||
new Request(inboxUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
@ -227,7 +240,7 @@ describe("Inbox Tests", () => {
|
|||
|
||||
const signedRequest = await sign(
|
||||
instanceKeys.privateKey,
|
||||
new URL(exampleRequest.data.author),
|
||||
instanceUrl,
|
||||
new Request(inboxUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
@ -322,7 +335,7 @@ describe("Inbox Tests", () => {
|
|||
|
||||
const signedRequest = await sign(
|
||||
instanceKeys.privateKey,
|
||||
new URL(exampleRequest.data.author),
|
||||
instanceUrl,
|
||||
new Request(inboxUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
@ -402,7 +415,7 @@ describe("Inbox Tests", () => {
|
|||
|
||||
const signedRequest = await sign(
|
||||
instanceKeys.privateKey,
|
||||
new URL(exampleRequest.data.author),
|
||||
instanceUrl,
|
||||
new Request(inboxUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
|
|||
2
packages/api/routes/versia/v0.6/inbox.ts
vendored
2
packages/api/routes/versia/v0.6/inbox.ts
vendored
|
|
@ -4,7 +4,7 @@ import z from "zod";
|
|||
import { InboxJobType, inboxQueue } from "~/packages/kit/queues/inbox/queue";
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.get(
|
||||
app.post(
|
||||
"/.versia/v0.6/inbox",
|
||||
describeRoute({
|
||||
summary: "Instance inbox endpoint",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue