fix: don't overwrite vanity Facebook URL with numeric page ID link
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

Graph API returns link as facebook.com/123456 even when a vanity URL
exists. Skip API link when it contains only digits after facebook.com/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-19 14:06:55 +01:00
parent 0ddde6af22
commit b5211c63d6

View File

@ -352,8 +352,12 @@ def sync_facebook_to_social_media(db, company_id: int) -> dict:
if page_info.get('single_line_address'):
completeness += 25
# URL: prefer API link, then existing URL, then numeric fallback
# URL: prefer API vanity link, then existing URL, then numeric fallback
# Don't replace a vanity URL with a numeric one (e.g. facebook.com/inpipl → facebook.com/123456)
import re
api_link = page_info.get('link')
if api_link and re.search(r'facebook\.com/\d+$', api_link):
api_link = None # Numeric URL, not useful as replacement
# 6. Upsert CompanySocialMedia record
# Look for existing Facebook record for this company (any URL)