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.

44 line
1.1 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. URL: accountRoot,
  25. Following: accountRoot + "/following",
  26. Followers: accountRoot + "/followers",
  27. Inbox: accountRoot + "/inbox",
  28. Outbox: accountRoot + "/outbox",
  29. }
  30. return &p
  31. }
  32. func (p *Person) AddPubKey(k []byte) {
  33. p.Context = append(p.Context, "https://w3id.org/security/v1")
  34. p.PublicKey = PublicKey{
  35. ID: p.ID + "#main-key",
  36. Owner: p.ID,
  37. PublicKeyPEM: string(k),
  38. }
  39. }