221 lines
4.7 KiB
Go
221 lines
4.7 KiB
Go
package goap
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gitlab.com/mstarongitlab/goutils/maputils"
|
|
"gitlab.com/mstarongitlab/goutils/sliceutils"
|
|
)
|
|
|
|
type ActorData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (actor *ActorData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return actor.FullIdType.GetSelfOrBase()
|
|
}
|
|
|
|
func (actor *ActorData) MarshalToMap() map[string]any {
|
|
return actor.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_ACTOR)
|
|
}
|
|
|
|
type AlsoKnownAsData struct {
|
|
Next BaseApChain
|
|
Urls []string
|
|
}
|
|
|
|
func (cc *AlsoKnownAsData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return cc.Next, true
|
|
}
|
|
|
|
func (cc *AlsoKnownAsData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
cc.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_ALSOKNOWNAS,
|
|
sliceutils.Map(cc.Urls, func(t string) map[string]any {
|
|
return map[string]any{KEY_ID: t}
|
|
}),
|
|
)
|
|
}
|
|
|
|
type AttachmentsData struct {
|
|
Next BaseApChain
|
|
Attachments []Attachment
|
|
}
|
|
|
|
func (attachmentsdata *AttachmentsData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return attachmentsdata.Next, true
|
|
}
|
|
|
|
func (attachmentsdata *AttachmentsData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
attachmentsdata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_ATTACHMENTS,
|
|
sliceutils.Map(
|
|
attachmentsdata.Attachments,
|
|
func(t Attachment) map[string]any { return t.Marshal() },
|
|
),
|
|
)
|
|
}
|
|
|
|
type AttributedToData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (attributedtodata *AttributedToData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return attributedtodata.FullIdType.Next, true
|
|
}
|
|
|
|
func (attributedtodata *AttributedToData) MarshalToMap() map[string]any {
|
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_ATTRIBUTEDTO)
|
|
}
|
|
|
|
type CCData struct {
|
|
Next BaseApChain
|
|
Targets []string
|
|
}
|
|
|
|
func (cc *CCData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return cc.Next, true
|
|
}
|
|
|
|
func (cc *CCData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
cc.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_CC,
|
|
sliceutils.Map(cc.Targets, func(t string) map[string]any {
|
|
return map[string]any{KEY_ID: t}
|
|
}),
|
|
)
|
|
}
|
|
|
|
// Content
|
|
|
|
type ContentData struct {
|
|
Next BaseApChain
|
|
Content []ValueValue[string]
|
|
}
|
|
|
|
func (contentdata *ContentData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return contentdata.Next, true
|
|
}
|
|
|
|
func (contentdata *ContentData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
contentdata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_CONTENT,
|
|
sliceutils.Map(contentdata.Content, func(t ValueValue[string]) map[string]any {
|
|
return t.Marshal()
|
|
}),
|
|
)
|
|
}
|
|
|
|
type EndpointsData struct {
|
|
Next BaseApChain
|
|
Endpoints map[string]string
|
|
}
|
|
|
|
func (endpointsdata *EndpointsData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return endpointsdata.Next, true
|
|
}
|
|
|
|
func (endpointsdata *EndpointsData) MarshalToMap() map[string]any {
|
|
m := endpointsdata.Next.MarshalToMap()
|
|
arr := []map[string]any{}
|
|
for k, v := range endpointsdata.Endpoints {
|
|
arr = append(arr, map[string]any{
|
|
k: []map[string]any{{KEY_ID: v}},
|
|
})
|
|
}
|
|
m[KEY_ACTIVITYSTREAMS_ENDPOINTS] = arr
|
|
return m
|
|
}
|
|
|
|
// Endpoints
|
|
// Followers
|
|
// Following
|
|
// Href
|
|
// Icon
|
|
// Image
|
|
// MediaType
|
|
// Name
|
|
// Outbox
|
|
|
|
type ObjectData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (object *ObjectData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return object.FullIdType.Next, true
|
|
}
|
|
|
|
func (object *ObjectData) MarshalToMap() map[string]any {
|
|
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_OBJECT)
|
|
}
|
|
|
|
// PrefferedUsername
|
|
|
|
type PublishedData struct {
|
|
Next BaseApChain
|
|
Timestamp time.Time
|
|
}
|
|
|
|
func (publisheddata *PublishedData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return publisheddata.Next, true
|
|
}
|
|
|
|
// Convert the chain to a map
|
|
// Should include the rest of the chain (extend the map the underlying object returns)
|
|
func (publisheddata *PublishedData) MarshalToMap() map[string]any {
|
|
m := publisheddata.Next.MarshalToMap()
|
|
m[KEY_ACTIVITYSTREAMS_PUBLISHED] = timeToXmlTime(publisheddata.Timestamp)
|
|
return m
|
|
}
|
|
|
|
// Public
|
|
// RestrictedFollow
|
|
// Replies
|
|
// SharedInbox
|
|
// Summary
|
|
// Sensitive
|
|
|
|
type TagData struct {
|
|
Next BaseApChain
|
|
Tags []string
|
|
}
|
|
|
|
func (tagdata *TagData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return tagdata.Next, true
|
|
}
|
|
|
|
func (tagdata *TagData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
tagdata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_TAG,
|
|
sliceutils.Map(tagdata.Tags, func(t string) map[string]any {
|
|
return map[string]any{KEY_ID: t}
|
|
}),
|
|
)
|
|
}
|
|
|
|
type ToData struct {
|
|
Next BaseApChain
|
|
Targets []string
|
|
}
|
|
|
|
func (cc *ToData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return cc.Next, true
|
|
}
|
|
|
|
func (cc *ToData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
cc.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_TO,
|
|
sliceutils.Map(cc.Targets, func(t string) map[string]any {
|
|
return map[string]any{KEY_ID: t}
|
|
}),
|
|
)
|
|
}
|
|
|
|
// Url
|
|
// Updated
|