ActivityPub/entities/activity/activityController.go
2020-10-17 12:13:15 +02:00

29 lines
674 B
Go

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
}