2018-06-22 16:42:38 -04:00
|
|
|
package activitystreams
|
|
|
|
|
|
|
|
|
|
type Person struct {
|
2018-06-22 17:11:07 -04:00
|
|
|
BaseObject
|
2018-06-22 16:42:38 -04:00
|
|
|
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"`
|
2018-08-03 00:22:42 +02:00
|
|
|
Endpoints Endpoints `json:"endpoints"`
|
2018-06-22 16:42:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewPerson(accountRoot string) *Person {
|
|
|
|
|
p := Person{
|
2018-06-22 17:11:07 -04:00
|
|
|
BaseObject: BaseObject{
|
|
|
|
|
Type: "Person",
|
2018-08-03 00:21:06 +02:00
|
|
|
Context: []interface{}{
|
2018-06-22 17:11:07 -04:00
|
|
|
"https://www.w3.org/ns/activitystreams",
|
|
|
|
|
},
|
|
|
|
|
ID: accountRoot,
|
2018-06-22 16:42:38 -04:00
|
|
|
},
|
|
|
|
|
Following: accountRoot + "/following",
|
|
|
|
|
Followers: accountRoot + "/followers",
|
|
|
|
|
Inbox: accountRoot + "/inbox",
|
|
|
|
|
Outbox: accountRoot + "/outbox",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &p
|
|
|
|
|
}
|
2018-06-24 21:08:46 -04:00
|
|
|
|
|
|
|
|
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),
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-25 11:32:12 -04:00
|
|
|
|
|
|
|
|
func (p *Person) SetPrivKey(k []byte) {
|
|
|
|
|
p.PublicKey.privateKey = k
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *Person) GetPrivKey() []byte {
|
|
|
|
|
return p.PublicKey.privateKey
|
|
|
|
|
}
|