Finished Prototype
This commit is contained in:
parent
ea54a27796
commit
6de476260d
30 changed files with 2189 additions and 0 deletions
13
entities/activity/activity.go
Normal file
13
entities/activity/activity.go
Normal 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"`
|
||||
}
|
29
entities/activity/activityController.go
Normal file
29
entities/activity/activityController.go
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue