ActivityPub/entities/activity/activityController.go

30 lines
674 B
Go
Raw Normal View History

2020-10-17 10:13:15 +00:00
package activity
import (
"time"
"git.nutfactory.org/hoernschen/ActivityPub/entities/object"
"git.nutfactory.org/hoernschen/ActivityPub/utils"
)
func New(id string, actorOfActivity string, objectOfActivity *object.Object, userId string) (newActivity *Activity) {
published := objectOfActivity.Published
to := objectOfActivity.To
if published == 0 {
published = time.Now().Unix()
}
if to == "" {
to = utils.GenerateFollowersUrl(userId)
}
newActivity = &Activity{
Context: utils.GetDefaultContext(),
Id: id,
Type: "Create",
Actor: actorOfActivity,
Object: objectOfActivity,
Published: published,
To: to,
}
return
}