30 lines
674 B
Go
30 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
|
||
|
}
|