Files
web-core-fr-gp/activitystreams/activity.go
T

72 lines
1.5 KiB
Go
Raw Normal View History

2018-06-24 21:06:26 -04:00
package activitystreams
import (
"time"
)
const (
toPublic = "https://www.w3.org/ns/activitystreams#Public"
)
type Activity struct {
BaseObject
Actor string `json:"actor"`
Published time.Time `json:"published,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
2018-06-24 21:06:26 -04:00
Object *Object `json:"object"`
}
func NewCreateActivity(o *Object) *Activity {
a := Activity{
BaseObject: BaseObject{
Context: []string{
"https://www.w3.org/ns/activitystreams",
},
2018-06-24 21:06:26 -04:00
ID: o.ID + "/activity",
Type: "Create",
},
Actor: o.AttributedTo,
Object: o,
2018-06-24 21:06:26 -04:00
}
return &a
}
type Object struct {
BaseObject
Published time.Time `json:"published"`
Summary *string `json:"summary,omitempty"`
2018-06-24 21:06:26 -04:00
InReplyTo *string `json:"inReplyTo"`
URL string `json:"url"`
AttributedTo string `json:"attributedTo"`
To []string `json:"to"`
CC []string `json:"cc,omitempty"`
2018-07-24 20:09:31 +02:00
Name string `json:"name,omitempty"`
2018-06-24 21:06:26 -04:00
Content string `json:"content"`
ContentMap map[string]string `json:"contentMap,omitempty"`
2018-06-24 21:06:26 -04:00
}
func NewNoteObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Note",
},
To: []string{
toPublic,
},
}
return &o
}
2018-07-24 20:09:31 +02:00
func NewArticleObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Article",
},
To: []string{
toPublic,
},
}
return &o
}