chore: delete dead platforms.py and fix seed_campaigns mutation bug

This commit is contained in:
pyr0ball 2026-04-27 13:03:57 -07:00
parent a3932aef1e
commit 6cf61663a5
2 changed files with 3 additions and 39 deletions

View file

@ -1,37 +0,0 @@
"""
Platform registry: maps platform names to their poster implementations.
Adding a new platform:
1. Create app/services/<platform>/client.py implementing PlatformClient
2. Register it here in REGISTRY
This keeps poster.py platform-agnostic it looks up the right client by
the campaign's `platform` field rather than branching on strings everywhere.
"""
from __future__ import annotations
from typing import Protocol
class PlatformClient(Protocol):
def post(self, target: str, title: str, body: str, flair: str | None = None) -> str:
"""Post content to a target (sub, group, channel). Returns a URL."""
...
def get_client(platform: str) -> PlatformClient:
"""Return an initialized client for the given platform name."""
if platform == "reddit":
from app.services.reddit.client import RedditClient
return RedditClient()
raise NotImplementedError(
f"Platform '{platform}' is not yet implemented. "
f"Add a client in app/services/{platform}/ and register it here."
)
# Platforms with posting support implemented
SUPPORTED_PLATFORMS = {"reddit"}
# Platforms planned but not yet implemented
PLANNED_PLATFORMS = {"facebook", "discord", "lemmy", "mastodon"}

View file

@ -412,8 +412,9 @@ def seed(store: Store) -> None:
print() print()
print("Seeding sub rules...") print("Seeding sub rules...")
for rule in SUB_RULES: for rule in SUB_RULES:
sub = rule.pop("sub") sub = rule["sub"]
store.upsert_sub_rules(sub=sub, last_checked="2026-04-21", **rule) fields = {k: v for k, v in rule.items() if k != "sub"}
store.upsert_sub_rules(sub=sub, last_checked="2026-04-21", **fields)
allowed = "OK" if rule.get("promo_allowed") else "BANNED" allowed = "OK" if rule.get("promo_allowed") else "BANNED"
print(f" r/{sub}: {allowed}") print(f" r/{sub}: {allowed}")