mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
feat(federation): ✨ Port to Versia 0.6
This commit is contained in:
parent
de69f27877
commit
fca30b4dad
62 changed files with 1614 additions and 2008 deletions
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue