video-accessibility/backend/app/services
Vadym Samoilenko 1563714454 feat(saas): Phase 3 — membership-based authz + Mailgun + job.organization_id
authz.py (new):
- MembershipContext — per-request membership dict for the current user
- get_membership_context FastAPI dependency
- require_org_role(min_role) — dependency factory keyed off org_id path param
- require_platform_admin()
- OrgScopedQuery — adds organization_id filter; platform admin passes through
- bump_user_membership_cache — invalidates Redis key on membership writes

dependencies.py:
- get_accessible_project_ids now queries memberships collection first;
  legacy pm_client_ids / team.member_user_ids fallback retained until migration runs
  (four job-route access checks at lines 608/1054/1181/1538 are fixed via this function)

routes_clients.py:
- _assert_pm_or_admin and _assert_client_access are now async and query memberships
- All 10 call sites updated with await + db arg

emailer.py:
- Switched from SendGrid to Mailgun REST API via httpx (already in requirements)
- _send() is now fully async; same public method signatures preserved
- send_completion_email uses _send()

config.py:
- Added mailgun_api_key, mailgun_domain, mailgun_from settings
- sendgrid_api_key kept with empty default for backward compat

migration_2026-04-28-000003:
- Backfills job.organization_id from project.client_id
- Creates (organization_id, status, created_at) sparse index on jobs

routes_organizations.py / routes_invitations.py:
- Call bump_user_membership_cache after every membership write

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 16:56:42 +01:00
..
__pycache__ better tts config for worker 2025-10-08 18:47:28 -05:00
audit_logger.py initial commit 2025-08-24 16:28:33 -05:00
cost_tracker.py fix: correct cost tracker API field names and endpoint path 2026-04-27 13:42:29 +00:00
descriptive_transcript.py feat: DCMP compliance, descriptive transcript, new languages, QA bug fixes 2026-03-27 11:50:43 +00:00
elevenlabs_voices.py fix: propagate ElevenLabs voice fetch errors to frontend 2026-03-03 14:27:45 +00:00
emailer.py feat(saas): Phase 3 — membership-based authz + Mailgun + job.organization_id 2026-04-27 16:56:42 +01:00
ffmpeg_http_service.py feat: add Cloud Run HTTP services for Whisper and FFmpeg 2026-01-02 10:12:50 -06:00
gcs.py fix: add charset=utf-8 to VTT content-type to prevent ♪ encoding issues 2026-03-27 14:17:16 +00:00
gemini.py feat: replace SDK with direct HTTP integration to centralized cost tracker 2026-04-27 13:36:15 +01:00
gemini_tts.py feat: add TTS_FAILED status and robust error handling for TTS synthesis 2025-12-30 14:26:07 -06:00
membership_service.py feat(saas): Phase 0+1 — Organization/Membership entities and dev branch 2026-04-27 16:46:24 +01:00
microsoft_auth.py added MSAL microsoft authentication 2025-10-10 09:19:39 -05:00
secrets_manager.py initial commit 2025-08-24 16:28:33 -05:00
tts.py feat: add ElevenLabs voice selection to frontend and backend 2026-03-03 13:58:56 +00:00
validation.py feat: add accessible video validation, remove AI confidence check 2025-12-26 16:41:57 -06:00
video_renderer.py feat: DCMP compliance, descriptive transcript, new languages, QA bug fixes 2026-03-27 11:50:43 +00:00
vtt_retimer.py fix: use actual freeze segment durations for VTT subtitle retiming 2026-01-05 15:52:57 -06:00
websocket.py wrote docker files and deployment instructions 2025-10-08 16:00:12 -05:00
websocket_publisher.py wrote docker files and deployment instructions 2025-10-08 16:00:12 -05:00
whisper_http_service.py feat: add Cloud Run HTTP services for Whisper and FFmpeg 2026-01-02 10:12:50 -06:00
whisper_service.py fix: enforce AD cue pause_point monotonicity to preserve cue order 2026-02-26 08:15:06 -06:00
zip_download.py feat: DCMP compliance, descriptive transcript, new languages, QA bug fixes 2026-03-27 11:50:43 +00:00