all repos — underbbs @ d7600f28fcbe1e5d86e33c95195d75513e6e868d

decentralized social media client

ts/message.ts (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 }