kopia lustrzana https://github.com/reiver/greatape
feat(activitypub): ✨ add activity
rodzic
7bc11c4537
commit
b386a8c24d
|
@ -296,6 +296,125 @@ func (x *ActivityPubObject) GetPublished() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
type ActivityPubActivity 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"`
|
||||
Object *ActivityPubObject `protobuf:"bytes,6,opt,name=object,proto3" json:"object,omitempty"`
|
||||
From string `protobuf:"bytes,7,opt,name=from,proto3" json:"from,omitempty"`
|
||||
To []string `protobuf:"bytes,8,rep,name=to,proto3" json:"to,omitempty"`
|
||||
InReplyTo string `protobuf:"bytes,9,opt,name=inReplyTo,proto3" json:"inReplyTo,omitempty"`
|
||||
Content string `protobuf:"bytes,10,opt,name=content,proto3" json:"content,omitempty"`
|
||||
Published string `protobuf:"bytes,11,opt,name=published,proto3" json:"published,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) Reset() {
|
||||
*x = ActivityPubActivity{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_objects_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ActivityPubActivity) ProtoMessage() {}
|
||||
|
||||
func (x *ActivityPubActivity) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_objects_proto_msgTypes[4]
|
||||
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 ActivityPubActivity.ProtoReflect.Descriptor instead.
|
||||
func (*ActivityPubActivity) Descriptor() ([]byte, []int) {
|
||||
return file_objects_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetContext() string {
|
||||
if x != nil {
|
||||
return x.Context
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetActor() string {
|
||||
if x != nil {
|
||||
return x.Actor
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetObject() *ActivityPubObject {
|
||||
if x != nil {
|
||||
return x.Object
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetFrom() string {
|
||||
if x != nil {
|
||||
return x.From
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetTo() []string {
|
||||
if x != nil {
|
||||
return x.To
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetInReplyTo() string {
|
||||
if x != nil {
|
||||
return x.InReplyTo
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetContent() string {
|
||||
if x != nil {
|
||||
return x.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ActivityPubActivity) GetPublished() string {
|
||||
if x != nil {
|
||||
return x.Published
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_objects_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_objects_proto_rawDesc = []byte{
|
||||
|
@ -325,8 +444,26 @@ var file_objects_proto_rawDesc = []byte{
|
|||
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,
|
||||
0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x22, 0x99, 0x02, 0x0a, 0x13, 0x41, 0x63,
|
||||
0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74,
|
||||
0x79, 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, 0x33, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x4f, 0x62, 0x6a,
|
||||
0x65, 0x63, 0x74, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66,
|
||||
0x72, 0x6f, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12,
|
||||
0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x18, 0x09, 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, 0x0a, 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, 0x0b, 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 (
|
||||
|
@ -341,19 +478,21 @@ func file_objects_proto_rawDescGZIP() []byte {
|
|||
return file_objects_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_objects_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_objects_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_objects_proto_goTypes = []interface{}{
|
||||
(*Error)(nil), // 0: protobuf.Error
|
||||
(*Document)(nil), // 1: protobuf.Document
|
||||
(*User)(nil), // 2: protobuf.User
|
||||
(*ActivityPubObject)(nil), // 3: protobuf.ActivityPubObject
|
||||
(*Error)(nil), // 0: protobuf.Error
|
||||
(*Document)(nil), // 1: protobuf.Document
|
||||
(*User)(nil), // 2: protobuf.User
|
||||
(*ActivityPubObject)(nil), // 3: protobuf.ActivityPubObject
|
||||
(*ActivityPubActivity)(nil), // 4: protobuf.ActivityPubActivity
|
||||
}
|
||||
var file_objects_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
3, // 0: protobuf.ActivityPubActivity.object:type_name -> protobuf.ActivityPubObject
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_objects_proto_init() }
|
||||
|
@ -410,6 +549,18 @@ func file_objects_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_objects_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ActivityPubActivity); 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{
|
||||
|
@ -417,7 +568,7 @@ func file_objects_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_objects_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
@ -5,8 +5,8 @@ package protobuf;
|
|||
option go_package = "./";
|
||||
|
||||
message Error {
|
||||
string message = 1;
|
||||
string description = 2;
|
||||
string message = 0x00000001;
|
||||
string description = 0x00000002;
|
||||
}
|
||||
|
||||
message Document {
|
||||
|
@ -30,3 +30,16 @@ message ActivityPubObject {
|
|||
string content = 0x00000009;
|
||||
string published = 0x0000000A;
|
||||
}
|
||||
|
||||
message ActivityPubActivity {
|
||||
string context = 0x00000002 [json_name = "@context"];
|
||||
string id = 0x00000003;
|
||||
string type = 0x00000004;
|
||||
string actor = 0x00000005;
|
||||
ActivityPubObject object = 0x00000006;
|
||||
string from = 0x00000007;
|
||||
repeated string to = 0x00000008;
|
||||
string inReplyTo = 0x00000009;
|
||||
string content = 0x0000000A;
|
||||
string published = 0x0000000B;
|
||||
}
|
|
@ -21,7 +21,7 @@ const (
|
|||
)
|
||||
|
||||
// API: SystemCall
|
||||
// ------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
type SystemCallRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -108,7 +108,7 @@ func (*SystemCallResult) Descriptor() ([]byte, []int) {
|
|||
}
|
||||
|
||||
// API: Echo
|
||||
// ------------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
type EchoRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
|
|
@ -7,16 +7,16 @@ option go_package = "./";
|
|||
import "objects.proto";
|
||||
|
||||
// API: SystemCall
|
||||
//------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
message SystemCallRequest {
|
||||
string command = 1;
|
||||
string command = 0x00000001;
|
||||
}
|
||||
|
||||
message SystemCallResult {
|
||||
}
|
||||
|
||||
// API: Echo
|
||||
//------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
||||
message EchoRequest {
|
||||
Document document = 0x00000001;
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ message EchoResult {
|
|||
Document document = 0x00000001;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------
|
|
@ -11,9 +11,13 @@ import (
|
|||
"rail.town/infrastructure/components/core"
|
||||
)
|
||||
|
||||
// noinspection GoUnusedParameter
|
||||
func SystemCallService(context IContext, input *SystemCallRequest) (result *SystemCallResult, err error) {
|
||||
core.Conductor.LogRemoteCall(context, INITIALIZE, "system_call", input, result, err)
|
||||
defer func() { core.Conductor.LogRemoteCall(context, FINALIZE, "system_call", input, result, err) }()
|
||||
conductor := core.Conductor
|
||||
_ = SYSTEM_CALL_REQUEST
|
||||
|
||||
conductor.LogRemoteCall(context, INITIALIZE, "system_call", input, result, err)
|
||||
defer func() { conductor.LogRemoteCall(context, FINALIZE, "system_call", input, result, err) }()
|
||||
|
||||
context.Logger().SysCall(fmt.Sprintf("SYSCALL: %s", input.Command))
|
||||
|
||||
|
@ -22,6 +26,8 @@ func SystemCallService(context IContext, input *SystemCallRequest) (result *Syst
|
|||
return nil, ERROR_NOT_IMPLEMENTED
|
||||
}
|
||||
|
||||
result = context.ResultContainer().(*SystemCallResult)
|
||||
|
||||
switch args[0] {
|
||||
case "reload":
|
||||
if len(args) < 2 {
|
||||
|
@ -29,18 +35,18 @@ func SystemCallService(context IContext, input *SystemCallRequest) (result *Syst
|
|||
}
|
||||
|
||||
componentName := args[1]
|
||||
if component := core.Conductor.GetSystemComponent(componentName); component == nil {
|
||||
if component := conductor.GetSystemComponent(componentName); component == nil {
|
||||
return nil, ERROR_SYSTEM_COMPONENT_NOT_FOUND
|
||||
} else if err := component.Reload(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return context.ResultContainer().(*SystemCallResult), nil
|
||||
return result, nil
|
||||
}
|
||||
default:
|
||||
if err := context.SystemCall(args); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return context.ResultContainer().(*SystemCallResult), nil
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,34 +8,36 @@ const ENABLE_CUSTOM_ERRORS = true
|
|||
// noinspection GoSnakeCaseUsage
|
||||
const (
|
||||
// SYSTEM_ERRORS
|
||||
ERROR_MESSAGE_INITIALIZE = "ERROR_MESSAGE_INITIALIZE"
|
||||
ERROR_MESSAGE_NOT_IMPLEMENTED = "ERROR_MESSAGE_NOT_IMPLEMENTED"
|
||||
ERROR_MESSAGE_OPERATION_FAILED = "ERROR_MESSAGE_OPERATION_FAILED"
|
||||
ERROR_MESSAGE_OPERATION_NOT_SUPPORTED = "ERROR_MESSAGE_OPERATION_NOT_SUPPORTED"
|
||||
ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES = "ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES"
|
||||
ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND = "ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND"
|
||||
ERROR_MESSAGE_DOCUMENT_NOT_FOUND = "ERROR_MESSAGE_DOCUMENT_NOT_FOUND"
|
||||
ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND = "ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND"
|
||||
ERROR_MESSAGE_IDENTITY_NOT_FOUND = "ERROR_MESSAGE_IDENTITY_NOT_FOUND"
|
||||
ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND = "ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND"
|
||||
ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND = "ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND"
|
||||
ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND = "ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND"
|
||||
ERROR_MESSAGE_CATEGORY_NOT_FOUND = "ERROR_MESSAGE_CATEGORY_NOT_FOUND"
|
||||
ERROR_MESSAGE_USER_NOT_FOUND = "ERROR_MESSAGE_USER_NOT_FOUND"
|
||||
ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND = "ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND"
|
||||
ERROR_MESSAGE_SPI_NOT_FOUND = "ERROR_MESSAGE_SPI_NOT_FOUND"
|
||||
ERROR_MESSAGE_UNKNOWN_DOCUMENT = "ERROR_MESSAGE_UNKNOWN_DOCUMENT"
|
||||
ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE = "ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE"
|
||||
ERROR_MESSAGE_UNKNOWN_IDENTITY = "ERROR_MESSAGE_UNKNOWN_IDENTITY"
|
||||
ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL = "ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL"
|
||||
ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY = "ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY"
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE = "ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE"
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY = "ERROR_MESSAGE_UNKNOWN_CATEGORY"
|
||||
ERROR_MESSAGE_UNKNOWN_USER = "ERROR_MESSAGE_UNKNOWN_USER"
|
||||
ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT = "ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT"
|
||||
ERROR_MESSAGE_UNKNOWN_SPI = "ERROR_MESSAGE_UNKNOWN_SPI"
|
||||
ERROR_MESSAGE_INVALID_ID = "ERROR_MESSAGE_INVALID_ID"
|
||||
ERROR_MESSAGE_INVALID_PARAMETERS = "ERROR_MESSAGE_INVALID_PARAMETERS"
|
||||
ERROR_MESSAGE_INITIALIZE = "ERROR_MESSAGE_INITIALIZE"
|
||||
ERROR_MESSAGE_NOT_IMPLEMENTED = "ERROR_MESSAGE_NOT_IMPLEMENTED"
|
||||
ERROR_MESSAGE_OPERATION_FAILED = "ERROR_MESSAGE_OPERATION_FAILED"
|
||||
ERROR_MESSAGE_OPERATION_NOT_SUPPORTED = "ERROR_MESSAGE_OPERATION_NOT_SUPPORTED"
|
||||
ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES = "ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES"
|
||||
ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND = "ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND"
|
||||
ERROR_MESSAGE_DOCUMENT_NOT_FOUND = "ERROR_MESSAGE_DOCUMENT_NOT_FOUND"
|
||||
ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND = "ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND"
|
||||
ERROR_MESSAGE_IDENTITY_NOT_FOUND = "ERROR_MESSAGE_IDENTITY_NOT_FOUND"
|
||||
ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND = "ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND"
|
||||
ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND = "ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND"
|
||||
ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND = "ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND"
|
||||
ERROR_MESSAGE_CATEGORY_NOT_FOUND = "ERROR_MESSAGE_CATEGORY_NOT_FOUND"
|
||||
ERROR_MESSAGE_USER_NOT_FOUND = "ERROR_MESSAGE_USER_NOT_FOUND"
|
||||
ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND = "ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND"
|
||||
ERROR_MESSAGE_ACTIVITY_PUB_ACTIVITY_NOT_FOUND = "ERROR_MESSAGE_ACTIVITY_PUB_ACTIVITY_NOT_FOUND"
|
||||
ERROR_MESSAGE_SPI_NOT_FOUND = "ERROR_MESSAGE_SPI_NOT_FOUND"
|
||||
ERROR_MESSAGE_UNKNOWN_DOCUMENT = "ERROR_MESSAGE_UNKNOWN_DOCUMENT"
|
||||
ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE = "ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE"
|
||||
ERROR_MESSAGE_UNKNOWN_IDENTITY = "ERROR_MESSAGE_UNKNOWN_IDENTITY"
|
||||
ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL = "ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL"
|
||||
ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY = "ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY"
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE = "ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE"
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY = "ERROR_MESSAGE_UNKNOWN_CATEGORY"
|
||||
ERROR_MESSAGE_UNKNOWN_USER = "ERROR_MESSAGE_UNKNOWN_USER"
|
||||
ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT = "ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT"
|
||||
ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_ACTIVITY = "ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_ACTIVITY"
|
||||
ERROR_MESSAGE_UNKNOWN_SPI = "ERROR_MESSAGE_UNKNOWN_SPI"
|
||||
ERROR_MESSAGE_INVALID_ID = "ERROR_MESSAGE_INVALID_ID"
|
||||
ERROR_MESSAGE_INVALID_PARAMETERS = "ERROR_MESSAGE_INVALID_PARAMETERS"
|
||||
// CUSTOM_ERRORS
|
||||
ERROR_MESSAGE_DATA_INTEGRITY_VIOLATION = "ERROR_MESSAGE_DATA_INTEGRITY_VIOLATION"
|
||||
ERROR_MESSAGE_INVALID_STATE = "ERROR_MESSAGE_INVALID_STATE"
|
||||
|
@ -53,34 +55,36 @@ const (
|
|||
// noinspection GoSnakeCaseUsage,GoUnusedGlobalVariable
|
||||
var (
|
||||
// SYSTEM_ERRORS
|
||||
ERROR_INITIALIZE = errors.New(ERROR_MESSAGE_INITIALIZE)
|
||||
ERROR_NOT_IMPLEMENTED = errors.New(ERROR_MESSAGE_NOT_IMPLEMENTED)
|
||||
ERROR_OPERATION_FAILED = errors.New(ERROR_MESSAGE_OPERATION_FAILED)
|
||||
ERROR_OPERATION_NOT_SUPPORTED = errors.New(ERROR_MESSAGE_OPERATION_NOT_SUPPORTED)
|
||||
ERROR_UNRESOLVED_DEPENDENCIES = errors.New(ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES)
|
||||
ERROR_SYSTEM_COMPONENT_NOT_FOUND = errors.New(ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND)
|
||||
ERROR_DOCUMENT_NOT_FOUND = errors.New(ERROR_MESSAGE_DOCUMENT_NOT_FOUND)
|
||||
ERROR_SYSTEM_SCHEDULE_NOT_FOUND = errors.New(ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND)
|
||||
ERROR_IDENTITY_NOT_FOUND = errors.New(ERROR_MESSAGE_IDENTITY_NOT_FOUND)
|
||||
ERROR_ACCESS_CONTROL_NOT_FOUND = errors.New(ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND)
|
||||
ERROR_REMOTE_ACTIVITY_NOT_FOUND = errors.New(ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND)
|
||||
ERROR_CATEGORY_TYPE_NOT_FOUND = errors.New(ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND)
|
||||
ERROR_CATEGORY_NOT_FOUND = errors.New(ERROR_MESSAGE_CATEGORY_NOT_FOUND)
|
||||
ERROR_USER_NOT_FOUND = errors.New(ERROR_MESSAGE_USER_NOT_FOUND)
|
||||
ERROR_ACTIVITY_PUB_OBJECT_NOT_FOUND = errors.New(ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND)
|
||||
ERROR_SPI_NOT_FOUND = errors.New(ERROR_MESSAGE_SPI_NOT_FOUND)
|
||||
ERROR_UNKNOWN_DOCUMENT = errors.New(ERROR_MESSAGE_UNKNOWN_DOCUMENT)
|
||||
ERROR_UNKNOWN_SYSTEM_SCHEDULE = errors.New(ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE)
|
||||
ERROR_UNKNOWN_IDENTITY = errors.New(ERROR_MESSAGE_UNKNOWN_IDENTITY)
|
||||
ERROR_UNKNOWN_ACCESS_CONTROL = errors.New(ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL)
|
||||
ERROR_UNKNOWN_REMOTE_ACTIVITY = errors.New(ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY)
|
||||
ERROR_UNKNOWN_CATEGORY_TYPE = errors.New(ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE)
|
||||
ERROR_UNKNOWN_CATEGORY = errors.New(ERROR_MESSAGE_UNKNOWN_CATEGORY)
|
||||
ERROR_UNKNOWN_USER = errors.New(ERROR_MESSAGE_UNKNOWN_USER)
|
||||
ERROR_UNKNOWN_ACTIVITY_PUB_OBJECT = errors.New(ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT)
|
||||
ERROR_UNKNOWN_SPI = errors.New(ERROR_MESSAGE_UNKNOWN_SPI)
|
||||
ERROR_INVALID_ID = errors.New(ERROR_MESSAGE_INVALID_ID)
|
||||
ERROR_INVALID_PARAMETERS = errors.New(ERROR_MESSAGE_INVALID_PARAMETERS)
|
||||
ERROR_INITIALIZE = errors.New(ERROR_MESSAGE_INITIALIZE)
|
||||
ERROR_NOT_IMPLEMENTED = errors.New(ERROR_MESSAGE_NOT_IMPLEMENTED)
|
||||
ERROR_OPERATION_FAILED = errors.New(ERROR_MESSAGE_OPERATION_FAILED)
|
||||
ERROR_OPERATION_NOT_SUPPORTED = errors.New(ERROR_MESSAGE_OPERATION_NOT_SUPPORTED)
|
||||
ERROR_UNRESOLVED_DEPENDENCIES = errors.New(ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES)
|
||||
ERROR_SYSTEM_COMPONENT_NOT_FOUND = errors.New(ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND)
|
||||
ERROR_DOCUMENT_NOT_FOUND = errors.New(ERROR_MESSAGE_DOCUMENT_NOT_FOUND)
|
||||
ERROR_SYSTEM_SCHEDULE_NOT_FOUND = errors.New(ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND)
|
||||
ERROR_IDENTITY_NOT_FOUND = errors.New(ERROR_MESSAGE_IDENTITY_NOT_FOUND)
|
||||
ERROR_ACCESS_CONTROL_NOT_FOUND = errors.New(ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND)
|
||||
ERROR_REMOTE_ACTIVITY_NOT_FOUND = errors.New(ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND)
|
||||
ERROR_CATEGORY_TYPE_NOT_FOUND = errors.New(ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND)
|
||||
ERROR_CATEGORY_NOT_FOUND = errors.New(ERROR_MESSAGE_CATEGORY_NOT_FOUND)
|
||||
ERROR_USER_NOT_FOUND = errors.New(ERROR_MESSAGE_USER_NOT_FOUND)
|
||||
ERROR_ACTIVITY_PUB_OBJECT_NOT_FOUND = errors.New(ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND)
|
||||
ERROR_ACTIVITY_PUB_ACTIVITY_NOT_FOUND = errors.New(ERROR_MESSAGE_ACTIVITY_PUB_ACTIVITY_NOT_FOUND)
|
||||
ERROR_SPI_NOT_FOUND = errors.New(ERROR_MESSAGE_SPI_NOT_FOUND)
|
||||
ERROR_UNKNOWN_DOCUMENT = errors.New(ERROR_MESSAGE_UNKNOWN_DOCUMENT)
|
||||
ERROR_UNKNOWN_SYSTEM_SCHEDULE = errors.New(ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE)
|
||||
ERROR_UNKNOWN_IDENTITY = errors.New(ERROR_MESSAGE_UNKNOWN_IDENTITY)
|
||||
ERROR_UNKNOWN_ACCESS_CONTROL = errors.New(ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL)
|
||||
ERROR_UNKNOWN_REMOTE_ACTIVITY = errors.New(ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY)
|
||||
ERROR_UNKNOWN_CATEGORY_TYPE = errors.New(ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE)
|
||||
ERROR_UNKNOWN_CATEGORY = errors.New(ERROR_MESSAGE_UNKNOWN_CATEGORY)
|
||||
ERROR_UNKNOWN_USER = errors.New(ERROR_MESSAGE_UNKNOWN_USER)
|
||||
ERROR_UNKNOWN_ACTIVITY_PUB_OBJECT = errors.New(ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT)
|
||||
ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY = errors.New(ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_ACTIVITY)
|
||||
ERROR_UNKNOWN_SPI = errors.New(ERROR_MESSAGE_UNKNOWN_SPI)
|
||||
ERROR_INVALID_ID = errors.New(ERROR_MESSAGE_INVALID_ID)
|
||||
ERROR_INVALID_PARAMETERS = errors.New(ERROR_MESSAGE_INVALID_PARAMETERS)
|
||||
// CUSTOM_ERRORS
|
||||
ERROR_DATA_INTEGRITY_VIOLATION = errors.New(ERROR_MESSAGE_DATA_INTEGRITY_VIOLATION)
|
||||
ERROR_INVALID_STATE = errors.New(ERROR_MESSAGE_INVALID_STATE)
|
||||
|
|
|
@ -5,34 +5,36 @@ import . "github.com/xeronith/diamante/contracts/localization"
|
|||
// noinspection GoUnusedGlobalVariable
|
||||
var Errors = Resource{
|
||||
// SYSTEM_ERRORS
|
||||
ERROR_MESSAGE_INITIALIZE: "initialize",
|
||||
ERROR_MESSAGE_NOT_IMPLEMENTED: "not_implemented",
|
||||
ERROR_MESSAGE_OPERATION_FAILED: "operation_failed",
|
||||
ERROR_MESSAGE_OPERATION_NOT_SUPPORTED: "operation_not_supported",
|
||||
ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES: "unresolved_dependencies",
|
||||
ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND: "system_component_not_found",
|
||||
ERROR_MESSAGE_DOCUMENT_NOT_FOUND: "document_not_found",
|
||||
ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND: "system_schedule_not_found",
|
||||
ERROR_MESSAGE_IDENTITY_NOT_FOUND: "identity_not_found",
|
||||
ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND: "access_control_not_found",
|
||||
ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND: "remote_activity_not_found",
|
||||
ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND: "category_type_not_found",
|
||||
ERROR_MESSAGE_CATEGORY_NOT_FOUND: "category_not_found",
|
||||
ERROR_MESSAGE_USER_NOT_FOUND: "user_not_found",
|
||||
ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND: "activity_pub_object_not_found",
|
||||
ERROR_MESSAGE_SPI_NOT_FOUND: "spi_not_found",
|
||||
ERROR_MESSAGE_UNKNOWN_DOCUMENT: "unknown_document",
|
||||
ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE: "unknown_system_schedule",
|
||||
ERROR_MESSAGE_UNKNOWN_IDENTITY: "unknown_identity",
|
||||
ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL: "unknown_access_control",
|
||||
ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY: "unknown_remote_activity",
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE: "unknown_category_type",
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY: "unknown_category",
|
||||
ERROR_MESSAGE_UNKNOWN_USER: "unknown_user",
|
||||
ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT: "unknown_activity_pub_object",
|
||||
ERROR_MESSAGE_UNKNOWN_SPI: "unknown_spi",
|
||||
ERROR_MESSAGE_INVALID_ID: "invalid_id",
|
||||
ERROR_MESSAGE_INVALID_PARAMETERS: "invalid_parameters",
|
||||
ERROR_MESSAGE_INITIALIZE: "initialize",
|
||||
ERROR_MESSAGE_NOT_IMPLEMENTED: "not_implemented",
|
||||
ERROR_MESSAGE_OPERATION_FAILED: "operation_failed",
|
||||
ERROR_MESSAGE_OPERATION_NOT_SUPPORTED: "operation_not_supported",
|
||||
ERROR_MESSAGE_UNRESOLVED_DEPENDENCIES: "unresolved_dependencies",
|
||||
ERROR_MESSAGE_SYSTEM_COMPONENT_NOT_FOUND: "system_component_not_found",
|
||||
ERROR_MESSAGE_DOCUMENT_NOT_FOUND: "document_not_found",
|
||||
ERROR_MESSAGE_SYSTEM_SCHEDULE_NOT_FOUND: "system_schedule_not_found",
|
||||
ERROR_MESSAGE_IDENTITY_NOT_FOUND: "identity_not_found",
|
||||
ERROR_MESSAGE_ACCESS_CONTROL_NOT_FOUND: "access_control_not_found",
|
||||
ERROR_MESSAGE_REMOTE_ACTIVITY_NOT_FOUND: "remote_activity_not_found",
|
||||
ERROR_MESSAGE_CATEGORY_TYPE_NOT_FOUND: "category_type_not_found",
|
||||
ERROR_MESSAGE_CATEGORY_NOT_FOUND: "category_not_found",
|
||||
ERROR_MESSAGE_USER_NOT_FOUND: "user_not_found",
|
||||
ERROR_MESSAGE_ACTIVITY_PUB_OBJECT_NOT_FOUND: "activity_pub_object_not_found",
|
||||
ERROR_MESSAGE_ACTIVITY_PUB_ACTIVITY_NOT_FOUND: "activity_pub_activity_not_found",
|
||||
ERROR_MESSAGE_SPI_NOT_FOUND: "spi_not_found",
|
||||
ERROR_MESSAGE_UNKNOWN_DOCUMENT: "unknown_document",
|
||||
ERROR_MESSAGE_UNKNOWN_SYSTEM_SCHEDULE: "unknown_system_schedule",
|
||||
ERROR_MESSAGE_UNKNOWN_IDENTITY: "unknown_identity",
|
||||
ERROR_MESSAGE_UNKNOWN_ACCESS_CONTROL: "unknown_access_control",
|
||||
ERROR_MESSAGE_UNKNOWN_REMOTE_ACTIVITY: "unknown_remote_activity",
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY_TYPE: "unknown_category_type",
|
||||
ERROR_MESSAGE_UNKNOWN_CATEGORY: "unknown_category",
|
||||
ERROR_MESSAGE_UNKNOWN_USER: "unknown_user",
|
||||
ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_OBJECT: "unknown_activity_pub_object",
|
||||
ERROR_MESSAGE_UNKNOWN_ACTIVITY_PUB_ACTIVITY: "unknown_activity_pub_activity",
|
||||
ERROR_MESSAGE_UNKNOWN_SPI: "unknown_spi",
|
||||
ERROR_MESSAGE_INVALID_ID: "invalid_id",
|
||||
ERROR_MESSAGE_INVALID_PARAMETERS: "invalid_parameters",
|
||||
// CUSTOM_ERRORS
|
||||
ERROR_MESSAGE_DATA_INTEGRITY_VIOLATION: "data_integrity_violation",
|
||||
ERROR_MESSAGE_INVALID_STATE: "invalid_state",
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package contracts
|
||||
|
||||
import . "github.com/xeronith/diamante/contracts/security"
|
||||
|
||||
var ActivityPubActivityPassThroughFilter = func(IActivityPubActivity) bool { return true }
|
||||
|
||||
type (
|
||||
ActivityPubActivities []IActivityPubActivity
|
||||
ActivityPubActivityIterator func(IActivityPubActivity)
|
||||
ActivityPubActivityCondition func(IActivityPubActivity) bool
|
||||
ActivityPubActivityFilterPredicate func(IActivityPubActivity) bool
|
||||
ActivityPubActivityMapPredicate func(IActivityPubActivity) IActivityPubActivity
|
||||
ActivityPubActivityCacheCallback func()
|
||||
|
||||
IActivityPubActivity interface {
|
||||
// Context returns 'Context' of this 'ActivityPubActivity' instance.
|
||||
Context() string
|
||||
// SetContext sets 'Context' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetContext(context string)
|
||||
// Id returns 'Id' of this 'ActivityPubActivity' instance.
|
||||
Id() string
|
||||
// SetId sets 'Id' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetId(id string)
|
||||
// Type returns 'Type' of this 'ActivityPubActivity' instance.
|
||||
Type() string
|
||||
// SetType sets 'Type' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetType(type_ string)
|
||||
// Actor returns 'Actor' of this 'ActivityPubActivity' instance.
|
||||
Actor() string
|
||||
// SetActor sets 'Actor' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetActor(actor string)
|
||||
// Object returns 'Object' of this 'ActivityPubActivity' instance.
|
||||
Object() IActivityPubObject
|
||||
// SetObject sets 'Object' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetObject(object IActivityPubObject)
|
||||
// From returns 'From' of this 'ActivityPubActivity' instance.
|
||||
From() string
|
||||
// SetFrom sets 'From' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetFrom(from string)
|
||||
// To returns 'To' of this 'ActivityPubActivity' instance.
|
||||
To() []string
|
||||
// SetTo sets 'To' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetTo(to []string)
|
||||
// InReplyTo returns 'InReplyTo' of this 'ActivityPubActivity' instance.
|
||||
InReplyTo() string
|
||||
// SetInReplyTo sets 'InReplyTo' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetInReplyTo(inReplyTo string)
|
||||
// Content returns 'Content' of this 'ActivityPubActivity' instance.
|
||||
Content() string
|
||||
// SetContent sets 'Content' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetContent(content string)
|
||||
// Published returns 'Published' of this 'ActivityPubActivity' instance.
|
||||
Published() string
|
||||
// SetPublished sets 'Published' in-memory value of this 'ActivityPubActivity' instance.
|
||||
// This doesn't affect the persistent data store.
|
||||
SetPublished(published string)
|
||||
}
|
||||
|
||||
IActivityPubActivityCollection interface {
|
||||
Count() int
|
||||
IsEmpty() bool
|
||||
IsNotEmpty() bool
|
||||
HasExactlyOneItem() bool
|
||||
HasAtLeastOneItem() bool
|
||||
First() IActivityPubActivity
|
||||
Append(activityPubActivity IActivityPubActivity)
|
||||
ForEach(ActivityPubActivityIterator)
|
||||
Array() ActivityPubActivities
|
||||
}
|
||||
|
||||
IActivityPubActivityManager interface {
|
||||
ISystemComponent
|
||||
OnCacheChanged(ActivityPubActivityCacheCallback)
|
||||
Count() int
|
||||
Exists(id int64) bool
|
||||
ExistsWhich(condition ActivityPubActivityCondition) bool
|
||||
ListActivityPubActivities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubActivityCollection
|
||||
GetActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error)
|
||||
AddActivityPubActivity(editor Identity) (IActivityPubActivity, error)
|
||||
AddActivityPubActivityWithCustomId(id int64, editor Identity) (IActivityPubActivity, error)
|
||||
AddActivityPubActivityObject(activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error)
|
||||
AddActivityPubActivityAtomic(transaction ITransaction, editor Identity) (IActivityPubActivity, error)
|
||||
AddActivityPubActivityWithCustomIdAtomic(id int64, transaction ITransaction, editor Identity) (IActivityPubActivity, error)
|
||||
AddActivityPubActivityObjectAtomic(transaction ITransaction, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error)
|
||||
Log(source string, editor Identity, payload string)
|
||||
UpdateActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error)
|
||||
UpdateActivityPubActivityObject(id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error)
|
||||
UpdateActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error)
|
||||
UpdateActivityPubActivityObjectAtomic(transaction ITransaction, id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error)
|
||||
AddOrUpdateActivityPubActivityObject(id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error)
|
||||
AddOrUpdateActivityPubActivityObjectAtomic(transaction ITransaction, id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error)
|
||||
RemoveActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error)
|
||||
RemoveActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error)
|
||||
Find(id int64) IActivityPubActivity
|
||||
ForEach(iterator ActivityPubActivityIterator)
|
||||
Filter(predicate ActivityPubActivityFilterPredicate) IActivityPubActivityCollection
|
||||
Map(predicate ActivityPubActivityMapPredicate) IActivityPubActivityCollection
|
||||
}
|
||||
)
|
|
@ -0,0 +1,326 @@
|
|||
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 activityPubActivity struct {
|
||||
context string
|
||||
id string
|
||||
type_ string
|
||||
actor string
|
||||
object IActivityPubObject
|
||||
from string
|
||||
to []string
|
||||
inReplyTo string
|
||||
content string
|
||||
published string
|
||||
}
|
||||
|
||||
// noinspection GoUnusedExportedFunction
|
||||
func InitializeActivityPubActivity() {
|
||||
_ = ENABLE_SECURITY
|
||||
_ = ENABLE_CUSTOM_ERRORS
|
||||
_ = validators.Initialize
|
||||
_ = repository.Initialize
|
||||
}
|
||||
|
||||
func NewActivityPubActivity() (IActivityPubActivity, error) {
|
||||
instance := &activityPubActivity{}
|
||||
|
||||
if err := instance.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return instance, nil
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Context() string {
|
||||
return activityPubActivity.context
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetContext(value string) {
|
||||
activityPubActivity.context = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Id() string {
|
||||
return activityPubActivity.id
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetId(value string) {
|
||||
activityPubActivity.id = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Type() string {
|
||||
return activityPubActivity.type_
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetType(value string) {
|
||||
activityPubActivity.type_ = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Actor() string {
|
||||
return activityPubActivity.actor
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetActor(value string) {
|
||||
activityPubActivity.actor = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Object() IActivityPubObject {
|
||||
return activityPubActivity.object
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetObject(value IActivityPubObject) {
|
||||
activityPubActivity.object = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) From() string {
|
||||
return activityPubActivity.from
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetFrom(value string) {
|
||||
activityPubActivity.from = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) To() []string {
|
||||
return activityPubActivity.to
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetTo(value []string) {
|
||||
activityPubActivity.to = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) InReplyTo() string {
|
||||
return activityPubActivity.inReplyTo
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetInReplyTo(value string) {
|
||||
activityPubActivity.inReplyTo = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Content() string {
|
||||
return activityPubActivity.content
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetContent(value string) {
|
||||
activityPubActivity.content = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Published() string {
|
||||
return activityPubActivity.published
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) SetPublished(value string) {
|
||||
activityPubActivity.published = value
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (activityPubActivity *activityPubActivity) String() string {
|
||||
return fmt.Sprintf("ActivityPubActivity (Id: %d)", 0)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
type activityPubActivities struct {
|
||||
collection ActivityPubActivities
|
||||
}
|
||||
|
||||
// NewActivityPubActivities creates an empty collection of 'Activity Pub Activity' which is not thread-safe.
|
||||
func NewActivityPubActivities() IActivityPubActivityCollection {
|
||||
return &activityPubActivities{
|
||||
collection: make(ActivityPubActivities, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) Count() int {
|
||||
return len(activityPubActivities.collection)
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) IsEmpty() bool {
|
||||
return len(activityPubActivities.collection) == 0
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) IsNotEmpty() bool {
|
||||
return len(activityPubActivities.collection) > 0
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) HasExactlyOneItem() bool {
|
||||
return len(activityPubActivities.collection) == 1
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) HasAtLeastOneItem() bool {
|
||||
return len(activityPubActivities.collection) >= 1
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) First() IActivityPubActivity {
|
||||
return activityPubActivities.collection[0]
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) Append(activityPubActivity IActivityPubActivity) {
|
||||
activityPubActivities.collection = append(activityPubActivities.collection, activityPubActivity)
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) ForEach(iterator ActivityPubActivityIterator) {
|
||||
if iterator == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, value := range activityPubActivities.collection {
|
||||
iterator(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (activityPubActivities *activityPubActivities) Array() ActivityPubActivities {
|
||||
return activityPubActivities.collection
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (dispatcher *dispatcher) ActivityPubActivityExists(id int64) bool {
|
||||
return dispatcher.conductor.ActivityPubActivityManager().Exists(id)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ActivityPubActivityExistsWhich(condition ActivityPubActivityCondition) bool {
|
||||
return dispatcher.conductor.ActivityPubActivityManager().ExistsWhich(condition)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ListActivityPubActivities() IActivityPubActivityCollection {
|
||||
return dispatcher.conductor.ActivityPubActivityManager().ListActivityPubActivities(0, 0, "", dispatcher.identity)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ForEachActivityPubActivity(iterator ActivityPubActivityIterator) {
|
||||
dispatcher.conductor.ActivityPubActivityManager().ForEach(iterator)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) FilterActivityPubActivities(predicate ActivityPubActivityFilterPredicate) IActivityPubActivityCollection {
|
||||
return dispatcher.conductor.ActivityPubActivityManager().Filter(predicate)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) MapActivityPubActivities(predicate ActivityPubActivityMapPredicate) IActivityPubActivityCollection {
|
||||
return dispatcher.conductor.ActivityPubActivityManager().Map(predicate)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetActivityPubActivity(id int64) IActivityPubActivity {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().GetActivityPubActivity(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AddActivityPubActivity() IActivityPubActivity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().AddActivityPubActivityAtomic(transaction, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
} else {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().AddActivityPubActivity(dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AddActivityPubActivityWithCustomId(id int64) IActivityPubActivity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().AddActivityPubActivityWithCustomIdAtomic(id, transaction, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
} else {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().AddActivityPubActivityWithCustomId(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) LogActivityPubActivity(source string, payload string) {
|
||||
dispatcher.conductor.ActivityPubActivityManager().Log(source, dispatcher.identity, payload)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) UpdateActivityPubActivity(id int64) IActivityPubActivity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().UpdateActivityPubActivityAtomic(transaction, id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
} else {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().UpdateActivityPubActivity(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// noinspection GoUnusedParameter
|
||||
func (dispatcher *dispatcher) UpdateActivityPubActivityObject(object IObject, activityPubActivity IActivityPubActivity) IActivityPubActivity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().UpdateActivityPubActivityAtomic(transaction, object.Id(), dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
} else {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().UpdateActivityPubActivity(object.Id(), dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AddOrUpdateActivityPubActivityObject(object IObject, activityPubActivity IActivityPubActivity) IActivityPubActivity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().AddOrUpdateActivityPubActivityObjectAtomic(transaction, object.Id(), activityPubActivity, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
} else {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().AddOrUpdateActivityPubActivityObject(object.Id(), activityPubActivity, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) RemoveActivityPubActivity(id int64) IActivityPubActivity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().RemoveActivityPubActivityAtomic(transaction, id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
} else {
|
||||
if activityPubActivity, err := dispatcher.conductor.ActivityPubActivityManager().RemoveActivityPubActivity(id, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return activityPubActivity
|
||||
}
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue