feat: Add publish and mark-published endpoints with validation

- Add /api/posts/{id}/publish endpoint for API-based publishing
- Add /api/posts/{id}/mark-published endpoint for manual workflow
- Add content length validation before publishing
- Update modal with "Ya lo publiqué" and "Publicar (API)" buttons
- Fix retry_count handling for None values

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 23:01:28 +00:00
parent 855e765417
commit 29520a00f6
4 changed files with 122 additions and 8 deletions

View File

@@ -99,6 +99,18 @@ def publish_to_platform(self, post_id: int, platform: str):
else:
# Publicación normal
content = post.get_content_for_platform(platform)
# Validar longitud antes de publicar
if hasattr(publisher, 'char_limit') and len(content) > publisher.char_limit:
error_msg = (
f"Contenido excede límite: {len(content)}/{publisher.char_limit} "
f"caracteres (sobran {len(content) - publisher.char_limit})"
)
post.error_message = f"{platform}: {error_msg}"
post.status = "failed"
db.commit()
return f"Error en {platform}: {error_msg}"
result = run_async(
publisher.publish(content, post.image_url)
)
@@ -125,7 +137,7 @@ def publish_to_platform(self, post_id: int, platform: str):
else:
# Error en publicación
post.error_message = f"{platform}: {result.error_message}"
post.retry_count += 1
post.retry_count = (post.retry_count or 0) + 1
if post.retry_count >= 3:
post.status = "failed"