forked from LiveCarta/ContentAutomation
Store posting results to a mongodb
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from content_automation.adapters.publish_store.mongodb import MongoPublishedContentStore
|
||||
from content_automation.adapters.social.instagram import InstagramAdapter
|
||||
from content_automation.adapters.social.youtube import YouTubeAdapter
|
||||
from content_automation.adapters.storage.base import StorageAdapterBase
|
||||
from content_automation.adapters.storage.local import LocalFilesystemStorageAdapter
|
||||
from content_automation.adapters.storage.s3 import S3StorageAdapter
|
||||
from content_automation.interfaces import SocialNetworkAdapter
|
||||
from content_automation.interfaces import PublishedContentStore, SocialNetworkAdapter
|
||||
from content_automation.settings import AppSettings
|
||||
|
||||
|
||||
@@ -49,3 +50,22 @@ def build_social_adapters(settings: AppSettings) -> dict[str, SocialNetworkAdapt
|
||||
expiry=settings.youtube.expiry or None,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def build_published_content_store(
|
||||
settings: AppSettings,
|
||||
) -> PublishedContentStore | None:
|
||||
if not settings.mongodb.enabled:
|
||||
return None
|
||||
|
||||
if not settings.mongodb.connection_uri:
|
||||
raise ValueError(
|
||||
"CONTENT_AUTOMATION_MONGODB__CONNECTION_URI must be set when "
|
||||
"MongoDB persistence is enabled."
|
||||
)
|
||||
|
||||
return MongoPublishedContentStore(
|
||||
connection_uri=settings.mongodb.connection_uri,
|
||||
database_name=settings.mongodb.database_name,
|
||||
collection_name=settings.mongodb.collection_name,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user