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
|
|
@ -6,39 +6,55 @@ import { Entity, Reference } from "../entity.ts";
|
|||
export class Like extends Entity {
|
||||
public static override name = "pub.versia:likes/Like";
|
||||
|
||||
public constructor(public override data: z.infer<typeof LikeSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof LikeSchema>,
|
||||
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 liked(): Reference {
|
||||
return Reference.fromString(this.data.liked);
|
||||
return Reference.fromString(this.data.liked, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Like> {
|
||||
return LikeSchema.parseAsync(json).then((u) => new Like(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Like> {
|
||||
return LikeSchema.parseAsync(json).then(
|
||||
(u) => new Like(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class Dislike extends Entity {
|
||||
public static override name = "pub.versia:likes/Dislike";
|
||||
|
||||
public constructor(public override data: z.infer<typeof DislikeSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof DislikeSchema>,
|
||||
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 disliked(): Reference {
|
||||
return Reference.fromString(this.data.disliked);
|
||||
return Reference.fromString(this.data.disliked, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Dislike> {
|
||||
return DislikeSchema.parseAsync(json).then((u) => new Dislike(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Dislike> {
|
||||
return DislikeSchema.parseAsync(json).then(
|
||||
(u) => new Dislike(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,27 @@ import { Entity, Reference } from "../entity.ts";
|
|||
export class Vote extends Entity {
|
||||
public static override name = "pub.versia:polls/Vote";
|
||||
|
||||
public constructor(public override data: z.infer<typeof VoteSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof VoteSchema>,
|
||||
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 poll(): Reference {
|
||||
return Reference.fromString(this.data.poll);
|
||||
return Reference.fromString(this.data.poll, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Vote> {
|
||||
return VoteSchema.parseAsync(json).then((u) => new Vote(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Vote> {
|
||||
return VoteSchema.parseAsync(json).then(
|
||||
(u) => new Vote(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,27 @@ import { Entity, Reference } from "../entity.ts";
|
|||
export class Reaction extends Entity {
|
||||
public static override name = "pub.versia:reactions/Reaction";
|
||||
|
||||
public constructor(public override data: z.infer<typeof ReactionSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof ReactionSchema>,
|
||||
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 object(): Reference {
|
||||
return Reference.fromString(this.data.object);
|
||||
return Reference.fromString(this.data.object, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Reaction> {
|
||||
return ReactionSchema.parseAsync(json).then((u) => new Reaction(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Reaction> {
|
||||
return ReactionSchema.parseAsync(json).then(
|
||||
(u) => new Reaction(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,31 @@ import { Entity, Reference } from "../entity.ts";
|
|||
export class Report extends Entity {
|
||||
public static override name = "pub.versia:reports/Report";
|
||||
|
||||
public constructor(public override data: z.infer<typeof ReportSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof ReportSchema>,
|
||||
instanceDomain: string,
|
||||
) {
|
||||
super(data, instanceDomain);
|
||||
}
|
||||
|
||||
public get author(): Reference | null {
|
||||
return this.data.author ? Reference.fromString(this.data.author) : null;
|
||||
return this.data.author
|
||||
? Reference.fromString(this.data.author, this.instanceDomain)
|
||||
: null;
|
||||
}
|
||||
|
||||
public get reported(): Reference[] {
|
||||
return this.data.reported.map((r) => Reference.fromString(r));
|
||||
return this.data.reported.map((r) =>
|
||||
Reference.fromString(r, this.instanceDomain),
|
||||
);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Report> {
|
||||
return ReportSchema.parseAsync(json).then((u) => new Report(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Report> {
|
||||
return ReportSchema.parseAsync(json).then(
|
||||
(u) => new Report(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,27 @@ import { Entity, Reference } from "../entity.ts";
|
|||
export class Share extends Entity {
|
||||
public static override name = "pub.versia:share/Share";
|
||||
|
||||
public constructor(public override data: z.infer<typeof ShareSchema>) {
|
||||
super(data);
|
||||
public constructor(
|
||||
public override data: z.infer<typeof ShareSchema>,
|
||||
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 shared(): Reference {
|
||||
return Reference.fromString(this.data.shared);
|
||||
return Reference.fromString(this.data.shared, this.instanceDomain);
|
||||
}
|
||||
|
||||
public static override fromJSON(json: JSONObject): Promise<Share> {
|
||||
return ShareSchema.parseAsync(json).then((u) => new Share(u));
|
||||
public static override fromJSON(
|
||||
json: JSONObject,
|
||||
instanceDomain: string,
|
||||
): Promise<Share> {
|
||||
return ShareSchema.parseAsync(json).then(
|
||||
(u) => new Share(u, instanceDomain),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue