refactor(federation): 🔥 Remove confusing User federation methods

This commit is contained in:
Jesse Wierzbinski 2025-04-08 17:27:08 +02:00
parent 9ff9b90f6b
commit 54b2dfb78d
No known key found for this signature in database
12 changed files with 72 additions and 94 deletions

View file

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

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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(