kopia lustrzana https://github.com/reiver/greatape
feat(project): ✨ add activitypub object
rodzic
272c6fe172
commit
af8568a1f1
|
@ -15,3 +15,16 @@ message User {
|
|||
int64 id = 0x00000001;
|
||||
string github = 0x00000003;
|
||||
}
|
||||
|
||||
// | OBJECT: Activity Pub Object
|
||||
message ActivityPubObject {
|
||||
string context = 0x00000002 [json_name = "@context"];
|
||||
string id = 0x00000003;
|
||||
string type = 0x00000004;
|
||||
string actor = 0x00000005;
|
||||
string from = 0x00000006;
|
||||
repeated string to = 0x00000007;
|
||||
string inReplyTo = 0x00000008;
|
||||
string content = 0x00000009;
|
||||
string published = 0x0000000A;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,118 @@ func (x *User) GetGithub() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// | OBJECT: Activity Pub Object
|
||||
type ActivityPubObject struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Context string `protobuf:"bytes,2,opt,name=context,json=@context,proto3" json:"context,omitempty"`
|
||||
Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
|
||||
Actor string `protobuf:"bytes,5,opt,name=actor,proto3" json:"actor,omitempty"`
|
||||
From string `protobuf:"bytes,6,opt,name=from,proto3" json:"from,omitempty"`
|
||||
To []string `protobuf:"bytes,7,rep,name=to,proto3" json:"to,omitempty"`
|
||||
InReplyTo string `protobuf:"bytes,8,opt,name=inReplyTo,proto3" json:"inReplyTo,omitempty"`
|
||||
Content string `protobuf:"bytes,9,opt,name=content,proto3" json:"content,omitempty"`
|
||||
Published string `protobuf:"bytes,10,opt,name=published,proto3" json:"published,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) Reset() {
|
||||
*x = ActivityPubObject{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_objects_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ActivityPubObject) ProtoMessage() {}
|
||||
|
||||
func (x *ActivityPubObject) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_objects_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ActivityPubObject.ProtoReflect.Descriptor instead.
|
||||
func (*ActivityPubObject) Descriptor() ([]byte, []int) {
|
||||
return file_objects_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetContext() string {
|
||||
if x != nil {
|
||||
return x.Context
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetActor() string {
|
||||
if x != nil {
|
||||
return x.Actor
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetFrom() string {
|
||||
if x != nil {
|
||||
return x.From
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetTo() []string {
|
||||
if x != nil {
|
||||
return x.To
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetInReplyTo() string {
|
||||
if x != nil {
|
||||
return x.InReplyTo
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetContent() string {
|
||||
if x != nil {
|
||||
return x.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubObject) GetPublished() string {
|
||||
if x != nil {
|
||||
return x.Published
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_objects_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_objects_proto_rawDesc = []byte{
|
||||
|
@ -142,8 +254,23 @@ var file_objects_proto_rawDesc = []byte{
|
|||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22,
|
||||
0x2e, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x42,
|
||||
0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x22,
|
||||
0xe2, 0x01, 0x0a, 0x11, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x4f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72,
|
||||
0x6f, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x74, 0x6f, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x1c,
|
||||
0x0a, 0x09, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x09, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73,
|
||||
0x68, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69,
|
||||
0x73, 0x68, 0x65, 0x64, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -158,10 +285,11 @@ func file_objects_proto_rawDescGZIP() []byte {
|
|||
return file_objects_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_objects_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_objects_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_objects_proto_goTypes = []interface{}{
|
||||
(*Document)(nil), // 0: protobuf.Document
|
||||
(*User)(nil), // 1: protobuf.User
|
||||
(*Document)(nil), // 0: protobuf.Document
|
||||
(*User)(nil), // 1: protobuf.User
|
||||
(*ActivityPubObject)(nil), // 2: protobuf.ActivityPubObject
|
||||
}
|
||||
var file_objects_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
|
@ -201,6 +329,18 @@ func file_objects_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_objects_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ActivityPubObject); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
|
@ -208,7 +348,7 @@ func file_objects_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_objects_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package contracts
|
||||
|
||||
import . "github.com/xeronith/diamante/contracts/security"
|
||||
|
||||
var ActivityPubObjectPassThroughFilter = func(IActivityPubObject) bool { return true }
|
||||
|
||||
type (
|
||||
ActivityPubObjects []IActivityPubObject
|
||||
ActivityPubObjectIterator func(IActivityPubObject)
|
||||
ActivityPubObjectCondition func(IActivityPubObject) bool
|
||||
ActivityPubObjectFilterPredicate func(IActivityPubObject) bool
|
||||
ActivityPubObjectMapPredicate func(IActivityPubObject) IActivityPubObject
|
||||
ActivityPubObjectCacheCallback func()
|
||||
|
||||
IActivityPubObject interface {
|
||||
// Context returns 'Context' of this 'ActivityPubObject' instance.
|
||||
Context() string
|
||||
// SetContext sets 'Context' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetContext(context string)
|
||||
// Id returns 'Id' of this 'ActivityPubObject' instance.
|
||||
Id() string
|
||||
// SetId sets 'Id' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetId(id string)
|
||||
// Type returns 'Type' of this 'ActivityPubObject' instance.
|
||||
Type() string
|
||||
// SetType sets 'Type' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetType(type_ string)
|
||||
// Actor returns 'Actor' of this 'ActivityPubObject' instance.
|
||||
Actor() string
|
||||
// SetActor sets 'Actor' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetActor(actor string)
|
||||
// From returns 'From' of this 'ActivityPubObject' instance.
|
||||
From() string
|
||||
// SetFrom sets 'From' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetFrom(from string)
|
||||
// To returns 'To' of this 'ActivityPubObject' instance.
|
||||
To() []string
|
||||
// SetTo sets 'To' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetTo(to []string)
|
||||
// InReplyTo returns 'InReplyTo' of this 'ActivityPubObject' instance.
|
||||
InReplyTo() string
|
||||
// SetInReplyTo sets 'InReplyTo' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetInReplyTo(inReplyTo string)
|
||||
// Content returns 'Content' of this 'ActivityPubObject' instance.
|
||||
Content() string
|
||||
// SetContent sets 'Content' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetContent(content string)
|
||||
// Published returns 'Published' of this 'ActivityPubObject' instance.
|
||||
Published() string
|
||||
// SetPublished sets 'Published' in-memory value of this 'ActivityPubObject' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetPublished(published string)
|
||||
}
|
||||
|
||||
IActivityPubObjectCollection interface {
|
||||
Count() int
|
||||
IsEmpty() bool
|
||||
IsNotEmpty() bool
|
||||
HasExactlyOneItem() bool
|
||||
HasAtLeastOneItem() bool
|
||||
First() IActivityPubObject
|
||||
Append(activityPubObject IActivityPubObject)
|
||||
ForEach(ActivityPubObjectIterator)
|
||||
Array() ActivityPubObjects
|
||||
}
|
||||
|
||||
IActivityPubObjectManager interface {
|
||||
ISystemComponent
|
||||
OnCacheChanged(ActivityPubObjectCacheCallback)
|
||||
Count() int
|
||||
Exists(id int64) bool
|
||||
ExistsWhich(condition ActivityPubObjectCondition) bool
|
||||
ListActivityPubObjects(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubObjectCollection
|
||||
GetActivityPubObject(id int64, editor Identity) (IActivityPubObject, error)
|
||||
AddActivityPubObject(editor Identity) (IActivityPubObject, error)
|
||||
AddActivityPubObjectWithCustomId(id int64, editor Identity) (IActivityPubObject, error)
|
||||
AddActivityPubObjectObject(activityPubObject IActivityPubObject, editor Identity) (IActivityPubObject, error)
|
||||
AddActivityPubObjectAtomic(transaction ITransaction, editor Identity) (IActivityPubObject, error)
|
||||
AddActivityPubObjectWithCustomIdAtomic(id int64, transaction ITransaction, editor Identity) (IActivityPubObject, error)
|
||||
AddActivityPubObjectObjectAtomic(transaction ITransaction, activityPubObject IActivityPubObject, editor Identity) (IActivityPubObject, error)
|
||||
Log(source string, editor Identity, payload string)
|
||||
UpdateActivityPubObject(id int64, editor Identity) (IActivityPubObject, error)
|
||||
UpdateActivityPubObjectObject(id int64, activityPubObject IActivityPubObject, editor Identity) (IActivityPubObject, error)
|
||||
UpdateActivityPubObjectAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubObject, error)
|
||||
UpdateActivityPubObjectObjectAtomic(transaction ITransaction, id int64, activityPubObject IActivityPubObject, editor Identity) (IActivityPubObject, error)
|
||||
AddOrUpdateActivityPubObjectObject(id int64, activityPubObject IActivityPubObject, editor Identity) (IActivityPubObject, error)
|
||||
AddOrUpdateActivityPubObjectObjectAtomic(transaction ITransaction, id int64, activityPubObject IActivityPubObject, editor Identity) (IActivityPubObject, error)
|
||||
RemoveActivityPubObject(id int64, editor Identity) (IActivityPubObject, error)
|
||||
RemoveActivityPubObjectAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubObject, error)
|
||||
Find(id int64) IActivityPubObject
|
||||
ForEach(iterator ActivityPubObjectIterator)
|
||||
Filter(predicate ActivityPubObjectFilterPredicate) IActivityPubObjectCollection
|
||||
Map(predicate ActivityPubObjectMapPredicate) IActivityPubObjectCollection
|
||||
}
|
||||
)
|
|
@ -0,0 +1,317 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
. "github.com/xeronith/diamante/contracts/security"
|
||||
"rail.town/infrastructure/app/validators"
|
||||
. "rail.town/infrastructure/components/constants"
|
||||
. "rail.town/infrastructure/components/contracts"
|
||||
"rail.town/infrastructure/components/model/repository"
|
||||
)
|
||||
|
||||
type activityPubObject struct {
|
||||
context string
|
||||
id string
|
||||
type_ string
|
||||
actor string
|
||||
from string
|
||||
to []string
|
||||
inReplyTo string
|
||||
content string
|
||||
published string
|
||||
}
|
||||
|
||||
// noinspection GoUnusedExportedFunction
|
||||
func InitializeActivityPubObject() {
|
||||
_ = ENABLE_SECURITY
|
||||
_ = ENABLE_CUSTOM_ERRORS
|
||||
_ = validators.Initialize
|
||||
_ = repository.Initialize
|
||||
}
|
||||
|
||||
func NewActivityPubObject() (IActivityPubObject, error) {
|
||||
instance := &activityPubObject{}
|
||||
|
||||
if err := instance.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Context() string {
|
||||
return activityPubObject.context
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetContext(value string) {
|
||||
activityPubObject.context = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Id() string {
|
||||
return activityPubObject.id
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetId(value string) {
|
||||
activityPubObject.id = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Type() string {
|
||||
return activityPubObject.type_
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetType(value string) {
|
||||
activityPubObject.type_ = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Actor() string {
|
||||
return activityPubObject.actor
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetActor(value string) {
|
||||
activityPubObject.actor = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) From() string {
|
||||
return activityPubObject.from
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetFrom(value string) {
|
||||
activityPubObject.from = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) To() []string {
|
||||
return activityPubObject.to
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetTo(value []string) {
|
||||
activityPubObject.to = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) InReplyTo() string {
|
||||
return activityPubObject.inReplyTo
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetInReplyTo(value string) {
|
||||
activityPubObject.inReplyTo = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Content() string {
|
||||
return activityPubObject.content
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetContent(value string) {
|
||||
activityPubObject.content = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Published() string {
|
||||
return activityPubObject.published
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) SetPublished(value string) {
|
||||
activityPubObject.published = value
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (activityPubObject *activityPubObject) String() string {
|
||||
return fmt.Sprintf("ActivityPubObject (Id: %d)", 0)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
type activityPubObjects struct {
|
||||
collection ActivityPubObjects
|
||||
}
|
||||
|
||||
// NewActivityPubObjects creates an empty collection of 'Activity Pub Object' which is not thread-safe.
|
||||
func NewActivityPubObjects() IActivityPubObjectCollection {
|
||||
return &activityPubObjects{
|
||||
collection: make(ActivityPubObjects, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) Count() int {
|
||||
return len(activityPubObjects.collection)
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) IsEmpty() bool {
|
||||
return len(activityPubObjects.collection) == 0
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) IsNotEmpty() bool {
|
||||
return len(activityPubObjects.collection) > 0
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) HasExactlyOneItem() bool {
|
||||
return len(activityPubObjects.collection) == 1
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) HasAtLeastOneItem() bool {
|
||||
return len(activityPubObjects.collection) >= 1
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) First() IActivityPubObject {
|
||||
return activityPubObjects.collection[0]
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) Append(activityPubObject IActivityPubObject) {
|
||||
activityPubObjects.collection = append(activityPubObjects.collection, activityPubObject)
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) ForEach(iterator ActivityPubObjectIterator) {
|
||||
if iterator == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, value := range activityPubObjects.collection {
|
||||
iterator(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (activityPubObjects *activityPubObjects) Array() ActivityPubObjects {
|
||||
return activityPubObjects.collection
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (dispatcher *dispatcher) ActivityPubObjectExists(id int64) bool {
|
||||
return dispatcher.conductor.ActivityPubObjectManager().Exists(id)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ActivityPubObjectExistsWhich(condition ActivityPubObjectCondition) bool {
|
||||
return dispatcher.conductor.ActivityPubObjectManager().ExistsWhich(condition)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ListActivityPubObjects() IActivityPubObjectCollection {
|
||||
return dispatcher.conductor.ActivityPubObjectManager().ListActivityPubObjects(0, 0, "", dispatcher.identity)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ForEachActivityPubObject(iterator ActivityPubObjectIterator) {
|
||||
dispatcher.conductor.ActivityPubObjectManager().ForEach(iterator)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) FilterActivityPubObjects(predicate ActivityPubObjectFilterPredicate) IActivityPubObjectCollection {
|
||||
return dispatcher.conductor.ActivityPubObjectManager().Filter(predicate)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) MapActivityPubObjects(predicate ActivityPubObjectMapPredicate) IActivityPubObjectCollection {
|
||||
return dispatcher.conductor.ActivityPubObjectManager().Map(predicate)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetActivityPubObject(id int64) IActivityPubObject {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().GetActivityPubObject(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AddActivityPubObject() IActivityPubObject {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().AddActivityPubObjectAtomic(transaction, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
} else {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().AddActivityPubObject(dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AddActivityPubObjectWithCustomId(id int64) IActivityPubObject {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().AddActivityPubObjectWithCustomIdAtomic(id, transaction, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
} else {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().AddActivityPubObjectWithCustomId(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) LogActivityPubObject(source string, payload string) {
|
||||
dispatcher.conductor.ActivityPubObjectManager().Log(source, dispatcher.identity, payload)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) UpdateActivityPubObject(id int64) IActivityPubObject {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().UpdateActivityPubObjectAtomic(transaction, id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
} else {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().UpdateActivityPubObject(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// noinspection GoUnusedParameter
|
||||
func (dispatcher *dispatcher) UpdateActivityPubObjectObject(object IObject, activityPubObject IActivityPubObject) IActivityPubObject {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().UpdateActivityPubObjectAtomic(transaction, object.Id(), dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
} else {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().UpdateActivityPubObject(object.Id(), dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AddOrUpdateActivityPubObjectObject(object IObject, activityPubObject IActivityPubObject) IActivityPubObject {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().AddOrUpdateActivityPubObjectObjectAtomic(transaction, object.Id(), activityPubObject, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
} else {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().AddOrUpdateActivityPubObjectObject(object.Id(), activityPubObject, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) RemoveActivityPubObject(id int64) IActivityPubObject {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().RemoveActivityPubObjectAtomic(transaction, id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
} else {
|
||||
if activityPubObject, err := dispatcher.conductor.ActivityPubObjectManager().RemoveActivityPubObject(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubObject
|
||||
}
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue