mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor(federation): Make references always have domains
Some checks failed
CodeQL Scan / Analyze (push) Failing after 0s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / lint (push) Has been cancelled
Build Docker Images / check (push) Has been cancelled
Build Docker Images / tests (push) Has been cancelled
Build Docker Images / detect-circular (push) Has been cancelled
Mirror to Codeberg / Mirror (push) Has been cancelled
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been cancelled
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been cancelled
Some checks failed
CodeQL Scan / Analyze (push) Failing after 0s
Deploy Docs to GitHub Pages / build (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 0s
Test Publish / build (client) (push) Failing after 0s
Test Publish / build (sdk) (push) Failing after 0s
Build Docker Images / lint (push) Has been cancelled
Build Docker Images / check (push) Has been cancelled
Build Docker Images / tests (push) Has been cancelled
Build Docker Images / detect-circular (push) Has been cancelled
Mirror to Codeberg / Mirror (push) Has been cancelled
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been cancelled
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been cancelled
This commit is contained in:
parent
df2a5ce260
commit
709e1c6087
22 changed files with 688 additions and 477 deletions
|
|
@ -11,20 +11,28 @@ import { Entity, Reference } from "./entity.ts";
|
|||
export class Follow extends Entity {
|
||||
public static override name = "Follow";
|
||||
|
||||
public constructor(public override data: z.infer<typeof FollowSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof FollowSchema>,
|
||||
instanceDomain: string,
|
||||
) {
|
||||
super(data, instanceDomain);
|
||||
}
|
||||
|
||||
public get author(): Reference {
|
||||
return Reference.fromString(this.data.author);
|
||||
return Reference.fromString(this.data.author, this.instanceDomain);
|
||||
}
|
||||
|
||||
public get followee(): Reference {
|
||||
return Reference.fromString(this.data.followee);
|
||||
return Reference.fromString(this.data.followee, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Follow> {
|
||||
return FollowSchema.parseAsync(json).then((u) => new Follow(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Follow> {
|
||||
return FollowSchema.parseAsync(json).then(
|
||||
(u) => new Follow(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,21 +41,25 @@ export class FollowAccept extends Entity {
|
|||
|
||||
public constructor(
|
||||
public override data: z.infer<typeof FollowAcceptSchema>,
|
||||
instanceDomain: string,
|
||||
) {
|
||||
super(data);
|
||||
super(data, instanceDomain);
|
||||
}
|
||||
|
||||
public get author(): Reference {
|
||||
return Reference.fromString(this.data.author);
|
||||
return Reference.fromString(this.data.author, this.instanceDomain);
|
||||
}
|
||||
|
||||
public get follower(): Reference {
|
||||
return Reference.fromString(this.data.follower);
|
||||
return Reference.fromString(this.data.follower, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<FollowAccept> {
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<FollowAccept> {
|
||||
return FollowAcceptSchema.parseAsync(json).then(
|
||||
(u) => new FollowAccept(u),
|
||||
(u) => new FollowAccept(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -57,21 +69,25 @@ export class FollowReject extends Entity {
|
|||
|
||||
public constructor(
|
||||
public override data: z.infer<typeof FollowRejectSchema>,
|
||||
instanceDomain: string,
|
||||
) {
|
||||
super(data);
|
||||
super(data, instanceDomain);
|
||||
}
|
||||
|
||||
public get author(): Reference {
|
||||
return Reference.fromString(this.data.author);
|
||||
return Reference.fromString(this.data.author, this.instanceDomain);
|
||||
}
|
||||
|
||||
public get follower(): Reference {
|
||||
return Reference.fromString(this.data.follower);
|
||||
return Reference.fromString(this.data.follower, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<FollowReject> {
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<FollowReject> {
|
||||
return FollowRejectSchema.parseAsync(json).then(
|
||||
(u) => new FollowReject(u),
|
||||
(u) => new FollowReject(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -79,19 +95,27 @@ export class FollowReject extends Entity {
|
|||
export class Unfollow extends Entity {
|
||||
public static override name = "Unfollow";
|
||||
|
||||
public constructor(public override data: z.infer<typeof UnfollowSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof UnfollowSchema>,
|
||||
instanceDomain: string,
|
||||
) {
|
||||
super(data, instanceDomain);
|
||||
}
|
||||
|
||||
public get author(): Reference {
|
||||
return Reference.fromString(this.data.author);
|
||||
return Reference.fromString(this.data.author, this.instanceDomain);
|
||||
}
|
||||
|
||||
public get followee(): Reference {
|
||||
return Reference.fromString(this.data.followee);
|
||||
return Reference.fromString(this.data.followee, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Unfollow> {
|
||||
return UnfollowSchema.parseAsync(json).then((u) => new Unfollow(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Unfollow> {
|
||||
return UnfollowSchema.parseAsync(json).then(
|
||||
(u) => new Unfollow(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue