Sorted constants a little ActivityStreams stuff now have their own BaseApChain types
438 lines
9.8 KiB
Go
438 lines
9.8 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
|
|
}
|
|
|
|
type FollowersData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (attributedtodata *FollowersData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return attributedtodata.FullIdType.Next, true
|
|
}
|
|
|
|
func (attributedtodata *FollowersData) MarshalToMap() map[string]any {
|
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_FOLLOWERS)
|
|
}
|
|
|
|
type FollowingData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (attributedtodata *FollowingData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return attributedtodata.FullIdType.Next, true
|
|
}
|
|
|
|
func (attributedtodata *FollowingData) MarshalToMap() map[string]any {
|
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_FOLLOWING)
|
|
}
|
|
|
|
type HrefData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (attributedtodata *HrefData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return attributedtodata.FullIdType.Next, true
|
|
}
|
|
|
|
func (attributedtodata *HrefData) MarshalToMap() map[string]any {
|
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_HREF)
|
|
}
|
|
|
|
type IconData struct {
|
|
Next BaseApChain
|
|
Media Media
|
|
}
|
|
|
|
func (icondata *IconData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return icondata.Next, true
|
|
}
|
|
|
|
func (icondata *IconData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
icondata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_ICON,
|
|
[]map[string]any{icondata.Media.Marshal()},
|
|
)
|
|
}
|
|
|
|
type ImageData struct {
|
|
Next BaseApChain
|
|
Media Media
|
|
}
|
|
|
|
func (icondata *ImageData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return icondata.Next, true
|
|
}
|
|
|
|
func (icondata *ImageData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
icondata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_IMAGE_ATTRIBUTE,
|
|
[]map[string]any{icondata.Media.Marshal()},
|
|
)
|
|
}
|
|
|
|
type MediaTypeData struct {
|
|
Next BaseApChain
|
|
Type string
|
|
}
|
|
|
|
func (mediatypedata *MediaTypeData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return mediatypedata.Next, true
|
|
}
|
|
|
|
func (mediatypedata *MediaTypeData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
mediatypedata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_MEDIATYPE,
|
|
ValueValue[string]{
|
|
Value: mediatypedata.Type,
|
|
Type: nil,
|
|
OtherThings: map[string]any{},
|
|
}.Marshal(),
|
|
)
|
|
}
|
|
|
|
type NameData struct {
|
|
Next BaseApChain
|
|
Name ValueValue[string]
|
|
}
|
|
|
|
func (namedata *NameData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return namedata.Next, true
|
|
}
|
|
|
|
func (namedata *NameData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
namedata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_NAME,
|
|
[]map[string]any{namedata.Name.Marshal()},
|
|
)
|
|
}
|
|
|
|
type OutboxData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (attributedtodata *OutboxData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return attributedtodata.FullIdType.Next, true
|
|
}
|
|
|
|
func (attributedtodata *OutboxData) MarshalToMap() map[string]any {
|
|
return attributedtodata.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_HREF)
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
type PreferredNameData struct {
|
|
Next BaseApChain
|
|
Name ValueValue[string]
|
|
}
|
|
|
|
func (namedata *PreferredNameData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return namedata.Next, true
|
|
}
|
|
|
|
func (namedata *PreferredNameData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
namedata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_PREFFEREDUSERNAME,
|
|
[]map[string]any{namedata.Name.Marshal()},
|
|
)
|
|
}
|
|
|
|
type PublishedData struct {
|
|
Next BaseApChain
|
|
Timestamp time.Time
|
|
}
|
|
|
|
func (publisheddata *PublishedData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return publisheddata.Next, true
|
|
}
|
|
|
|
func (publisheddata *PublishedData) MarshalToMap() map[string]any {
|
|
m := publisheddata.Next.MarshalToMap()
|
|
m[KEY_ACTIVITYSTREAMS_PUBLISHED] = timeToXmlTime(publisheddata.Timestamp)
|
|
return m
|
|
}
|
|
|
|
type RestrictedFollowData struct {
|
|
Next BaseApChain
|
|
Value ValueValue[bool]
|
|
}
|
|
|
|
func (namedata *RestrictedFollowData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return namedata.Next, true
|
|
}
|
|
|
|
func (namedata *RestrictedFollowData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
namedata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_RESTRICTED_FOLLOW,
|
|
[]map[string]any{namedata.Value.Marshal()},
|
|
)
|
|
}
|
|
|
|
type RepliesData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (object *RepliesData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return object.FullIdType.Next, true
|
|
}
|
|
|
|
func (object *RepliesData) MarshalToMap() map[string]any {
|
|
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_REPLIES)
|
|
}
|
|
|
|
type SharedInboxData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (object *SharedInboxData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return object.FullIdType.Next, true
|
|
}
|
|
|
|
func (object *SharedInboxData) MarshalToMap() map[string]any {
|
|
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_SHAREDINBOX)
|
|
}
|
|
|
|
type SummaryData struct {
|
|
Next BaseApChain
|
|
Name ValueValue[string]
|
|
}
|
|
|
|
func (namedata *SummaryData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return namedata.Next, true
|
|
}
|
|
|
|
func (namedata *SummaryData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
namedata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_SUMMARY,
|
|
[]map[string]any{namedata.Name.Marshal()},
|
|
)
|
|
}
|
|
|
|
type SensitiveData struct {
|
|
Next BaseApChain
|
|
Name ValueValue[bool]
|
|
}
|
|
|
|
func (namedata *SensitiveData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return namedata.Next, true
|
|
}
|
|
|
|
func (namedata *SensitiveData) MarshalToMap() map[string]any {
|
|
return appendWithKey(
|
|
namedata.Next.MarshalToMap(),
|
|
KEY_ACTIVITYSTREAMS_SENSITIVE,
|
|
[]map[string]any{namedata.Name.Marshal()},
|
|
)
|
|
}
|
|
|
|
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
|
|
type UrlData struct {
|
|
FullIdType
|
|
}
|
|
|
|
func (object *UrlData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return object.FullIdType.Next, true
|
|
}
|
|
|
|
func (object *UrlData) MarshalToMap() map[string]any {
|
|
return object.FullIdType.MarshalToMapWithName(KEY_ACTIVITYSTREAMS_SHAREDINBOX)
|
|
}
|
|
|
|
// Updated
|
|
type UpdatedData struct {
|
|
Next BaseApChain
|
|
Timestamp time.Time
|
|
}
|
|
|
|
func (publisheddata *UpdatedData) GetSelfOrBase() (BaseApChain, bool) {
|
|
return publisheddata.Next, true
|
|
}
|
|
|
|
func (publisheddata *UpdatedData) MarshalToMap() map[string]any {
|
|
m := publisheddata.Next.MarshalToMap()
|
|
m[KEY_ACTIVITYSTREAMS_PUBLISHED] = timeToXmlTime(publisheddata.Timestamp)
|
|
return m
|
|
}
|