2023-03-28 23:29:47 +02:00
|
|
|
export type Post = {
|
2023-07-31 21:42:31 +02:00
|
|
|
text: string | undefined;
|
2023-03-28 23:29:47 +02:00
|
|
|
cw: string | null;
|
|
|
|
localOnly: boolean;
|
|
|
|
createdAt: Date;
|
2023-07-31 21:42:31 +02:00
|
|
|
visibility: string;
|
2023-03-28 23:29:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export function parse(acct: any): Post {
|
2023-03-31 04:10:03 +02:00
|
|
|
return {
|
2023-07-31 21:42:31 +02:00
|
|
|
text: acct.text || undefined,
|
2023-03-31 04:10:03 +02:00
|
|
|
cw: acct.cw,
|
|
|
|
localOnly: acct.localOnly,
|
|
|
|
createdAt: new Date(acct.createdAt),
|
2023-07-31 21:42:31 +02:00
|
|
|
visibility: "hidden" + (acct.visibility || ""),
|
2023-03-31 04:10:03 +02:00
|
|
|
};
|
2023-03-28 23:29:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function toJson(acct: Post): string {
|
|
|
|
return { text: acct.text, cw: acct.cw, localOnly: acct.localOnly }.toString();
|
|
|
|
}
|