feat(federation): Port to Versia 0.6

This commit is contained in:
Jesse Wierzbinski 2026-02-25 02:34:27 +01:00
parent de69f27877
commit fca30b4dad
No known key found for this signature in database
62 changed files with 1614 additions and 2008 deletions

View file

@ -6,7 +6,7 @@ import {
UnfollowSchema,
} from "../schemas/follow.ts";
import type { JSONObject } from "../types.ts";
import { Entity } from "./entity.ts";
import { Entity, Reference } from "./entity.ts";
export class Follow extends Entity {
public static override name = "Follow";
@ -15,6 +15,14 @@ export class Follow extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get followee(): Reference {
return Reference.fromString(this.data.followee);
}
public static override fromJSON(json: JSONObject): Promise<Follow> {
return FollowSchema.parseAsync(json).then((u) => new Follow(u));
}
@ -29,6 +37,14 @@ export class FollowAccept extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get follower(): Reference {
return Reference.fromString(this.data.follower);
}
public static override fromJSON(json: JSONObject): Promise<FollowAccept> {
return FollowAcceptSchema.parseAsync(json).then(
(u) => new FollowAccept(u),
@ -45,6 +61,14 @@ export class FollowReject extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get follower(): Reference {
return Reference.fromString(this.data.follower);
}
public static override fromJSON(json: JSONObject): Promise<FollowReject> {
return FollowRejectSchema.parseAsync(json).then(
(u) => new FollowReject(u),
@ -59,6 +83,14 @@ export class Unfollow extends Entity {
super(data);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
}
public get followee(): Reference {
return Reference.fromString(this.data.followee);
}
public static override fromJSON(json: JSONObject): Promise<Unfollow> {
return UnfollowSchema.parseAsync(json).then((u) => new Unfollow(u));
}