from app.services.distribution.publishers.base import ContentPublisher, PublishResult
from app.services.distribution.publishers.mock_publisher import MockPublisher

__all__ = ["ContentPublisher", "PublishResult", "MockPublisher", "get_publisher"]


def get_publisher(platform: str) -> ContentPublisher:
    from app.config import settings

    if settings.DISTRIBUTION_MODE == "mock":
        return MockPublisher(platform=platform)

    if platform == "zhihu":
        from app.services.distribution.publishers.zhihu_publisher import ZhihuPublisher

        pub = ZhihuPublisher()
        return pub if pub.is_configured() else MockPublisher(platform="zhihu")
    elif platform == "toutiao":
        from app.services.distribution.publishers.toutiao_publisher import ToutiaoPublisher

        pub = ToutiaoPublisher()
        return pub if pub.is_configured() else MockPublisher(platform="toutiao")
    elif platform == "wechat":
        from app.services.distribution.publishers.wechat_publisher import WeChatPublisher

        pub = WeChatPublisher()
        return pub if pub.is_configured() else MockPublisher(platform="wechat")

    return MockPublisher(platform=platform)
