fix: allow retry of failed Facebook posts and fix token type
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

- Add 'failed' to allowed statuses in publish_post() and update_post()
- Show "Spróbuj ponownie" button for failed posts in form template
- Root cause: select-page endpoint stored USER token instead of PAGE token

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-19 15:56:35 +01:00
parent 3a2aa6f33a
commit 6d1dfd2d4d
2 changed files with 5 additions and 5 deletions

View File

@ -303,7 +303,7 @@ class SocialPublisherService:
post = db.query(SocialPost).filter(SocialPost.id == post_id).first()
if not post:
return None
if post.status in ('published', 'failed'):
if post.status == 'published':
logger.warning(f"Cannot edit post #{post_id} with status={post.status}")
return None
@ -425,9 +425,9 @@ class SocialPublisherService:
post = db.query(SocialPost).filter(SocialPost.id == post_id).first()
if not post:
return False, "Post nie znaleziony"
allowed = ('draft', 'approved', 'scheduled')
allowed = ('draft', 'approved', 'scheduled', 'failed')
if force_live:
allowed = ('draft', 'approved', 'scheduled', 'published')
allowed = ('draft', 'approved', 'scheduled', 'published', 'failed')
if post.status not in allowed:
return False, f"Nie można opublikować posta ze statusem: {post.status}"

View File

@ -640,8 +640,8 @@
{% if post.status == 'draft' %}
<button type="submit" name="action" value="approve" class="btn btn-info" style="background: #0ea5e9; color: white; border: none;">Zatwierdz</button>
{% endif %}
{% if post.status in ['draft', 'approved'] %}
<button type="submit" name="action" value="publish" class="btn btn-success">Publikuj teraz{% if is_debug %} (debug){% endif %}</button>
{% if post.status in ['draft', 'approved', 'failed'] %}
<button type="submit" name="action" value="publish" class="btn btn-success">{% if post.status == 'failed' %}Spróbuj ponownie{% else %}Publikuj teraz{% endif %}{% if is_debug %} (debug){% endif %}</button>
{% if is_debug %}
<button type="button" class="btn btn-danger"
onclick="showConfirm({icon: '🌐', title: 'Publikacja na żywo', message: 'Post zostanie opublikowany publicznie i będzie widoczny dla wszystkich użytkowników Facebooka.', okText: 'Publikuj na żywo', okClass: 'btn btn-danger', submitAction: 'publish_live'});">