kopia lustrzana https://github.com/reiver/greatape
feat(activitypub): ✨ activity manager
rodzic
b386a8c24d
commit
7c60829f88
|
@ -150,6 +150,19 @@ type (
|
||||||
RemoveActivityPubObject(id int64, editor Identity) (IActivityPubObject, error)
|
RemoveActivityPubObject(id int64, editor Identity) (IActivityPubObject, error)
|
||||||
RemoveActivityPubObjectAtomic(transaction ITransaction, 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
|
// Spi
|
||||||
SpiManager() ISpiManager
|
SpiManager() ISpiManager
|
||||||
SpiExists(id int64) bool
|
SpiExists(id int64) bool
|
||||||
|
@ -173,6 +186,7 @@ type (
|
||||||
NewCategory(id int64, categoryTypeId int64, categoryId int64, title string, description string) (ICategory, error)
|
NewCategory(id int64, categoryTypeId int64, categoryId int64, title string, description string) (ICategory, error)
|
||||||
NewUser(id int64, github string) (IUser, error)
|
NewUser(id int64, github string) (IUser, error)
|
||||||
NewActivityPubObject() (IActivityPubObject, error)
|
NewActivityPubObject() (IActivityPubObject, error)
|
||||||
|
NewActivityPubActivity() (IActivityPubActivity, error)
|
||||||
NewSpi() (ISpi, error)
|
NewSpi() (ISpi, error)
|
||||||
NewEchoResult(document IDocument, ignored interface{}) IEchoResult
|
NewEchoResult(document IDocument, ignored interface{}) IEchoResult
|
||||||
}
|
}
|
||||||
|
@ -219,14 +233,15 @@ type (
|
||||||
|
|
||||||
// noinspection GoSnakeCaseUsage
|
// noinspection GoSnakeCaseUsage
|
||||||
const (
|
const (
|
||||||
SYSTEM_COMPONENT_DOCUMENT_MANAGER SystemComponentType = 0x00000001
|
SYSTEM_COMPONENT_DOCUMENT_MANAGER SystemComponentType = 0x00000001
|
||||||
SYSTEM_COMPONENT_SYSTEM_SCHEDULE_MANAGER SystemComponentType = 0x00000002
|
SYSTEM_COMPONENT_SYSTEM_SCHEDULE_MANAGER SystemComponentType = 0x00000002
|
||||||
SYSTEM_COMPONENT_IDENTITY_MANAGER SystemComponentType = 0x00000003
|
SYSTEM_COMPONENT_IDENTITY_MANAGER SystemComponentType = 0x00000003
|
||||||
SYSTEM_COMPONENT_ACCESS_CONTROL_MANAGER SystemComponentType = 0x00000004
|
SYSTEM_COMPONENT_ACCESS_CONTROL_MANAGER SystemComponentType = 0x00000004
|
||||||
SYSTEM_COMPONENT_REMOTE_ACTIVITY_MANAGER SystemComponentType = 0x00000005
|
SYSTEM_COMPONENT_REMOTE_ACTIVITY_MANAGER SystemComponentType = 0x00000005
|
||||||
SYSTEM_COMPONENT_CATEGORY_TYPE_MANAGER SystemComponentType = 0x00000006
|
SYSTEM_COMPONENT_CATEGORY_TYPE_MANAGER SystemComponentType = 0x00000006
|
||||||
SYSTEM_COMPONENT_CATEGORY_MANAGER SystemComponentType = 0x00000007
|
SYSTEM_COMPONENT_CATEGORY_MANAGER SystemComponentType = 0x00000007
|
||||||
SYSTEM_COMPONENT_USER_MANAGER SystemComponentType = 0x00000008
|
SYSTEM_COMPONENT_USER_MANAGER SystemComponentType = 0x00000008
|
||||||
SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER SystemComponentType = 0x00000009
|
SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER SystemComponentType = 0x00000009
|
||||||
SYSTEM_COMPONENT_SPI_MANAGER SystemComponentType = 0x0000000A
|
SYSTEM_COMPONENT_ACTIVITY_PUB_ACTIVITY_MANAGER SystemComponentType = 0x0000000A
|
||||||
|
SYSTEM_COMPONENT_SPI_MANAGER SystemComponentType = 0x0000000B
|
||||||
)
|
)
|
||||||
|
|
|
@ -558,6 +558,62 @@ type IDispatcher interface {
|
||||||
// the transaction if used in an x.Atomic context. This method is synchronous.
|
// the transaction if used in an x.Atomic context. This method is synchronous.
|
||||||
RemoveActivityPubObject(id int64) IActivityPubObject
|
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
|
// Spi
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -651,6 +707,10 @@ type IDispatcher interface {
|
||||||
NewActivityPubObject() (IActivityPubObject, error)
|
NewActivityPubObject() (IActivityPubObject, error)
|
||||||
// NewActivityPubObjects creates an empty in-memory 'Activity Pub Object' collection which is not thread-safe.
|
// NewActivityPubObjects creates an empty in-memory 'Activity Pub Object' collection which is not thread-safe.
|
||||||
NewActivityPubObjects() IActivityPubObjectCollection
|
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 creates a new 'Spi' instance using the provided property values.
|
||||||
NewSpi() (ISpi, error)
|
NewSpi() (ISpi, error)
|
||||||
// NewSpis creates an empty in-memory 'Spi' collection which is not thread-safe.
|
// NewSpis creates an empty in-memory 'Spi' collection which is not thread-safe.
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -40,6 +40,10 @@ func (dispatcher *dispatcher) NewActivityPubObjects() IActivityPubObjectCollecti
|
||||||
return NewActivityPubObjects()
|
return NewActivityPubObjects()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dispatcher *dispatcher) NewActivityPubActivities() IActivityPubActivityCollection {
|
||||||
|
return NewActivityPubActivities()
|
||||||
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewSpis() ISpiCollection {
|
func (dispatcher *dispatcher) NewSpis() ISpiCollection {
|
||||||
return NewSpis()
|
return NewSpis()
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@ func (factory *systemComponentFactory) Create(componentType SystemComponentType,
|
||||||
component = newUserManager(configuration, logger, dependencies...)
|
component = newUserManager(configuration, logger, dependencies...)
|
||||||
case SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER:
|
case SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER:
|
||||||
component = newActivityPubObjectManager(configuration, logger, dependencies...)
|
component = newActivityPubObjectManager(configuration, logger, dependencies...)
|
||||||
|
case SYSTEM_COMPONENT_ACTIVITY_PUB_ACTIVITY_MANAGER:
|
||||||
|
component = newActivityPubActivityManager(configuration, logger, dependencies...)
|
||||||
case SYSTEM_COMPONENT_SPI_MANAGER:
|
case SYSTEM_COMPONENT_SPI_MANAGER:
|
||||||
component = newSpiManager(configuration, logger, dependencies...)
|
component = newSpiManager(configuration, logger, dependencies...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ func Initialize(configuration IConfiguration, logger ILogger) error {
|
||||||
categoryManager := factory.Create(SYSTEM_COMPONENT_CATEGORY_MANAGER, configuration, logger).(ICategoryManager)
|
categoryManager := factory.Create(SYSTEM_COMPONENT_CATEGORY_MANAGER, configuration, logger).(ICategoryManager)
|
||||||
userManager := factory.Create(SYSTEM_COMPONENT_USER_MANAGER, configuration, logger).(IUserManager)
|
userManager := factory.Create(SYSTEM_COMPONENT_USER_MANAGER, configuration, logger).(IUserManager)
|
||||||
activityPubObjectManager := factory.Create(SYSTEM_COMPONENT_ACTIVITY_PUB_OBJECT_MANAGER, configuration, logger).(IActivityPubObjectManager)
|
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)
|
spiManager := factory.Create(SYSTEM_COMPONENT_SPI_MANAGER, configuration, logger).(ISpiManager)
|
||||||
|
|
||||||
// Resolving Dependencies
|
// Resolving Dependencies
|
||||||
|
@ -84,19 +85,20 @@ func Initialize(configuration IConfiguration, logger ILogger) error {
|
||||||
// Aggregating System Components
|
// Aggregating System Components
|
||||||
Conductor = &conductor{
|
Conductor = &conductor{
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
documentManager: documentManager,
|
documentManager: documentManager,
|
||||||
systemScheduleManager: systemScheduleManager,
|
systemScheduleManager: systemScheduleManager,
|
||||||
identityManager: identityManager,
|
identityManager: identityManager,
|
||||||
accessControlManager: accessControlManager,
|
accessControlManager: accessControlManager,
|
||||||
remoteActivityManager: remoteActivityManager,
|
remoteActivityManager: remoteActivityManager,
|
||||||
categoryTypeManager: categoryTypeManager,
|
categoryTypeManager: categoryTypeManager,
|
||||||
categoryManager: categoryManager,
|
categoryManager: categoryManager,
|
||||||
userManager: userManager,
|
userManager: userManager,
|
||||||
activityPubObjectManager: activityPubObjectManager,
|
activityPubObjectManager: activityPubObjectManager,
|
||||||
spiManager: spiManager,
|
activityPubActivityManager: activityPubActivityManager,
|
||||||
logger: logger,
|
spiManager: spiManager,
|
||||||
configuration: configuration,
|
logger: logger,
|
||||||
scheduler: scheduler,
|
configuration: configuration,
|
||||||
|
scheduler: scheduler,
|
||||||
httpClient: &http.Client{
|
httpClient: &http.Client{
|
||||||
Timeout: time.Second * 5,
|
Timeout: time.Second * 5,
|
||||||
},
|
},
|
||||||
|
@ -145,20 +147,21 @@ func Initialize(configuration IConfiguration, logger ILogger) error {
|
||||||
|
|
||||||
type conductor struct {
|
type conductor struct {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
documentManager IDocumentManager
|
documentManager IDocumentManager
|
||||||
systemScheduleManager ISystemScheduleManager
|
systemScheduleManager ISystemScheduleManager
|
||||||
identityManager IIdentityManager
|
identityManager IIdentityManager
|
||||||
accessControlManager IAccessControlManager
|
accessControlManager IAccessControlManager
|
||||||
remoteActivityManager IRemoteActivityManager
|
remoteActivityManager IRemoteActivityManager
|
||||||
categoryTypeManager ICategoryTypeManager
|
categoryTypeManager ICategoryTypeManager
|
||||||
categoryManager ICategoryManager
|
categoryManager ICategoryManager
|
||||||
userManager IUserManager
|
userManager IUserManager
|
||||||
activityPubObjectManager IActivityPubObjectManager
|
activityPubObjectManager IActivityPubObjectManager
|
||||||
spiManager ISpiManager
|
activityPubActivityManager IActivityPubActivityManager
|
||||||
logger ILogger
|
spiManager ISpiManager
|
||||||
configuration IConfiguration
|
logger ILogger
|
||||||
scheduler *schedule.Cron
|
configuration IConfiguration
|
||||||
httpClient *http.Client
|
scheduler *schedule.Cron
|
||||||
|
httpClient *http.Client
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,6 +687,52 @@ func (conductor *conductor) RemoveActivityPubObjectAtomic(transaction ITransacti
|
||||||
return conductor.activityPubObjectManager.RemoveActivityPubObjectAtomic(transaction, id, editor)
|
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
|
// Spi
|
||||||
|
|
||||||
func (conductor *conductor) SpiManager() ISpiManager {
|
func (conductor *conductor) SpiManager() ISpiManager {
|
||||||
|
@ -770,6 +819,10 @@ func (conductor *conductor) NewActivityPubObject() (IActivityPubObject, error) {
|
||||||
return NewActivityPubObject()
|
return NewActivityPubObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (conductor *conductor) NewActivityPubActivity() (IActivityPubActivity, error) {
|
||||||
|
return NewActivityPubActivity()
|
||||||
|
}
|
||||||
|
|
||||||
func (conductor *conductor) NewSpi() (ISpi, error) {
|
func (conductor *conductor) NewSpi() (ISpi, error) {
|
||||||
return NewSpi()
|
return NewSpi()
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,10 @@ func (dispatcher *dispatcher) NewActivityPubObject() (IActivityPubObject, error)
|
||||||
return NewActivityPubObject()
|
return NewActivityPubObject()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dispatcher *dispatcher) NewActivityPubActivity() (IActivityPubActivity, error) {
|
||||||
|
return NewActivityPubActivity()
|
||||||
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewSpi() (ISpi, error) {
|
func (dispatcher *dispatcher) NewSpi() (ISpi, error) {
|
||||||
return NewSpi()
|
return NewSpi()
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue