fix(zopk): Capture current_user.id before SSE scrape generator
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

Flask-Login's current_user proxy loses context inside generator
functions. Same fix as applied to search stream endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-02-09 15:24:59 +01:00
parent a1cf9519f0
commit 841fe0df67

View File

@ -813,12 +813,13 @@ def admin_zopk_news_scrape_stream():
limit = request.args.get('limit', 50, type=int)
force = request.args.get('force', 'false').lower() == 'true'
user_id = current_user.id # Capture before generator (proxy loses context inside)
def generate():
import json
db = SessionLocal()
try:
scraper = ZOPKContentScraper(db, user_id=current_user.id)
scraper = ZOPKContentScraper(db, user_id=user_id)
# Get articles to scrape
query = db.query(ZOPKNews).filter(