mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(federation): 🔥 Remove confusing User federation methods
This commit is contained in:
parent
9ff9b90f6b
commit
54b2dfb78d
12 changed files with 72 additions and 94 deletions
|
|
@ -3,6 +3,7 @@ import { Account as AccountSchema } from "@versia/client/schemas";
|
|||
import { RolePermission } from "@versia/client/schemas";
|
||||
import { describeRoute } from "hono-openapi";
|
||||
import { resolver } from "hono-openapi/zod";
|
||||
import { User } from "~/classes/database/user";
|
||||
import { ApiError } from "~/classes/errors/api-error";
|
||||
|
||||
export default apiRoute((app) =>
|
||||
|
|
@ -48,7 +49,7 @@ export default apiRoute((app) =>
|
|||
throw new ApiError(400, "Cannot refetch a local user");
|
||||
}
|
||||
|
||||
const newUser = await otherUser.updateFromRemote();
|
||||
const newUser = await User.fromVersia(otherUser.uri);
|
||||
|
||||
return context.json(newUser.toApi(false), 200);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ export default apiRoute((app) =>
|
|||
// Check if accepting remote follow
|
||||
if (account.isRemote()) {
|
||||
// Federate follow accept
|
||||
await user.sendFollowAccept(account);
|
||||
await user.acceptFollowRequest(account);
|
||||
}
|
||||
|
||||
return context.json(foundRelationship.toApi(), 200);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export default apiRoute((app) =>
|
|||
// Check if rejecting remote follow
|
||||
if (account.isRemote()) {
|
||||
// Federate follow reject
|
||||
await user.sendFollowReject(account);
|
||||
await user.rejectFollowRequest(account);
|
||||
}
|
||||
|
||||
return context.json(foundRelationship.toApi(), 200);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ describe("/api/v1/statuses", () => {
|
|||
|
||||
expect(ok).toBe(true);
|
||||
expect(data).toMatchObject({
|
||||
content: `<p>Hello, <a class="u-url mention" rel="nofollow noopener noreferrer" target="_blank" href="${users[1].getUri()}">@${users[1].data.username}</a>!</p>`,
|
||||
content: `<p>Hello, <a class="u-url mention" rel="nofollow noopener noreferrer" target="_blank" href="${users[1].uri.href}">@${users[1].data.username}</a>!</p>`,
|
||||
});
|
||||
expect((data as z.infer<typeof Status>).mentions).toBeArrayOfSize(
|
||||
1,
|
||||
|
|
@ -241,7 +241,7 @@ describe("/api/v1/statuses", () => {
|
|||
|
||||
expect(ok).toBe(true);
|
||||
expect(data).toMatchObject({
|
||||
content: `<p>Hello, <a class="u-url mention" rel="nofollow noopener noreferrer" target="_blank" href="${users[1].getUri()}">@${users[1].data.username}</a>!</p>`,
|
||||
content: `<p>Hello, <a class="u-url mention" rel="nofollow noopener noreferrer" target="_blank" href="${users[1].uri.href}">@${users[1].data.username}</a>!</p>`,
|
||||
});
|
||||
expect((data as z.infer<typeof Status>).mentions).toBeArrayOfSize(
|
||||
1,
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default apiRoute((app) =>
|
|||
);
|
||||
|
||||
const uriCollection = new VersiaEntities.URICollection({
|
||||
author: note.author.getUri(),
|
||||
author: note.author.uri,
|
||||
first: new URL(
|
||||
`/notes/${note.id}/quotes?offset=0`,
|
||||
config.http.base_url,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export default apiRoute((app) =>
|
|||
);
|
||||
|
||||
const uriCollection = new VersiaEntities.URICollection({
|
||||
author: note.author.getUri(),
|
||||
author: note.author.uri,
|
||||
first: new URL(
|
||||
`/notes/${note.id}/replies?offset=0`,
|
||||
config.http.base_url,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ export default apiRoute((app) =>
|
|||
config.http.base_url,
|
||||
),
|
||||
total: totalNotes,
|
||||
author: author.getUri(),
|
||||
author: author.uri,
|
||||
next:
|
||||
notes.length === NOTES_PER_PAGE
|
||||
? new URL(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue