Finished Prototype

This commit is contained in:
Hoernschen 2020-10-17 12:13:15 +02:00
parent ea54a27796
commit 6de476260d
30 changed files with 2189 additions and 0 deletions

View file

@ -0,0 +1,13 @@
package activity
import "git.nutfactory.org/hoernschen/ActivityPub/entities/object"
type Activity struct {
Context string `json:"@context,omitempty"`
Id string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Actor string `json:"actor,omitempty"`
Object *object.Object `json:"object,omitempty"`
Published int64 `json:"published,omitempty"`
To string `json:"to,omitempty"`
}

View file

@ -0,0 +1,29 @@
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
}