Repository navigation
Expand file tree
/
Copy pathactor.ts
More file actions
66 lines (54 loc) · 1.75 KB
/
Copy pathactor.ts
File metadata and controls
66 lines (54 loc) · 1.75 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { Column, CreateDateColumn, Index } from "typeorm";
import type { ActorMention } from "../util/activitypub/constants.js";
import { BaseModel } from "./basemodel.js";
export abstract class Actor extends BaseModel {
@CreateDateColumn()
created_date: Date;
/** The remote address of this actor. If this actor is local, it will be null. */
@Column({ nullable: true, type: String })
remote_address: string | null;
@Column({ type: String, nullable: true })
@Index({ unique: true, where: "remote_id IS NOT NULL" })
remote_id: string | null;
/** The domain of this actor. null if local */
@Column({ type: String, nullable: true })
domain: string | null;
/**
* The addresses of the collections related to the remote actor
*/
@Column({ type: "jsonb", nullable: true })
collections: {
inbox: string;
outbox: string;
shared_inbox: string | undefined;
followers?: string;
following?: string;
context?: string;
} | null;
/**
* The private key for this user, used to sign activities sent to external instances
* If this is a remote actor, it will be null.
*/
@Column({ type: String, nullable: true })
private_key: string | null;
/** The public key of this user. Exists on both external and internal users */
@Column({ nullable: true, type: String })
public_key: string;
public get mention(): ActorMention {
return `${this.remote_id ?? this.id}@${this.domain}`;
}
public toPublic(): unknown {
throw new Error("don't");
}
public toPrivate() {
return this.toPublic();
}
// TODO: how do I narrow this class so that it does contain remote_address
/** Whether or not this actor is controlled by us */
public isRemote() {
return !!this.remote_address;
}
public toString() {
return `${this.constructor.name}[${this.mention}]`;
}
}