underbbs/ts/message.ts

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-04-28 18:16:23 +00:00
import {NDKEvent} from "@nostr-dev-kit/ndk"
import * as masto from "masto";
type APStatus = masto.mastodon.v1.Status;
export class Message {
public author: Author = new Author();
public protocol: string = "";
public content: string = "";
public attachments: Attachment[] = [];
public replyTo: Message | null = null;
public replies: Message[] = [];
public mentions: Author[] = [];
public created: Date = new Date();
public edited: Date = new Date();
public visibility: string = "public";
// this will contain additional data about what kind of message it is
public aux: any | null = null;
public static fromNostr(event: NDKEvent): Message {
let self = new Message();
// build out the message based on the contents of event
return self;
}
public static fromMasto(status: APStatus): Message {
let self = new Message();
// build out the message based on the contents of status
return self;
}
}
export class Author {
public id: string = "";
public name: string = "";
public profileData: string = "";
public messages: Message[] = [];
}
export class Attachment {
public file: Uint8Array = new Uint8Array();
public altText: string = "";
public filename: string = "";
}
export default { Message, Attachment, Author }