pleroma-support - optionally use pleroma as a host for the bot. #54
1 changed files with 22 additions and 8 deletions
|
@ -8,9 +8,13 @@ class FediverseServiceFactory:
|
||||||
"""Factory for creating FediverseService implementations based on configuration"""
|
"""Factory for creating FediverseService implementations based on configuration"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_service() -> FediverseService:
|
def create_service(instance_type: str = None) -> FediverseService:
|
||||||
"""
|
"""
|
||||||
Create a FediverseService implementation based on the configured instance type.
|
Create a FediverseService implementation based on the instance type.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
instance_type: The type of instance ("misskey" or "pleroma").
|
||||||
|
If None, reads from config.INSTANCE_TYPE
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
FediverseService implementation (MisskeyService or PleromaService)
|
FediverseService implementation (MisskeyService or PleromaService)
|
||||||
|
@ -18,14 +22,24 @@ class FediverseServiceFactory:
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If the instance type is not supported
|
ValueError: If the instance type is not supported
|
||||||
"""
|
"""
|
||||||
if config.INSTANCE_TYPE == "misskey":
|
if instance_type is None:
|
||||||
|
instance_type = config.INSTANCE_TYPE
|
||||||
|
|
||||||
|
instance_type = instance_type.lower()
|
||||||
|
|
||||||
|
if instance_type == "misskey":
|
||||||
return MisskeyService()
|
return MisskeyService()
|
||||||
elif config.INSTANCE_TYPE == "pleroma":
|
elif instance_type == "pleroma":
|
||||||
return PleromaService()
|
return PleromaService()
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unsupported instance type: {config.INSTANCE_TYPE}")
|
raise ValueError(f"Unsupported instance type: {instance_type}")
|
||||||
|
|
||||||
|
|
||||||
def get_fediverse_service() -> FediverseService:
|
def get_fediverse_service(instance_type: str = None) -> FediverseService:
|
||||||
"""Convenience function to get a FediverseService instance"""
|
"""
|
||||||
return FediverseServiceFactory.create_service()
|
Convenience function to get a FediverseService instance
|
||||||
|
|
||||||
|
Args:
|
||||||
|
instance_type: Optional instance type override for testing
|
||||||
|
"""
|
||||||
|
return FediverseServiceFactory.create_service(instance_type)
|
Loading…
Add table
Reference in a new issue