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
|
|
@ -2,7 +2,7 @@ import type { z } from "zod";
|
|||
import { NoteSchema } from "../schemas/note.ts";
|
||||
import type { JSONObject } from "../types.ts";
|
||||
import { NonTextContentFormat, TextContentFormat } from "./contentformat.ts";
|
||||
import { Entity } from "./entity.ts";
|
||||
import { Entity, Reference } from "./entity.ts";
|
||||
|
||||
export class Note extends Entity {
|
||||
public static override name = "Note";
|
||||
|
|
@ -15,6 +15,35 @@ export class Note extends Entity {
|
|||
return NoteSchema.parseAsync(json).then((n) => new Note(n));
|
||||
}
|
||||
|
||||
public get author(): Reference {
|
||||
return Reference.fromString(this.data.author);
|
||||
}
|
||||
|
||||
public get group(): Reference | null {
|
||||
if (
|
||||
!this.data.group ||
|
||||
["public", "followers"].includes(this.data.group)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Reference.fromString(this.data.group);
|
||||
}
|
||||
|
||||
public get mentions(): Reference[] {
|
||||
return this.data.mentions.map((m) => Reference.fromString(m));
|
||||
}
|
||||
|
||||
public get quotes(): Reference | null {
|
||||
return this.data.quotes ? Reference.fromString(this.data.quotes) : null;
|
||||
}
|
||||
|
||||
public get repliesTo(): Reference | null {
|
||||
return this.data.replies_to
|
||||
? Reference.fromString(this.data.replies_to)
|
||||
: null;
|
||||
}
|
||||
|
||||
public get attachments(): NonTextContentFormat[] {
|
||||
return (
|
||||
this.data.attachments?.map((a) => new NonTextContentFormat(a)) ?? []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue