diff --git a/greataped/components/contracts/system_component.go b/greataped/components/contracts/system_component.go index 43f81b5..33c544d 100644 --- a/greataped/components/contracts/system_component.go +++ b/greataped/components/contracts/system_component.go @@ -150,6 +150,19 @@ type ( RemoveActivityPubObject(id int64, editor Identity) (IActivityPubObject, error) RemoveActivityPubObjectAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubObject, error) + // ActivityPubActivity + ActivityPubActivityManager() IActivityPubActivityManager + ActivityPubActivityExists(id int64) bool + ListActivityPubActivities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubActivityCollection + GetActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) + AddActivityPubActivity(editor Identity) (IActivityPubActivity, error) + AddActivityPubActivityAtomic(transaction ITransaction, editor Identity) (IActivityPubActivity, error) + LogActivityPubActivity(source string, editor Identity, payload string) + UpdateActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) + UpdateActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) + RemoveActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) + RemoveActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) + // Spi SpiManager() ISpiManager SpiExists(id int64) bool @@ -173,6 +186,7 @@ type ( NewCategory(id int64, categoryTypeId int64, categoryId int64, title string, description string) (ICategory, error) NewUser(id int64, github string) (IUser, error) NewActivityPubObject() (IActivityPubObject, error) + NewActivityPubActivity() (IActivityPubActivity, error) NewSpi() (ISpi, error) NewEchoResult(document IDocument, ignored interface{}) IEchoResult } @@ -219,14 +233,15 @@ type ( // noinspection GoSnakeCaseUsage const ( - SYSTEM_COMPONENT_DOCUMENT_MANAGER SystemComponentType = 0x00000001 - SYSTEM_COMPONENT_SYSTEM_SCHEDULE_MANAGER SystemComponentType = 0x00000002 - SYSTEM_COMPONENT_IDENTITY_MANAGER SystemComponentType = 0x00000003 - SYSTEM_COMPONENT_ACCESS_CONTROL_MANAGER SystemComponentType = 0x00000004 - SYSTEM_COMPONENT_REMOTE_ACTIVITY_MANAGER SystemComponentType = 0x00000005 - SYSTEM_COMPONENT_CATEGORY_TYPE_MANAGER SystemComponentType = 0x00000006 - SYSTEM_COMPONENT_CATEGORY_MANAGER SystemComponentType = 0x00000007 - SYSTEM_COMPONENT_USER_MANAGER SystemComponentType = 0x00000008 - SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER SystemComponentType = 0x00000009 - SYSTEM_COMPONENT_SPI_MANAGER SystemComponentType = 0x0000000A + SYSTEM_COMPONENT_DOCUMENT_MANAGER SystemComponentType = 0x00000001 + SYSTEM_COMPONENT_SYSTEM_SCHEDULE_MANAGER SystemComponentType = 0x00000002 + SYSTEM_COMPONENT_IDENTITY_MANAGER SystemComponentType = 0x00000003 + SYSTEM_COMPONENT_ACCESS_CONTROL_MANAGER SystemComponentType = 0x00000004 + SYSTEM_COMPONENT_REMOTE_ACTIVITY_MANAGER SystemComponentType = 0x00000005 + SYSTEM_COMPONENT_CATEGORY_TYPE_MANAGER SystemComponentType = 0x00000006 + SYSTEM_COMPONENT_CATEGORY_MANAGER SystemComponentType = 0x00000007 + SYSTEM_COMPONENT_USER_MANAGER SystemComponentType = 0x00000008 + SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER SystemComponentType = 0x00000009 + SYSTEM_COMPONENT_ACTIVITY_PUB_ACTIVITY_MANAGER SystemComponentType = 0x0000000A + SYSTEM_COMPONENT_SPI_MANAGER SystemComponentType = 0x0000000B ) diff --git a/greataped/components/contracts/system_dispatcher.go b/greataped/components/contracts/system_dispatcher.go index b09aa67..3d5e5e7 100644 --- a/greataped/components/contracts/system_dispatcher.go +++ b/greataped/components/contracts/system_dispatcher.go @@ -558,6 +558,62 @@ type IDispatcher interface { // the transaction if used in an x.Atomic context. This method is synchronous. RemoveActivityPubObject(id int64) IActivityPubObject + // ActivityPubActivity + // ------------------------------------------------------------ + + // ActivityPubActivityExists checks whether a specific 'Activity Pub Activity' with the provided + // unique identifier or 'Id' exists in the system. + ActivityPubActivityExists(id int64) bool + // ActivityPubActivityExistsWhich checks whether a specific 'Activity Pub Activity' exists in the system + // which satisfies the provided condition. + ActivityPubActivityExistsWhich(condition ActivityPubActivityCondition) bool + // ListActivityPubActivities returns a list of all 'Activity Pub Activity' instances in the system. + ListActivityPubActivities() IActivityPubActivityCollection + // ForEachActivityPubActivity loops over all 'Activity Pub Activity' instances in the system running + // the provided iterator for each of them. + ForEachActivityPubActivity(iterator ActivityPubActivityIterator) + // FilterActivityPubActivities returns a filtered list of 'Activity Pub Activity' instances based + // on the provided predicate. + FilterActivityPubActivities(predicate ActivityPubActivityFilterPredicate) IActivityPubActivityCollection + // MapActivityPubActivities loops over all 'Activity Pub Activity' instances in the system and + // returns a transformed list based on the provided predicate. + MapActivityPubActivities(predicate ActivityPubActivityMapPredicate) IActivityPubActivityCollection + // GetActivityPubActivity finds a specific 'Activity Pub Activity' instance using + // the provided unique identifier or 'Id'. + GetActivityPubActivity(id int64) IActivityPubActivity + // AddActivityPubActivity creates a new 'Activity Pub Activity' instance with an auto-generated unique identifier using the + // provided property values and adds it to persistent data store and system cache. + // The method is smart enough to respect the transaction if used in an + // x.Atomic context. This method is synchronous. + AddActivityPubActivity() IActivityPubActivity + // AddActivityPubActivityWithCustomId creates a new 'Activity Pub Activity' instance with a custom unique identifier using the + // provided property values and adds it to persistent data store and system cache. + // The method is smart enough to respect the transaction if used in an + // x.Atomic context. This method is synchronous. + AddActivityPubActivityWithCustomId(id int64) IActivityPubActivity + // LogActivityPubActivity creates a new 'Activity Pub Activity' instance using the provided property values + // and adds it to persistent data store and system cache. + // The method is smart enough to respect the transaction if used in an + // x.Atomic context. This method is asynchronous. + LogActivityPubActivity(source string, payload string) + // UpdateActivityPubActivity finds the 'Activity Pub Activity' instance using the provided unique identifier and updates it using + // the provided property values and reflects the changes to persistent data store and system + // cache. The method is smart enough to respect the transaction if used in an x.Atomic context. + // This method is synchronous. + UpdateActivityPubActivity(id int64) IActivityPubActivity + // UpdateActivityPubActivityObject finds and updates the 'Activity Pub Activity' using the provided instance and reflects the + // changes to persistent data store and system cache. The method is smart enough to + // respect the transaction if used in an x.Atomic context. This method is synchronous. + UpdateActivityPubActivityObject(object IObject, activityPubActivity IActivityPubActivity) IActivityPubActivity + // AddOrUpdateActivityPubActivityObject tries to find the 'Activity Pub Activity' using the provided instance, then updates it in persistent + // data store and system cache or creates it if doesn't already exist. The method is smart enough + // to respect the transaction if used in an x.Atomic context. This method is synchronous. + AddOrUpdateActivityPubActivityObject(object IObject, activityPubActivity IActivityPubActivity) IActivityPubActivity + // RemoveActivityPubActivity finds the 'Activity Pub Activity' instance using the provided unique identifier and + // removes it from the system cache. The method is smart enough to respect + // the transaction if used in an x.Atomic context. This method is synchronous. + RemoveActivityPubActivity(id int64) IActivityPubActivity + // Spi // ------------------------------------------------------------ @@ -651,6 +707,10 @@ type IDispatcher interface { NewActivityPubObject() (IActivityPubObject, error) // NewActivityPubObjects creates an empty in-memory 'Activity Pub Object' collection which is not thread-safe. NewActivityPubObjects() IActivityPubObjectCollection + // NewActivityPubActivity creates a new 'Activity Pub Activity' instance using the provided property values. + NewActivityPubActivity() (IActivityPubActivity, error) + // NewActivityPubActivities creates an empty in-memory 'Activity Pub Activity' collection which is not thread-safe. + NewActivityPubActivities() IActivityPubActivityCollection // NewSpi creates a new 'Spi' instance using the provided property values. NewSpi() (ISpi, error) // NewSpis creates an empty in-memory 'Spi' collection which is not thread-safe. diff --git a/greataped/components/core/activity_pub_activity_manager.go b/greataped/components/core/activity_pub_activity_manager.go new file mode 100644 index 0000000..fee556b --- /dev/null +++ b/greataped/components/core/activity_pub_activity_manager.go @@ -0,0 +1,196 @@ +package core + +import ( + . "github.com/xeronith/diamante/contracts/logging" + . "github.com/xeronith/diamante/contracts/security" + . "github.com/xeronith/diamante/contracts/settings" + . "github.com/xeronith/diamante/contracts/system" + . "github.com/xeronith/diamante/system" + "rail.town/infrastructure/app/validators" + . "rail.town/infrastructure/components/constants" + . "rail.town/infrastructure/components/contracts" +) + +// noinspection GoSnakeCaseUsage +const ACTIVITY_PUB_ACTIVITY_MANAGER = "ActivityPubActivityManager" + +type activityPubActivityManager struct { + systemComponent + cache ICache +} + +func newActivityPubActivityManager(configuration IConfiguration, logger ILogger, dependencies ...ISystemComponent) IActivityPubActivityManager { + _ = ENABLE_CUSTOM_ERRORS + _ = validators.Initialize + + manager := &activityPubActivityManager{ + systemComponent: newSystemComponent(configuration, logger), + cache: NewCache(), + } + + if err := manager.ResolveDependencies(dependencies...); err != nil { + return nil + } + + return manager +} + +func (manager *activityPubActivityManager) Name() string { + return ACTIVITY_PUB_ACTIVITY_MANAGER +} + +func (manager *activityPubActivityManager) ResolveDependencies(_ ...ISystemComponent) error { + return nil +} + +func (manager *activityPubActivityManager) Load() error { + return nil +} + +func (manager *activityPubActivityManager) Reload() error { + return manager.Load() +} + +func (manager *activityPubActivityManager) OnCacheChanged(callback ActivityPubActivityCacheCallback) { + manager.cache.OnChanged(callback) +} + +func (manager *activityPubActivityManager) Count() int { + return manager.cache.Size() +} + +func (manager *activityPubActivityManager) Exists(id int64) bool { + return manager.Find(id) != nil +} + +func (manager *activityPubActivityManager) ExistsWhich(condition ActivityPubActivityCondition) bool { + var activityPubActivities ActivityPubActivities + manager.ForEach(func(activityPubActivity IActivityPubActivity) { + if condition(activityPubActivity) { + activityPubActivities = append(activityPubActivities, activityPubActivity) + } + }) + + return len(activityPubActivities) > 0 +} + +func (manager *activityPubActivityManager) ListActivityPubActivities(_ /* pageIndex */ uint32, _ /* pageSize */ uint32, _ /* criteria */ string, _ Identity) IActivityPubActivityCollection { + return manager.Filter(ActivityPubActivityPassThroughFilter) +} + +func (manager *activityPubActivityManager) GetActivityPubActivity(id int64, _ Identity) (IActivityPubActivity, error) { + if activityPubActivity := manager.Find(id); activityPubActivity == nil { + return nil, ERROR_ACTIVITY_PUB_ACTIVITY_NOT_FOUND + } else { + return activityPubActivity, nil + } +} + +func (manager *activityPubActivityManager) AddActivityPubActivity(editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) AddActivityPubActivityWithCustomId(id int64, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) AddActivityPubActivityObject(activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) AddActivityPubActivityAtomic(transaction ITransaction, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) AddActivityPubActivityWithCustomIdAtomic(id int64, transaction ITransaction, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) AddActivityPubActivityObjectAtomic(transaction ITransaction, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) Log(source string, editor Identity, payload string) { +} + +func (manager *activityPubActivityManager) UpdateActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) UpdateActivityPubActivityObject(id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) UpdateActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) UpdateActivityPubActivityObjectAtomic(transaction ITransaction, id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) AddOrUpdateActivityPubActivityObject(id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubActivityObject(id, activityPubActivity, editor) + } else { + return manager.AddActivityPubActivityObject(activityPubActivity, editor) + } +} + +func (manager *activityPubActivityManager) AddOrUpdateActivityPubActivityObjectAtomic(transaction ITransaction, id int64, activityPubActivity IActivityPubActivity, editor Identity) (IActivityPubActivity, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubActivityObjectAtomic(transaction, id, activityPubActivity, editor) + } else { + return manager.AddActivityPubActivityObjectAtomic(transaction, activityPubActivity, editor) + } +} + +func (manager *activityPubActivityManager) RemoveActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) RemoveActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubActivityManager) Find(id int64) IActivityPubActivity { + if object, exists := manager.cache.Get(id); !exists { + return nil + } else { + return object.(IActivityPubActivity) + } +} + +func (manager *activityPubActivityManager) ForEach(iterator ActivityPubActivityIterator) { + manager.cache.ForEachValue(func(object ISystemObject) { + iterator(object.(IActivityPubActivity)) + }) +} + +func (manager *activityPubActivityManager) Filter(predicate ActivityPubActivityFilterPredicate) IActivityPubActivityCollection { + activityPubActivities := NewActivityPubActivities() + if predicate == nil { + return activityPubActivities + } + + manager.ForEach(func(activityPubActivity IActivityPubActivity) { + if predicate(activityPubActivity) { + activityPubActivities.Append(activityPubActivity) + } + }) + + return activityPubActivities +} + +func (manager *activityPubActivityManager) Map(predicate ActivityPubActivityMapPredicate) IActivityPubActivityCollection { + activityPubActivities := NewActivityPubActivities() + if predicate == nil { + return activityPubActivities + } + + manager.ForEach(func(activityPubActivity IActivityPubActivity) { + activityPubActivities.Append(predicate(activityPubActivity)) + }) + + return activityPubActivities +} diff --git a/greataped/components/core/activity_pub_activity_manager_test.go b/greataped/components/core/activity_pub_activity_manager_test.go new file mode 100644 index 0000000..858d8eb --- /dev/null +++ b/greataped/components/core/activity_pub_activity_manager_test.go @@ -0,0 +1,150 @@ +package core_test + +import ( + "testing" + + . "rail.town/infrastructure/components/constants" + . "rail.town/infrastructure/components/contracts" + . "rail.town/infrastructure/components/core" +) + +func TestActivityPubActivityManager_GetName(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + if manager.Name() != ACTIVITY_PUB_ACTIVITY_MANAGER { + test.Fail() + } +} + +func TestActivityPubActivityManager_ResolveDependencies(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + if err := manager.ResolveDependencies(); err != nil { + test.Fatal(err) + } +} + +func TestActivityPubActivityManager_Load(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + if err := manager.Load(); err != nil { + test.Fatal(err) + } +} + +func TestActivityPubActivityManager_Reload(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + if err := manager.Reload(); err != nil && err != ERROR_OPERATION_NOT_SUPPORTED { + test.Fatal(err) + } +} + +func TestActivityPubActivityManager_Count(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + _ = manager.Count() +} + +func TestActivityPubActivityManager_Exists(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + if manager.Exists(0) { + test.FailNow() + } +} + +func TestActivityPubActivityManager_ListActivityPubActivities(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + _ = manager.ListActivityPubActivities(0, 0, "", nil) +} + +func TestActivityPubActivityManager_GetActivityPubActivity(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + if activityPubActivity, err := manager.GetActivityPubActivity(0, nil); err == nil { + _ = activityPubActivity + test.FailNow() + } +} + +func TestActivityPubActivityManager_AddActivityPubActivity(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + activityPubActivity, err := manager.AddActivityPubActivity(nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubActivity +} + +func TestActivityPubActivityManager_UpdateActivityPubActivity(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + activityPubActivity, err := manager.UpdateActivityPubActivity(0, nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubActivity +} + +func TestActivityPubActivityManager_RemoveActivityPubActivity(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + activityPubActivity, err := manager.RemoveActivityPubActivity(0, nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubActivity +} + +func TestActivityPubActivityManager_Find(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + activityPubActivity := manager.Find(0) + if activityPubActivity == nil { + test.Fail() + } + + _ = activityPubActivity +} + +func TestActivityPubActivityManager_ForEach(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + manager.ForEach(func(activityPubActivity IActivityPubActivity) { + _ = activityPubActivity + }) +} + +func TestActivityPubActivityManager_Filter(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + activityPubActivities := manager.Filter(func(activityPubActivity IActivityPubActivity) bool { + return false + }) + + if activityPubActivities.IsNotEmpty() { + test.Fail() + } + + _ = activityPubActivities +} + +func TestActivityPubActivityManager_Map(test *testing.T) { + manager := Conductor.ActivityPubActivityManager() + + activityPubActivities := manager.Map(func(activityPubActivity IActivityPubActivity) IActivityPubActivity { + return activityPubActivity + }) + + if activityPubActivities.Count() != manager.Count() { + test.Fail() + } + + _ = activityPubActivities +} diff --git a/greataped/components/core/collections.go b/greataped/components/core/collections.go index 470e5e2..895600e 100644 --- a/greataped/components/core/collections.go +++ b/greataped/components/core/collections.go @@ -40,6 +40,10 @@ func (dispatcher *dispatcher) NewActivityPubObjects() IActivityPubObjectCollecti return NewActivityPubObjects() } +func (dispatcher *dispatcher) NewActivityPubActivities() IActivityPubActivityCollection { + return NewActivityPubActivities() +} + func (dispatcher *dispatcher) NewSpis() ISpiCollection { return NewSpis() } diff --git a/greataped/components/core/factory.go b/greataped/components/core/factory.go index 8ac4340..fdc2f61 100644 --- a/greataped/components/core/factory.go +++ b/greataped/components/core/factory.go @@ -32,6 +32,8 @@ func (factory *systemComponentFactory) Create(componentType SystemComponentType, component = newUserManager(configuration, logger, dependencies...) case SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER: component = newActivityPubObjectManager(configuration, logger, dependencies...) + case SYSTEM_COMPONENT_ACTIVITY_PUB_ACTIVITY_MANAGER: + component = newActivityPubActivityManager(configuration, logger, dependencies...) case SYSTEM_COMPONENT_SPI_MANAGER: component = newSpiManager(configuration, logger, dependencies...) } diff --git a/greataped/components/core/initializer.go b/greataped/components/core/initializer.go index e9def94..f4a0015 100644 --- a/greataped/components/core/initializer.go +++ b/greataped/components/core/initializer.go @@ -63,6 +63,7 @@ func Initialize(configuration IConfiguration, logger ILogger) error { categoryManager := factory.Create(SYSTEM_COMPONENT_CATEGORY_MANAGER, configuration, logger).(ICategoryManager) userManager := factory.Create(SYSTEM_COMPONENT_USER_MANAGER, configuration, logger).(IUserManager) activityPubObjectManager := factory.Create(SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER, configuration, logger).(IActivityPubObjectManager) + activityPubActivityManager := factory.Create(SYSTEM_COMPONENT_ACTIVITY_PUB_ACTIVITY_MANAGER, configuration, logger).(IActivityPubActivityManager) spiManager := factory.Create(SYSTEM_COMPONENT_SPI_MANAGER, configuration, logger).(ISpiManager) // Resolving Dependencies @@ -84,19 +85,20 @@ func Initialize(configuration IConfiguration, logger ILogger) error { // Aggregating System Components Conductor = &conductor{ // @formatter:off - documentManager: documentManager, - systemScheduleManager: systemScheduleManager, - identityManager: identityManager, - accessControlManager: accessControlManager, - remoteActivityManager: remoteActivityManager, - categoryTypeManager: categoryTypeManager, - categoryManager: categoryManager, - userManager: userManager, - activityPubObjectManager: activityPubObjectManager, - spiManager: spiManager, - logger: logger, - configuration: configuration, - scheduler: scheduler, + documentManager: documentManager, + systemScheduleManager: systemScheduleManager, + identityManager: identityManager, + accessControlManager: accessControlManager, + remoteActivityManager: remoteActivityManager, + categoryTypeManager: categoryTypeManager, + categoryManager: categoryManager, + userManager: userManager, + activityPubObjectManager: activityPubObjectManager, + activityPubActivityManager: activityPubActivityManager, + spiManager: spiManager, + logger: logger, + configuration: configuration, + scheduler: scheduler, httpClient: &http.Client{ Timeout: time.Second * 5, }, @@ -145,20 +147,21 @@ func Initialize(configuration IConfiguration, logger ILogger) error { type conductor struct { // @formatter:off - documentManager IDocumentManager - systemScheduleManager ISystemScheduleManager - identityManager IIdentityManager - accessControlManager IAccessControlManager - remoteActivityManager IRemoteActivityManager - categoryTypeManager ICategoryTypeManager - categoryManager ICategoryManager - userManager IUserManager - activityPubObjectManager IActivityPubObjectManager - spiManager ISpiManager - logger ILogger - configuration IConfiguration - scheduler *schedule.Cron - httpClient *http.Client + documentManager IDocumentManager + systemScheduleManager ISystemScheduleManager + identityManager IIdentityManager + accessControlManager IAccessControlManager + remoteActivityManager IRemoteActivityManager + categoryTypeManager ICategoryTypeManager + categoryManager ICategoryManager + userManager IUserManager + activityPubObjectManager IActivityPubObjectManager + activityPubActivityManager IActivityPubActivityManager + spiManager ISpiManager + logger ILogger + configuration IConfiguration + scheduler *schedule.Cron + httpClient *http.Client // @formatter:on } @@ -684,6 +687,52 @@ func (conductor *conductor) RemoveActivityPubObjectAtomic(transaction ITransacti return conductor.activityPubObjectManager.RemoveActivityPubObjectAtomic(transaction, id, editor) } +// ActivityPubActivity + +func (conductor *conductor) ActivityPubActivityManager() IActivityPubActivityManager { + return conductor.activityPubActivityManager +} + +func (conductor *conductor) ActivityPubActivityExists(id int64) bool { + return conductor.activityPubActivityManager.Exists(id) +} + +func (conductor *conductor) ListActivityPubActivities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubActivityCollection { + return conductor.activityPubActivityManager.ListActivityPubActivities(pageIndex, pageSize, criteria, editor) +} + +func (conductor *conductor) GetActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.GetActivityPubActivity(id, editor) +} + +func (conductor *conductor) AddActivityPubActivity(editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.AddActivityPubActivity(editor) +} + +func (conductor *conductor) AddActivityPubActivityAtomic(transaction ITransaction, editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.AddActivityPubActivityAtomic(transaction, editor) +} + +func (conductor *conductor) LogActivityPubActivity(source string, editor Identity, payload string) { + conductor.activityPubActivityManager.Log(source, editor, payload) +} + +func (conductor *conductor) UpdateActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.UpdateActivityPubActivity(id, editor) +} + +func (conductor *conductor) UpdateActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.UpdateActivityPubActivityAtomic(transaction, id, editor) +} + +func (conductor *conductor) RemoveActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.RemoveActivityPubActivity(id, editor) +} + +func (conductor *conductor) RemoveActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) { + return conductor.activityPubActivityManager.RemoveActivityPubActivityAtomic(transaction, id, editor) +} + // Spi func (conductor *conductor) SpiManager() ISpiManager { @@ -770,6 +819,10 @@ func (conductor *conductor) NewActivityPubObject() (IActivityPubObject, error) { return NewActivityPubObject() } +func (conductor *conductor) NewActivityPubActivity() (IActivityPubActivity, error) { + return NewActivityPubActivity() +} + func (conductor *conductor) NewSpi() (ISpi, error) { return NewSpi() } diff --git a/greataped/components/core/system_dispatcher.go b/greataped/components/core/system_dispatcher.go index 7a05ade..2125623 100644 --- a/greataped/components/core/system_dispatcher.go +++ b/greataped/components/core/system_dispatcher.go @@ -144,6 +144,10 @@ func (dispatcher *dispatcher) NewActivityPubObject() (IActivityPubObject, error) return NewActivityPubObject() } +func (dispatcher *dispatcher) NewActivityPubActivity() (IActivityPubActivity, error) { + return NewActivityPubActivity() +} + func (dispatcher *dispatcher) NewSpi() (ISpi, error) { return NewSpi() }