/
person.go
51 lines (45 loc) · 1.26 KB
/
person.go
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
package activitystreams
type Person struct {
BaseObject
Inbox string `json:"inbox"`
Outbox string `json:"outbox"`
PreferredUsername string `json:"preferredUsername"`
URL string `json:"url"`
Name string `json:"name"`
Icon Image `json:"icon"`
Following string `json:"following"`
Followers string `json:"followers"`
Summary string `json:"summary"`
PublicKey PublicKey `json:"publicKey"`
Endpoints Endpoints `json:"endpoints"`
}
func NewPerson(accountRoot string) *Person {
p := Person{
BaseObject: BaseObject{
Type: "Person",
Context: []interface{}{
Namespace,
},
ID: accountRoot,
},
Following: accountRoot + "/following",
Followers: accountRoot + "/followers",
Inbox: accountRoot + "/inbox",
Outbox: accountRoot + "/outbox",
}
return &p
}
func (p *Person) AddPubKey(k []byte) {
p.Context = append(p.Context, "https://w3id.org/security/v1")
p.PublicKey = PublicKey{
ID: p.ID + "#main-key",
Owner: p.ID,
PublicKeyPEM: string(k),
}
}
func (p *Person) SetPrivKey(k []byte) {
p.PublicKey.privateKey = k
}
func (p *Person) GetPrivKey() []byte {
return p.PublicKey.privateKey
}