Core components of the web application. https://write.as
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

  1. package activitystreams
  2. type Person struct {
  3. BaseObject
  4. Inbox string `json:"inbox"`
  5. Outbox string `json:"outbox"`
  6. PreferredUsername string `json:"preferredUsername"`
  7. URL string `json:"url"`
  8. Name string `json:"name"`
  9. Icon Image `json:"icon"`
  10. Following string `json:"following"`
  11. Followers string `json:"followers"`
  12. Summary string `json:"summary"`
  13. PublicKey PublicKey `json:"publicKey"`
  14. }
  15. func NewPerson(accountRoot string) *Person {
  16. p := Person{
  17. BaseObject: BaseObject{
  18. Type: "Person",
  19. Context: []string{
  20. "https://www.w3.org/ns/activitystreams",
  21. },
  22. ID: accountRoot,
  23. },
  24. Following: accountRoot + "/following",
  25. Followers: accountRoot + "/followers",
  26. Inbox: accountRoot + "/inbox",
  27. Outbox: accountRoot + "/outbox",
  28. }
  29. return &p
  30. }
  31. func (p *Person) AddPubKey(k []byte) {
  32. p.Context = append(p.Context, "https://w3id.org/security/v1")
  33. p.PublicKey = PublicKey{
  34. ID: p.ID + "#main-key",
  35. Owner: p.ID,
  36. PublicKeyPEM: string(k),
  37. }
  38. }
  39. func (p *Person) SetPrivKey(k []byte) {
  40. p.PublicKey.privateKey = k
  41. }
  42. func (p *Person) GetPrivKey() []byte {
  43. return p.PublicKey.privateKey
  44. }