Recovered state: integrated TrendSurferAgent, restored frontend/backend files, and cleaned up recovery scripts

This commit is contained in:
ajaysi
2026-02-08 13:56:57 +05:30
parent 1db10ccd0f
commit e404a86502
333 changed files with 42223 additions and 10875 deletions

View File

@@ -15,13 +15,57 @@ from .wordpress_content import WordPressContentManager
import sqlite3
from services.database import get_user_db_path
class WordPressPublisher:
"""High-level WordPress publishing service."""
"""Handles publishing content to WordPress."""
def __init__(self, db_path: str = "alwrity.db"):
"""Initialize WordPress publisher."""
self.wp_service = WordPressService(db_path)
def __init__(self, db_path: str = None):
# db_path is deprecated
self.db_path = db_path
def _get_db_path(self, user_id: str) -> str:
return get_user_db_path(user_id)
def _init_db(self, user_id: str):
"""Initialize database tables for published posts."""
db_path = self._get_db_path(user_id)
os.makedirs(os.path.dirname(db_path), exist_ok=True)
with sqlite3.connect(db_path) as conn:
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS wordpress_posts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT NOT NULL,
wp_post_id INTEGER NOT NULL,
wp_url TEXT NOT NULL,
title TEXT NOT NULL,
status TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
''')
conn.commit()
def save_post_info(self, user_id: str, wp_post_id: int, wp_url: str, title: str, status: str) -> bool:
"""Save information about a published post."""
try:
self._init_db(user_id)
db_path = self._get_db_path(user_id)
with sqlite3.connect(db_path) as conn:
cursor = conn.cursor()
cursor.execute('''
INSERT INTO wordpress_posts (user_id, wp_post_id, wp_url, title, status)
VALUES (?, ?, ?, ?, ?)
''', (user_id, wp_post_id, wp_url, title, status))
conn.commit()
return True
except Exception as e:
logger.error(f"Error saving WordPress post info: {e}")
return False
def publish_blog_post(self, user_id: str, site_id: int,
title: str, content: str,