diff --git a/classes/functions/federation.ts b/classes/functions/federation.ts deleted file mode 100644 index 9aa4b666..00000000 --- a/classes/functions/federation.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { Unfollow } from "@versia/federation/types"; -import type { User } from "~/packages/database-interface/user"; - -export const unfollowFederationRequest = ( - unfollower: User, - unfollowing: User, -): Unfollow => { - const id = crypto.randomUUID(); - return { - type: "Unfollow", - id, - author: unfollower.getUri(), - created_at: new Date().toISOString(), - followee: unfollowing.getUri(), - }; -}; diff --git a/packages/database-interface/user.ts b/packages/database-interface/user.ts index c81f25d9..ec9ac084 100644 --- a/packages/database-interface/user.ts +++ b/packages/database-interface/user.ts @@ -14,7 +14,11 @@ import { type HttpVerb, SignatureConstructor, } from "@versia/federation"; -import type { Collection, User as VersiaUser } from "@versia/federation/types"; +import type { + Collection, + Unfollow, + User as VersiaUser, +} from "@versia/federation/types"; import chalk from "chalk"; import { type InferInsertModel, @@ -49,7 +53,6 @@ import { } from "~/drizzle/schema"; import { type Config, config } from "~/packages/config-manager"; import type { KnownEntity } from "~/types/api.ts"; -import { unfollowFederationRequest } from "../../classes/functions/federation.ts"; import { BaseInterface } from "./base"; import { Emoji } from "./emoji"; import { Instance } from "./instance"; @@ -210,7 +213,7 @@ export class User extends BaseInterface { if (followee.isRemote()) { // TODO: This should reschedule for a later time and maybe notify the server admin if it fails too often const { ok } = await this.federateToUser( - unfollowFederationRequest(this, followee), + this.unfollowToVersia(followee), followee, ); @@ -240,6 +243,17 @@ export class User extends BaseInterface { return true; } + private unfollowToVersia(followee: User): Unfollow { + const id = crypto.randomUUID(); + return { + type: "Unfollow", + id, + author: this.getUri(), + created_at: new Date().toISOString(), + followee: followee.getUri(), + }; + } + static async webFinger( manager: FederationRequester, username: string,