package activitypub // An Person actor // Ref: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person 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"` } // NewPerson creates an ActivityPub Person func NewPerson(id string) *Person { p := Person{ BaseObject: BaseObject{ Type: "Person", Context: []interface{}{ Namespace, }, ID: id, }, Following: id + "/following", Followers: id + "/followers", Inbox: id + "/inbox", Outbox: id + "/outbox", } return &p } // AddPubKey add public key to Person 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), } } // SetPrivateKey set private key to Person func (p *Person) SetPrivateKey(k []byte) { p.PublicKey.privateKey = k } // GetPrivateKey get private key func (p *Person) GetPrivateKey() []byte { return p.PublicKey.privateKey }