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

This commit is contained in:
Jesse Wierzbinski 2026-04-03 13:34:19 +02:00
parent df2a5ce260
commit 709e1c6087
No known key found for this signature in database
22 changed files with 688 additions and 477 deletions

View file

@ -7,16 +7,24 @@ import { Entity, Reference } from "./entity.ts";
export class Note extends Entity {
public static override name = "Note";
public constructor(public override data: z.infer<typeof NoteSchema>) {
super(data);
public constructor(
public override data: z.infer<typeof NoteSchema>,
instanceDomain: string,
) {
super(data, instanceDomain);
}
public static override fromJSON(json: JSONObject): Promise<Note> {
return NoteSchema.parseAsync(json).then((n) => new Note(n));
public static override fromJSON(
json: JSONObject,
instanceDomain: string,
): Promise<Note> {
return NoteSchema.parseAsync(json).then(
(n) => new Note(n, instanceDomain),
);
}
public get author(): Reference {
return Reference.fromString(this.data.author);
return Reference.fromString(this.data.author, this.instanceDomain);
}
public get group(): Reference | null {
@ -27,20 +35,24 @@ export class Note extends Entity {
return null;
}
return Reference.fromString(this.data.group);
return Reference.fromString(this.data.group, this.instanceDomain);
}
public get mentions(): Reference[] {
return this.data.mentions.map((m) => Reference.fromString(m));
return this.data.mentions.map((m) =>
Reference.fromString(m, this.instanceDomain),
);
}
public get quotes(): Reference | null {
return this.data.quotes ? Reference.fromString(this.data.quotes) : null;
return this.data.quotes
? Reference.fromString(this.data.quotes, this.instanceDomain)
: null;
}
public get repliesTo(): Reference | null {
return this.data.replies_to
? Reference.fromString(this.data.replies_to)
? Reference.fromString(this.data.replies_to, this.instanceDomain)
: null;
}