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.

59 lines
1.3 KiB

  1. package activitystreams
  2. import (
  3. "time"
  4. )
  5. const (
  6. toPublic = "https://www.w3.org/ns/activitystreams#Public"
  7. )
  8. type Activity struct {
  9. BaseObject
  10. Actor string `json:"actor"`
  11. Published time.Time `json:"published,omitempty"`
  12. To []string `json:"to,omitempty"`
  13. CC []string `json:"cc,omitempty"`
  14. Object *Object `json:"object"`
  15. }
  16. func NewCreateActivity(o *Object) *Activity {
  17. a := Activity{
  18. BaseObject: BaseObject{
  19. Context: []string{
  20. "https://www.w3.org/ns/activitystreams",
  21. },
  22. ID: o.ID + "/activity",
  23. Type: "Create",
  24. },
  25. Actor: o.AttributedTo,
  26. Object: o,
  27. }
  28. return &a
  29. }
  30. type Object struct {
  31. BaseObject
  32. Published time.Time `json:"published"`
  33. Summary *string `json:"summary,omitempty"`
  34. InReplyTo *string `json:"inReplyTo"`
  35. URL string `json:"url"`
  36. AttributedTo string `json:"attributedTo"`
  37. To []string `json:"to"`
  38. CC []string `json:"cc,omitempty"`
  39. Content string `json:"content"`
  40. ContentMap map[string]string `json:"contentMap,omitempty"`
  41. }
  42. func NewNoteObject() *Object {
  43. o := Object{
  44. BaseObject: BaseObject{
  45. Type: "Note",
  46. },
  47. To: []string{
  48. toPublic,
  49. },
  50. }
  51. return &o
  52. }