From e9409eea40ae5a5ad7bfb1b48269d3f655a199ae Mon Sep 17 00:00:00 2001 From: Xeronith Date: Thu, 3 Nov 2022 11:48:39 +0330 Subject: [PATCH] feat(activitypub): :sparkles: upgrade core components and add new object managers --- .../components/contracts/system_component.go | 67 +++++- .../components/contracts/system_dispatcher.go | 180 +++++++++++++++ .../core/activity_pub_link_manager.go | 196 ++++++++++++++++ .../core/activity_pub_media_manager.go | 196 ++++++++++++++++ .../core/activity_pub_public_key_manager.go | 196 ++++++++++++++++ greataped/components/core/collections.go | 12 + greataped/components/core/factory.go | 6 + greataped/components/core/initializer.go | 217 +++++++++++++++--- .../components/core/system_dispatcher.go | 12 + 9 files changed, 1042 insertions(+), 40 deletions(-) create mode 100644 greataped/components/core/activity_pub_link_manager.go create mode 100644 greataped/components/core/activity_pub_media_manager.go create mode 100644 greataped/components/core/activity_pub_public_key_manager.go diff --git a/greataped/components/contracts/system_component.go b/greataped/components/contracts/system_component.go index 33c544d..ad81fc0 100644 --- a/greataped/components/contracts/system_component.go +++ b/greataped/components/contracts/system_component.go @@ -163,6 +163,45 @@ type ( RemoveActivityPubActivity(id int64, editor Identity) (IActivityPubActivity, error) RemoveActivityPubActivityAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubActivity, error) + // ActivityPubPublicKey + ActivityPubPublicKeyManager() IActivityPubPublicKeyManager + ActivityPubPublicKeyExists(id int64) bool + ListActivityPubPublicKeys(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubPublicKeyCollection + GetActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) + AddActivityPubPublicKey(editor Identity) (IActivityPubPublicKey, error) + AddActivityPubPublicKeyAtomic(transaction ITransaction, editor Identity) (IActivityPubPublicKey, error) + LogActivityPubPublicKey(source string, editor Identity, payload string) + UpdateActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) + UpdateActivityPubPublicKeyAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubPublicKey, error) + RemoveActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) + RemoveActivityPubPublicKeyAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubPublicKey, error) + + // ActivityPubLink + ActivityPubLinkManager() IActivityPubLinkManager + ActivityPubLinkExists(id int64) bool + ListActivityPubLinks(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubLinkCollection + GetActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) + AddActivityPubLink(editor Identity) (IActivityPubLink, error) + AddActivityPubLinkAtomic(transaction ITransaction, editor Identity) (IActivityPubLink, error) + LogActivityPubLink(source string, editor Identity, payload string) + UpdateActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) + UpdateActivityPubLinkAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubLink, error) + RemoveActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) + RemoveActivityPubLinkAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubLink, error) + + // ActivityPubMedia + ActivityPubMediaManager() IActivityPubMediaManager + ActivityPubMediaExists(id int64) bool + ListActivityPubMedias(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubMediaCollection + GetActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) + AddActivityPubMedia(editor Identity) (IActivityPubMedia, error) + AddActivityPubMediaAtomic(transaction ITransaction, editor Identity) (IActivityPubMedia, error) + LogActivityPubMedia(source string, editor Identity, payload string) + UpdateActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) + UpdateActivityPubMediaAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubMedia, error) + RemoveActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) + RemoveActivityPubMediaAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubMedia, error) + // Spi SpiManager() ISpiManager SpiExists(id int64) bool @@ -187,6 +226,9 @@ type ( NewUser(id int64, github string) (IUser, error) NewActivityPubObject() (IActivityPubObject, error) NewActivityPubActivity() (IActivityPubActivity, error) + NewActivityPubPublicKey() (IActivityPubPublicKey, error) + NewActivityPubLink() (IActivityPubLink, error) + NewActivityPubMedia() (IActivityPubMedia, error) NewSpi() (ISpi, error) NewEchoResult(document IDocument, ignored interface{}) IEchoResult } @@ -233,15 +275,18 @@ 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_ACTIVITY_PUB_ACTIVITY_MANAGER SystemComponentType = 0x0000000A - SYSTEM_COMPONENT_SPI_MANAGER SystemComponentType = 0x0000000B + 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_ACTIVITY_PUB_PUBLIC_KEY_MANAGER SystemComponentType = 0x0000000B + SYSTEM_COMPONENT_ACTIVITY_PUB_LINK_MANAGER SystemComponentType = 0x0000000C + SYSTEM_COMPONENT_ACTIVITY_PUB_MEDIA_MANAGER SystemComponentType = 0x0000000D + SYSTEM_COMPONENT_SPI_MANAGER SystemComponentType = 0x0000000E ) diff --git a/greataped/components/contracts/system_dispatcher.go b/greataped/components/contracts/system_dispatcher.go index 3d5e5e7..d7ba126 100644 --- a/greataped/components/contracts/system_dispatcher.go +++ b/greataped/components/contracts/system_dispatcher.go @@ -614,6 +614,174 @@ type IDispatcher interface { // the transaction if used in an x.Atomic context. This method is synchronous. RemoveActivityPubActivity(id int64) IActivityPubActivity + // ActivityPubPublicKey + // ------------------------------------------------------------ + + // ActivityPubPublicKeyExists checks whether a specific 'Activity Pub Public Key' with the provided + // unique identifier or 'Id' exists in the system. + ActivityPubPublicKeyExists(id int64) bool + // ActivityPubPublicKeyExistsWhich checks whether a specific 'Activity Pub Public Key' exists in the system + // which satisfies the provided condition. + ActivityPubPublicKeyExistsWhich(condition ActivityPubPublicKeyCondition) bool + // ListActivityPubPublicKeys returns a list of all 'Activity Pub Public Key' instances in the system. + ListActivityPubPublicKeys() IActivityPubPublicKeyCollection + // ForEachActivityPubPublicKey loops over all 'Activity Pub Public Key' instances in the system running + // the provided iterator for each of them. + ForEachActivityPubPublicKey(iterator ActivityPubPublicKeyIterator) + // FilterActivityPubPublicKeys returns a filtered list of 'Activity Pub Public Key' instances based + // on the provided predicate. + FilterActivityPubPublicKeys(predicate ActivityPubPublicKeyFilterPredicate) IActivityPubPublicKeyCollection + // MapActivityPubPublicKeys loops over all 'Activity Pub Public Key' instances in the system and + // returns a transformed list based on the provided predicate. + MapActivityPubPublicKeys(predicate ActivityPubPublicKeyMapPredicate) IActivityPubPublicKeyCollection + // GetActivityPubPublicKey finds a specific 'Activity Pub Public Key' instance using + // the provided unique identifier or 'Id'. + GetActivityPubPublicKey(id int64) IActivityPubPublicKey + // AddActivityPubPublicKey creates a new 'Activity Pub Public Key' 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. + AddActivityPubPublicKey() IActivityPubPublicKey + // AddActivityPubPublicKeyWithCustomId creates a new 'Activity Pub Public Key' 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. + AddActivityPubPublicKeyWithCustomId(id int64) IActivityPubPublicKey + // LogActivityPubPublicKey creates a new 'Activity Pub Public Key' 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. + LogActivityPubPublicKey(source string, payload string) + // UpdateActivityPubPublicKey finds the 'Activity Pub Public Key' 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. + UpdateActivityPubPublicKey(id int64) IActivityPubPublicKey + // UpdateActivityPubPublicKeyObject finds and updates the 'Activity Pub Public Key' 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. + UpdateActivityPubPublicKeyObject(object IObject, activityPubPublicKey IActivityPubPublicKey) IActivityPubPublicKey + // AddOrUpdateActivityPubPublicKeyObject tries to find the 'Activity Pub Public Key' 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. + AddOrUpdateActivityPubPublicKeyObject(object IObject, activityPubPublicKey IActivityPubPublicKey) IActivityPubPublicKey + // RemoveActivityPubPublicKey finds the 'Activity Pub Public Key' 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. + RemoveActivityPubPublicKey(id int64) IActivityPubPublicKey + + // ActivityPubLink + // ------------------------------------------------------------ + + // ActivityPubLinkExists checks whether a specific 'Activity Pub Link' with the provided + // unique identifier or 'Id' exists in the system. + ActivityPubLinkExists(id int64) bool + // ActivityPubLinkExistsWhich checks whether a specific 'Activity Pub Link' exists in the system + // which satisfies the provided condition. + ActivityPubLinkExistsWhich(condition ActivityPubLinkCondition) bool + // ListActivityPubLinks returns a list of all 'Activity Pub Link' instances in the system. + ListActivityPubLinks() IActivityPubLinkCollection + // ForEachActivityPubLink loops over all 'Activity Pub Link' instances in the system running + // the provided iterator for each of them. + ForEachActivityPubLink(iterator ActivityPubLinkIterator) + // FilterActivityPubLinks returns a filtered list of 'Activity Pub Link' instances based + // on the provided predicate. + FilterActivityPubLinks(predicate ActivityPubLinkFilterPredicate) IActivityPubLinkCollection + // MapActivityPubLinks loops over all 'Activity Pub Link' instances in the system and + // returns a transformed list based on the provided predicate. + MapActivityPubLinks(predicate ActivityPubLinkMapPredicate) IActivityPubLinkCollection + // GetActivityPubLink finds a specific 'Activity Pub Link' instance using + // the provided unique identifier or 'Id'. + GetActivityPubLink(id int64) IActivityPubLink + // AddActivityPubLink creates a new 'Activity Pub Link' 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. + AddActivityPubLink() IActivityPubLink + // AddActivityPubLinkWithCustomId creates a new 'Activity Pub Link' 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. + AddActivityPubLinkWithCustomId(id int64) IActivityPubLink + // LogActivityPubLink creates a new 'Activity Pub Link' 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. + LogActivityPubLink(source string, payload string) + // UpdateActivityPubLink finds the 'Activity Pub Link' 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. + UpdateActivityPubLink(id int64) IActivityPubLink + // UpdateActivityPubLinkObject finds and updates the 'Activity Pub Link' 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. + UpdateActivityPubLinkObject(object IObject, activityPubLink IActivityPubLink) IActivityPubLink + // AddOrUpdateActivityPubLinkObject tries to find the 'Activity Pub Link' 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. + AddOrUpdateActivityPubLinkObject(object IObject, activityPubLink IActivityPubLink) IActivityPubLink + // RemoveActivityPubLink finds the 'Activity Pub Link' 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. + RemoveActivityPubLink(id int64) IActivityPubLink + + // ActivityPubMedia + // ------------------------------------------------------------ + + // ActivityPubMediaExists checks whether a specific 'Activity Pub Media' with the provided + // unique identifier or 'Id' exists in the system. + ActivityPubMediaExists(id int64) bool + // ActivityPubMediaExistsWhich checks whether a specific 'Activity Pub Media' exists in the system + // which satisfies the provided condition. + ActivityPubMediaExistsWhich(condition ActivityPubMediaCondition) bool + // ListActivityPubMedias returns a list of all 'Activity Pub Media' instances in the system. + ListActivityPubMedias() IActivityPubMediaCollection + // ForEachActivityPubMedia loops over all 'Activity Pub Media' instances in the system running + // the provided iterator for each of them. + ForEachActivityPubMedia(iterator ActivityPubMediaIterator) + // FilterActivityPubMedias returns a filtered list of 'Activity Pub Media' instances based + // on the provided predicate. + FilterActivityPubMedias(predicate ActivityPubMediaFilterPredicate) IActivityPubMediaCollection + // MapActivityPubMedias loops over all 'Activity Pub Media' instances in the system and + // returns a transformed list based on the provided predicate. + MapActivityPubMedias(predicate ActivityPubMediaMapPredicate) IActivityPubMediaCollection + // GetActivityPubMedia finds a specific 'Activity Pub Media' instance using + // the provided unique identifier or 'Id'. + GetActivityPubMedia(id int64) IActivityPubMedia + // AddActivityPubMedia creates a new 'Activity Pub Media' 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. + AddActivityPubMedia() IActivityPubMedia + // AddActivityPubMediaWithCustomId creates a new 'Activity Pub Media' 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. + AddActivityPubMediaWithCustomId(id int64) IActivityPubMedia + // LogActivityPubMedia creates a new 'Activity Pub Media' 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. + LogActivityPubMedia(source string, payload string) + // UpdateActivityPubMedia finds the 'Activity Pub Media' 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. + UpdateActivityPubMedia(id int64) IActivityPubMedia + // UpdateActivityPubMediaObject finds and updates the 'Activity Pub Media' 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. + UpdateActivityPubMediaObject(object IObject, activityPubMedia IActivityPubMedia) IActivityPubMedia + // AddOrUpdateActivityPubMediaObject tries to find the 'Activity Pub Media' 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. + AddOrUpdateActivityPubMediaObject(object IObject, activityPubMedia IActivityPubMedia) IActivityPubMedia + // RemoveActivityPubMedia finds the 'Activity Pub Media' 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. + RemoveActivityPubMedia(id int64) IActivityPubMedia + // Spi // ------------------------------------------------------------ @@ -711,6 +879,18 @@ type IDispatcher interface { NewActivityPubActivity() (IActivityPubActivity, error) // NewActivityPubActivities creates an empty in-memory 'Activity Pub Activity' collection which is not thread-safe. NewActivityPubActivities() IActivityPubActivityCollection + // NewActivityPubPublicKey creates a new 'Activity Pub Public Key' instance using the provided property values. + NewActivityPubPublicKey() (IActivityPubPublicKey, error) + // NewActivityPubPublicKeys creates an empty in-memory 'Activity Pub Public Key' collection which is not thread-safe. + NewActivityPubPublicKeys() IActivityPubPublicKeyCollection + // NewActivityPubLink creates a new 'Activity Pub Link' instance using the provided property values. + NewActivityPubLink() (IActivityPubLink, error) + // NewActivityPubLinks creates an empty in-memory 'Activity Pub Link' collection which is not thread-safe. + NewActivityPubLinks() IActivityPubLinkCollection + // NewActivityPubMedia creates a new 'Activity Pub Media' instance using the provided property values. + NewActivityPubMedia() (IActivityPubMedia, error) + // NewActivityPubMedias creates an empty in-memory 'Activity Pub Media' collection which is not thread-safe. + NewActivityPubMedias() IActivityPubMediaCollection // 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_link_manager.go b/greataped/components/core/activity_pub_link_manager.go new file mode 100644 index 0000000..f4db9d9 --- /dev/null +++ b/greataped/components/core/activity_pub_link_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_LINK_MANAGER = "ActivityPubLinkManager" + +type activityPubLinkManager struct { + systemComponent + cache ICache +} + +func newActivityPubLinkManager(configuration IConfiguration, logger ILogger, dependencies ...ISystemComponent) IActivityPubLinkManager { + _ = ENABLE_CUSTOM_ERRORS + _ = validators.Initialize + + manager := &activityPubLinkManager{ + systemComponent: newSystemComponent(configuration, logger), + cache: NewCache(), + } + + if err := manager.ResolveDependencies(dependencies...); err != nil { + return nil + } + + return manager +} + +func (manager *activityPubLinkManager) Name() string { + return ACTIVITY_PUB_LINK_MANAGER +} + +func (manager *activityPubLinkManager) ResolveDependencies(_ ...ISystemComponent) error { + return nil +} + +func (manager *activityPubLinkManager) Load() error { + return nil +} + +func (manager *activityPubLinkManager) Reload() error { + return manager.Load() +} + +func (manager *activityPubLinkManager) OnCacheChanged(callback ActivityPubLinkCacheCallback) { + manager.cache.OnChanged(callback) +} + +func (manager *activityPubLinkManager) Count() int { + return manager.cache.Size() +} + +func (manager *activityPubLinkManager) Exists(id int64) bool { + return manager.Find(id) != nil +} + +func (manager *activityPubLinkManager) ExistsWhich(condition ActivityPubLinkCondition) bool { + var activityPubLinks ActivityPubLinks + manager.ForEach(func(activityPubLink IActivityPubLink) { + if condition(activityPubLink) { + activityPubLinks = append(activityPubLinks, activityPubLink) + } + }) + + return len(activityPubLinks) > 0 +} + +func (manager *activityPubLinkManager) ListActivityPubLinks(_ /* pageIndex */ uint32, _ /* pageSize */ uint32, _ /* criteria */ string, _ Identity) IActivityPubLinkCollection { + return manager.Filter(ActivityPubLinkPassThroughFilter) +} + +func (manager *activityPubLinkManager) GetActivityPubLink(id int64, _ Identity) (IActivityPubLink, error) { + if activityPubLink := manager.Find(id); activityPubLink == nil { + return nil, ERROR_ACTIVITY_PUB_LINK_NOT_FOUND + } else { + return activityPubLink, nil + } +} + +func (manager *activityPubLinkManager) AddActivityPubLink(editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) AddActivityPubLinkWithCustomId(id int64, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) AddActivityPubLinkObject(activityPubLink IActivityPubLink, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) AddActivityPubLinkAtomic(transaction ITransaction, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) AddActivityPubLinkWithCustomIdAtomic(id int64, transaction ITransaction, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) AddActivityPubLinkObjectAtomic(transaction ITransaction, activityPubLink IActivityPubLink, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) Log(source string, editor Identity, payload string) { +} + +func (manager *activityPubLinkManager) UpdateActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) UpdateActivityPubLinkObject(id int64, activityPubLink IActivityPubLink, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) UpdateActivityPubLinkAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) UpdateActivityPubLinkObjectAtomic(transaction ITransaction, id int64, activityPubLink IActivityPubLink, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) AddOrUpdateActivityPubLinkObject(id int64, activityPubLink IActivityPubLink, editor Identity) (IActivityPubLink, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubLinkObject(id, activityPubLink, editor) + } else { + return manager.AddActivityPubLinkObject(activityPubLink, editor) + } +} + +func (manager *activityPubLinkManager) AddOrUpdateActivityPubLinkObjectAtomic(transaction ITransaction, id int64, activityPubLink IActivityPubLink, editor Identity) (IActivityPubLink, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubLinkObjectAtomic(transaction, id, activityPubLink, editor) + } else { + return manager.AddActivityPubLinkObjectAtomic(transaction, activityPubLink, editor) + } +} + +func (manager *activityPubLinkManager) RemoveActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) RemoveActivityPubLinkAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubLink, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubLinkManager) Find(id int64) IActivityPubLink { + if object, exists := manager.cache.Get(id); !exists { + return nil + } else { + return object.(IActivityPubLink) + } +} + +func (manager *activityPubLinkManager) ForEach(iterator ActivityPubLinkIterator) { + manager.cache.ForEachValue(func(object ISystemObject) { + iterator(object.(IActivityPubLink)) + }) +} + +func (manager *activityPubLinkManager) Filter(predicate ActivityPubLinkFilterPredicate) IActivityPubLinkCollection { + activityPubLinks := NewActivityPubLinks() + if predicate == nil { + return activityPubLinks + } + + manager.ForEach(func(activityPubLink IActivityPubLink) { + if predicate(activityPubLink) { + activityPubLinks.Append(activityPubLink) + } + }) + + return activityPubLinks +} + +func (manager *activityPubLinkManager) Map(predicate ActivityPubLinkMapPredicate) IActivityPubLinkCollection { + activityPubLinks := NewActivityPubLinks() + if predicate == nil { + return activityPubLinks + } + + manager.ForEach(func(activityPubLink IActivityPubLink) { + activityPubLinks.Append(predicate(activityPubLink)) + }) + + return activityPubLinks +} diff --git a/greataped/components/core/activity_pub_media_manager.go b/greataped/components/core/activity_pub_media_manager.go new file mode 100644 index 0000000..94068f9 --- /dev/null +++ b/greataped/components/core/activity_pub_media_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_MEDIA_MANAGER = "ActivityPubMediaManager" + +type activityPubMediaManager struct { + systemComponent + cache ICache +} + +func newActivityPubMediaManager(configuration IConfiguration, logger ILogger, dependencies ...ISystemComponent) IActivityPubMediaManager { + _ = ENABLE_CUSTOM_ERRORS + _ = validators.Initialize + + manager := &activityPubMediaManager{ + systemComponent: newSystemComponent(configuration, logger), + cache: NewCache(), + } + + if err := manager.ResolveDependencies(dependencies...); err != nil { + return nil + } + + return manager +} + +func (manager *activityPubMediaManager) Name() string { + return ACTIVITY_PUB_MEDIA_MANAGER +} + +func (manager *activityPubMediaManager) ResolveDependencies(_ ...ISystemComponent) error { + return nil +} + +func (manager *activityPubMediaManager) Load() error { + return nil +} + +func (manager *activityPubMediaManager) Reload() error { + return manager.Load() +} + +func (manager *activityPubMediaManager) OnCacheChanged(callback ActivityPubMediaCacheCallback) { + manager.cache.OnChanged(callback) +} + +func (manager *activityPubMediaManager) Count() int { + return manager.cache.Size() +} + +func (manager *activityPubMediaManager) Exists(id int64) bool { + return manager.Find(id) != nil +} + +func (manager *activityPubMediaManager) ExistsWhich(condition ActivityPubMediaCondition) bool { + var activityPubMedias ActivityPubMedias + manager.ForEach(func(activityPubMedia IActivityPubMedia) { + if condition(activityPubMedia) { + activityPubMedias = append(activityPubMedias, activityPubMedia) + } + }) + + return len(activityPubMedias) > 0 +} + +func (manager *activityPubMediaManager) ListActivityPubMedias(_ /* pageIndex */ uint32, _ /* pageSize */ uint32, _ /* criteria */ string, _ Identity) IActivityPubMediaCollection { + return manager.Filter(ActivityPubMediaPassThroughFilter) +} + +func (manager *activityPubMediaManager) GetActivityPubMedia(id int64, _ Identity) (IActivityPubMedia, error) { + if activityPubMedia := manager.Find(id); activityPubMedia == nil { + return nil, ERROR_ACTIVITY_PUB_MEDIA_NOT_FOUND + } else { + return activityPubMedia, nil + } +} + +func (manager *activityPubMediaManager) AddActivityPubMedia(editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) AddActivityPubMediaWithCustomId(id int64, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) AddActivityPubMediaObject(activityPubMedia IActivityPubMedia, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) AddActivityPubMediaAtomic(transaction ITransaction, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) AddActivityPubMediaWithCustomIdAtomic(id int64, transaction ITransaction, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) AddActivityPubMediaObjectAtomic(transaction ITransaction, activityPubMedia IActivityPubMedia, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) Log(source string, editor Identity, payload string) { +} + +func (manager *activityPubMediaManager) UpdateActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) UpdateActivityPubMediaObject(id int64, activityPubMedia IActivityPubMedia, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) UpdateActivityPubMediaAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) UpdateActivityPubMediaObjectAtomic(transaction ITransaction, id int64, activityPubMedia IActivityPubMedia, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) AddOrUpdateActivityPubMediaObject(id int64, activityPubMedia IActivityPubMedia, editor Identity) (IActivityPubMedia, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubMediaObject(id, activityPubMedia, editor) + } else { + return manager.AddActivityPubMediaObject(activityPubMedia, editor) + } +} + +func (manager *activityPubMediaManager) AddOrUpdateActivityPubMediaObjectAtomic(transaction ITransaction, id int64, activityPubMedia IActivityPubMedia, editor Identity) (IActivityPubMedia, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubMediaObjectAtomic(transaction, id, activityPubMedia, editor) + } else { + return manager.AddActivityPubMediaObjectAtomic(transaction, activityPubMedia, editor) + } +} + +func (manager *activityPubMediaManager) RemoveActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) RemoveActivityPubMediaAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubMedia, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubMediaManager) Find(id int64) IActivityPubMedia { + if object, exists := manager.cache.Get(id); !exists { + return nil + } else { + return object.(IActivityPubMedia) + } +} + +func (manager *activityPubMediaManager) ForEach(iterator ActivityPubMediaIterator) { + manager.cache.ForEachValue(func(object ISystemObject) { + iterator(object.(IActivityPubMedia)) + }) +} + +func (manager *activityPubMediaManager) Filter(predicate ActivityPubMediaFilterPredicate) IActivityPubMediaCollection { + activityPubMedias := NewActivityPubMedias() + if predicate == nil { + return activityPubMedias + } + + manager.ForEach(func(activityPubMedia IActivityPubMedia) { + if predicate(activityPubMedia) { + activityPubMedias.Append(activityPubMedia) + } + }) + + return activityPubMedias +} + +func (manager *activityPubMediaManager) Map(predicate ActivityPubMediaMapPredicate) IActivityPubMediaCollection { + activityPubMedias := NewActivityPubMedias() + if predicate == nil { + return activityPubMedias + } + + manager.ForEach(func(activityPubMedia IActivityPubMedia) { + activityPubMedias.Append(predicate(activityPubMedia)) + }) + + return activityPubMedias +} diff --git a/greataped/components/core/activity_pub_public_key_manager.go b/greataped/components/core/activity_pub_public_key_manager.go new file mode 100644 index 0000000..b7f0773 --- /dev/null +++ b/greataped/components/core/activity_pub_public_key_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_PUBLIC_KEY_MANAGER = "ActivityPubPublicKeyManager" + +type activityPubPublicKeyManager struct { + systemComponent + cache ICache +} + +func newActivityPubPublicKeyManager(configuration IConfiguration, logger ILogger, dependencies ...ISystemComponent) IActivityPubPublicKeyManager { + _ = ENABLE_CUSTOM_ERRORS + _ = validators.Initialize + + manager := &activityPubPublicKeyManager{ + systemComponent: newSystemComponent(configuration, logger), + cache: NewCache(), + } + + if err := manager.ResolveDependencies(dependencies...); err != nil { + return nil + } + + return manager +} + +func (manager *activityPubPublicKeyManager) Name() string { + return ACTIVITY_PUB_PUBLIC_KEY_MANAGER +} + +func (manager *activityPubPublicKeyManager) ResolveDependencies(_ ...ISystemComponent) error { + return nil +} + +func (manager *activityPubPublicKeyManager) Load() error { + return nil +} + +func (manager *activityPubPublicKeyManager) Reload() error { + return manager.Load() +} + +func (manager *activityPubPublicKeyManager) OnCacheChanged(callback ActivityPubPublicKeyCacheCallback) { + manager.cache.OnChanged(callback) +} + +func (manager *activityPubPublicKeyManager) Count() int { + return manager.cache.Size() +} + +func (manager *activityPubPublicKeyManager) Exists(id int64) bool { + return manager.Find(id) != nil +} + +func (manager *activityPubPublicKeyManager) ExistsWhich(condition ActivityPubPublicKeyCondition) bool { + var activityPubPublicKeys ActivityPubPublicKeys + manager.ForEach(func(activityPubPublicKey IActivityPubPublicKey) { + if condition(activityPubPublicKey) { + activityPubPublicKeys = append(activityPubPublicKeys, activityPubPublicKey) + } + }) + + return len(activityPubPublicKeys) > 0 +} + +func (manager *activityPubPublicKeyManager) ListActivityPubPublicKeys(_ /* pageIndex */ uint32, _ /* pageSize */ uint32, _ /* criteria */ string, _ Identity) IActivityPubPublicKeyCollection { + return manager.Filter(ActivityPubPublicKeyPassThroughFilter) +} + +func (manager *activityPubPublicKeyManager) GetActivityPubPublicKey(id int64, _ Identity) (IActivityPubPublicKey, error) { + if activityPubPublicKey := manager.Find(id); activityPubPublicKey == nil { + return nil, ERROR_ACTIVITY_PUB_PUBLIC_KEY_NOT_FOUND + } else { + return activityPubPublicKey, nil + } +} + +func (manager *activityPubPublicKeyManager) AddActivityPubPublicKey(editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) AddActivityPubPublicKeyWithCustomId(id int64, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) AddActivityPubPublicKeyObject(activityPubPublicKey IActivityPubPublicKey, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) AddActivityPubPublicKeyAtomic(transaction ITransaction, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) AddActivityPubPublicKeyWithCustomIdAtomic(id int64, transaction ITransaction, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) AddActivityPubPublicKeyObjectAtomic(transaction ITransaction, activityPubPublicKey IActivityPubPublicKey, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) Log(source string, editor Identity, payload string) { +} + +func (manager *activityPubPublicKeyManager) UpdateActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) UpdateActivityPubPublicKeyObject(id int64, activityPubPublicKey IActivityPubPublicKey, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) UpdateActivityPubPublicKeyAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) UpdateActivityPubPublicKeyObjectAtomic(transaction ITransaction, id int64, activityPubPublicKey IActivityPubPublicKey, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) AddOrUpdateActivityPubPublicKeyObject(id int64, activityPubPublicKey IActivityPubPublicKey, editor Identity) (IActivityPubPublicKey, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubPublicKeyObject(id, activityPubPublicKey, editor) + } else { + return manager.AddActivityPubPublicKeyObject(activityPubPublicKey, editor) + } +} + +func (manager *activityPubPublicKeyManager) AddOrUpdateActivityPubPublicKeyObjectAtomic(transaction ITransaction, id int64, activityPubPublicKey IActivityPubPublicKey, editor Identity) (IActivityPubPublicKey, error) { + if manager.Exists(id) { + return manager.UpdateActivityPubPublicKeyObjectAtomic(transaction, id, activityPubPublicKey, editor) + } else { + return manager.AddActivityPubPublicKeyObjectAtomic(transaction, activityPubPublicKey, editor) + } +} + +func (manager *activityPubPublicKeyManager) RemoveActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) RemoveActivityPubPublicKeyAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubPublicKey, error) { + return nil, ERROR_NOT_IMPLEMENTED +} + +func (manager *activityPubPublicKeyManager) Find(id int64) IActivityPubPublicKey { + if object, exists := manager.cache.Get(id); !exists { + return nil + } else { + return object.(IActivityPubPublicKey) + } +} + +func (manager *activityPubPublicKeyManager) ForEach(iterator ActivityPubPublicKeyIterator) { + manager.cache.ForEachValue(func(object ISystemObject) { + iterator(object.(IActivityPubPublicKey)) + }) +} + +func (manager *activityPubPublicKeyManager) Filter(predicate ActivityPubPublicKeyFilterPredicate) IActivityPubPublicKeyCollection { + activityPubPublicKeys := NewActivityPubPublicKeys() + if predicate == nil { + return activityPubPublicKeys + } + + manager.ForEach(func(activityPubPublicKey IActivityPubPublicKey) { + if predicate(activityPubPublicKey) { + activityPubPublicKeys.Append(activityPubPublicKey) + } + }) + + return activityPubPublicKeys +} + +func (manager *activityPubPublicKeyManager) Map(predicate ActivityPubPublicKeyMapPredicate) IActivityPubPublicKeyCollection { + activityPubPublicKeys := NewActivityPubPublicKeys() + if predicate == nil { + return activityPubPublicKeys + } + + manager.ForEach(func(activityPubPublicKey IActivityPubPublicKey) { + activityPubPublicKeys.Append(predicate(activityPubPublicKey)) + }) + + return activityPubPublicKeys +} diff --git a/greataped/components/core/collections.go b/greataped/components/core/collections.go index 895600e..e4d8283 100644 --- a/greataped/components/core/collections.go +++ b/greataped/components/core/collections.go @@ -44,6 +44,18 @@ func (dispatcher *dispatcher) NewActivityPubActivities() IActivityPubActivityCol return NewActivityPubActivities() } +func (dispatcher *dispatcher) NewActivityPubPublicKeys() IActivityPubPublicKeyCollection { + return NewActivityPubPublicKeys() +} + +func (dispatcher *dispatcher) NewActivityPubLinks() IActivityPubLinkCollection { + return NewActivityPubLinks() +} + +func (dispatcher *dispatcher) NewActivityPubMedias() IActivityPubMediaCollection { + return NewActivityPubMedias() +} + func (dispatcher *dispatcher) NewSpis() ISpiCollection { return NewSpis() } diff --git a/greataped/components/core/factory.go b/greataped/components/core/factory.go index fdc2f61..a225169 100644 --- a/greataped/components/core/factory.go +++ b/greataped/components/core/factory.go @@ -34,6 +34,12 @@ func (factory *systemComponentFactory) Create(componentType SystemComponentType, component = newActivityPubObjectManager(configuration, logger, dependencies...) case SYSTEM_COMPONENT_ACTIVITY_PUB_ACTIVITY_MANAGER: component = newActivityPubActivityManager(configuration, logger, dependencies...) + case SYSTEM_COMPONENT_ACTIVITY_PUB_PUBLIC_KEY_MANAGER: + component = newActivityPubPublicKeyManager(configuration, logger, dependencies...) + case SYSTEM_COMPONENT_ACTIVITY_PUB_LINK_MANAGER: + component = newActivityPubLinkManager(configuration, logger, dependencies...) + case SYSTEM_COMPONENT_ACTIVITY_PUB_MEDIA_MANAGER: + component = newActivityPubMediaManager(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 f4a0015..7cbfedd 100644 --- a/greataped/components/core/initializer.go +++ b/greataped/components/core/initializer.go @@ -64,6 +64,9 @@ func Initialize(configuration IConfiguration, logger ILogger) error { 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) + activityPubPublicKeyManager := factory.Create(SYSTEM_COMPONENT_ACTIVITY_PUB_PUBLIC_KEY_MANAGER, configuration, logger).(IActivityPubPublicKeyManager) + activityPubLinkManager := factory.Create(SYSTEM_COMPONENT_ACTIVITY_PUB_LINK_MANAGER, configuration, logger).(IActivityPubLinkManager) + activityPubMediaManager := factory.Create(SYSTEM_COMPONENT_ACTIVITY_PUB_MEDIA_MANAGER, configuration, logger).(IActivityPubMediaManager) spiManager := factory.Create(SYSTEM_COMPONENT_SPI_MANAGER, configuration, logger).(ISpiManager) // Resolving Dependencies @@ -85,20 +88,23 @@ 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, - activityPubActivityManager: activityPubActivityManager, - 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, + activityPubPublicKeyManager: activityPubPublicKeyManager, + activityPubLinkManager: activityPubLinkManager, + activityPubMediaManager: activityPubMediaManager, + spiManager: spiManager, + logger: logger, + configuration: configuration, + scheduler: scheduler, httpClient: &http.Client{ Timeout: time.Second * 5, }, @@ -147,21 +153,24 @@ 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 - activityPubActivityManager IActivityPubActivityManager - 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 + activityPubPublicKeyManager IActivityPubPublicKeyManager + activityPubLinkManager IActivityPubLinkManager + activityPubMediaManager IActivityPubMediaManager + spiManager ISpiManager + logger ILogger + configuration IConfiguration + scheduler *schedule.Cron + httpClient *http.Client // @formatter:on } @@ -733,6 +742,144 @@ func (conductor *conductor) RemoveActivityPubActivityAtomic(transaction ITransac return conductor.activityPubActivityManager.RemoveActivityPubActivityAtomic(transaction, id, editor) } +// ActivityPubPublicKey + +func (conductor *conductor) ActivityPubPublicKeyManager() IActivityPubPublicKeyManager { + return conductor.activityPubPublicKeyManager +} + +func (conductor *conductor) ActivityPubPublicKeyExists(id int64) bool { + return conductor.activityPubPublicKeyManager.Exists(id) +} + +func (conductor *conductor) ListActivityPubPublicKeys(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubPublicKeyCollection { + return conductor.activityPubPublicKeyManager.ListActivityPubPublicKeys(pageIndex, pageSize, criteria, editor) +} + +func (conductor *conductor) GetActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.GetActivityPubPublicKey(id, editor) +} + +func (conductor *conductor) AddActivityPubPublicKey(editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.AddActivityPubPublicKey(editor) +} + +func (conductor *conductor) AddActivityPubPublicKeyAtomic(transaction ITransaction, editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.AddActivityPubPublicKeyAtomic(transaction, editor) +} + +func (conductor *conductor) LogActivityPubPublicKey(source string, editor Identity, payload string) { + conductor.activityPubPublicKeyManager.Log(source, editor, payload) +} + +func (conductor *conductor) UpdateActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.UpdateActivityPubPublicKey(id, editor) +} + +func (conductor *conductor) UpdateActivityPubPublicKeyAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.UpdateActivityPubPublicKeyAtomic(transaction, id, editor) +} + +func (conductor *conductor) RemoveActivityPubPublicKey(id int64, editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.RemoveActivityPubPublicKey(id, editor) +} + +func (conductor *conductor) RemoveActivityPubPublicKeyAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubPublicKey, error) { + return conductor.activityPubPublicKeyManager.RemoveActivityPubPublicKeyAtomic(transaction, id, editor) +} + +// ActivityPubLink + +func (conductor *conductor) ActivityPubLinkManager() IActivityPubLinkManager { + return conductor.activityPubLinkManager +} + +func (conductor *conductor) ActivityPubLinkExists(id int64) bool { + return conductor.activityPubLinkManager.Exists(id) +} + +func (conductor *conductor) ListActivityPubLinks(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubLinkCollection { + return conductor.activityPubLinkManager.ListActivityPubLinks(pageIndex, pageSize, criteria, editor) +} + +func (conductor *conductor) GetActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.GetActivityPubLink(id, editor) +} + +func (conductor *conductor) AddActivityPubLink(editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.AddActivityPubLink(editor) +} + +func (conductor *conductor) AddActivityPubLinkAtomic(transaction ITransaction, editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.AddActivityPubLinkAtomic(transaction, editor) +} + +func (conductor *conductor) LogActivityPubLink(source string, editor Identity, payload string) { + conductor.activityPubLinkManager.Log(source, editor, payload) +} + +func (conductor *conductor) UpdateActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.UpdateActivityPubLink(id, editor) +} + +func (conductor *conductor) UpdateActivityPubLinkAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.UpdateActivityPubLinkAtomic(transaction, id, editor) +} + +func (conductor *conductor) RemoveActivityPubLink(id int64, editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.RemoveActivityPubLink(id, editor) +} + +func (conductor *conductor) RemoveActivityPubLinkAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubLink, error) { + return conductor.activityPubLinkManager.RemoveActivityPubLinkAtomic(transaction, id, editor) +} + +// ActivityPubMedia + +func (conductor *conductor) ActivityPubMediaManager() IActivityPubMediaManager { + return conductor.activityPubMediaManager +} + +func (conductor *conductor) ActivityPubMediaExists(id int64) bool { + return conductor.activityPubMediaManager.Exists(id) +} + +func (conductor *conductor) ListActivityPubMedias(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IActivityPubMediaCollection { + return conductor.activityPubMediaManager.ListActivityPubMedias(pageIndex, pageSize, criteria, editor) +} + +func (conductor *conductor) GetActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.GetActivityPubMedia(id, editor) +} + +func (conductor *conductor) AddActivityPubMedia(editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.AddActivityPubMedia(editor) +} + +func (conductor *conductor) AddActivityPubMediaAtomic(transaction ITransaction, editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.AddActivityPubMediaAtomic(transaction, editor) +} + +func (conductor *conductor) LogActivityPubMedia(source string, editor Identity, payload string) { + conductor.activityPubMediaManager.Log(source, editor, payload) +} + +func (conductor *conductor) UpdateActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.UpdateActivityPubMedia(id, editor) +} + +func (conductor *conductor) UpdateActivityPubMediaAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.UpdateActivityPubMediaAtomic(transaction, id, editor) +} + +func (conductor *conductor) RemoveActivityPubMedia(id int64, editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.RemoveActivityPubMedia(id, editor) +} + +func (conductor *conductor) RemoveActivityPubMediaAtomic(transaction ITransaction, id int64, editor Identity) (IActivityPubMedia, error) { + return conductor.activityPubMediaManager.RemoveActivityPubMediaAtomic(transaction, id, editor) +} + // Spi func (conductor *conductor) SpiManager() ISpiManager { @@ -823,6 +970,18 @@ func (conductor *conductor) NewActivityPubActivity() (IActivityPubActivity, erro return NewActivityPubActivity() } +func (conductor *conductor) NewActivityPubPublicKey() (IActivityPubPublicKey, error) { + return NewActivityPubPublicKey() +} + +func (conductor *conductor) NewActivityPubLink() (IActivityPubLink, error) { + return NewActivityPubLink() +} + +func (conductor *conductor) NewActivityPubMedia() (IActivityPubMedia, error) { + return NewActivityPubMedia() +} + 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 2125623..3f4bf6c 100644 --- a/greataped/components/core/system_dispatcher.go +++ b/greataped/components/core/system_dispatcher.go @@ -148,6 +148,18 @@ func (dispatcher *dispatcher) NewActivityPubActivity() (IActivityPubActivity, er return NewActivityPubActivity() } +func (dispatcher *dispatcher) NewActivityPubPublicKey() (IActivityPubPublicKey, error) { + return NewActivityPubPublicKey() +} + +func (dispatcher *dispatcher) NewActivityPubLink() (IActivityPubLink, error) { + return NewActivityPubLink() +} + +func (dispatcher *dispatcher) NewActivityPubMedia() (IActivityPubMedia, error) { + return NewActivityPubMedia() +} + func (dispatcher *dispatcher) NewSpi() (ISpi, error) { return NewSpi() }