This commit is contained in:
Igor Loskutov
2025-06-19 10:13:57 -04:00
parent 98acf298d6
commit 6cb46dc64f
10 changed files with 59 additions and 31 deletions

View File

@@ -189,15 +189,19 @@ class MeetingController:
class MeetingConsentController:
async def get_by_meeting_id(self, meeting_id: str) -> list[MeetingConsent]:
query = meeting_consent.select().where(meeting_consent.c.meeting_id == meeting_id)
query = meeting_consent.select().where(
meeting_consent.c.meeting_id == meeting_id
)
results = await database.fetch_all(query)
return [MeetingConsent(**result) for result in results]
async def get_by_meeting_and_user(self, meeting_id: str, user_id: str) -> MeetingConsent | None:
async def get_by_meeting_and_user(
self, meeting_id: str, user_id: str
) -> MeetingConsent | None:
"""Get existing consent for a specific user and meeting"""
query = meeting_consent.select().where(
meeting_consent.c.meeting_id == meeting_id,
meeting_consent.c.user_id == user_id
meeting_consent.c.user_id == user_id,
)
result = await database.fetch_one(query)
return MeetingConsent(**result) if result else None
@@ -207,16 +211,20 @@ class MeetingConsentController:
if consent.user_id:
# For authenticated users, check if consent already exists
# not transactional but we're ok with that; the consents ain't deleted anyways
existing = await self.get_by_meeting_and_user(consent.meeting_id, consent.user_id)
existing = await self.get_by_meeting_and_user(
consent.meeting_id, consent.user_id
)
if existing:
query = meeting_consent.update().where(
meeting_consent.c.id == existing.id
).values(
consent_given=consent.consent_given,
consent_timestamp=consent.consent_timestamp,
query = (
meeting_consent.update()
.where(meeting_consent.c.id == existing.id)
.values(
consent_given=consent.consent_given,
consent_timestamp=consent.consent_timestamp,
)
)
await database.execute(query)
existing.consent_given = consent.consent_given
existing.consent_timestamp = consent.consent_timestamp
return existing
@@ -224,12 +232,12 @@ class MeetingConsentController:
query = meeting_consent.insert().values(**consent.model_dump())
await database.execute(query)
return consent
async def has_any_denial(self, meeting_id: str) -> bool:
"""Check if any participant denied consent for this meeting"""
query = meeting_consent.select().where(
meeting_consent.c.meeting_id == meeting_id,
meeting_consent.c.consent_given.is_(False)
meeting_consent.c.consent_given.is_(False),
)
result = await database.fetch_one(query)
return result is not None

View File

@@ -22,6 +22,7 @@ recordings = sa.Table(
sa.Column("meeting_id", sa.String),
)
class Recording(BaseModel):
id: str = Field(default_factory=generate_uuid4)
bucket_name: str

View File

@@ -76,6 +76,7 @@ transcripts = sqlalchemy.Table(
sqlalchemy.Column("audio_deleted", sqlalchemy.Boolean, nullable=True),
)
def generate_transcript_name() -> str:
now = datetime.utcnow()
return f"Transcript {now.strftime('%Y-%m-%d %H:%M:%S')}"
@@ -550,13 +551,17 @@ class TranscriptController:
"""
if transcript.audio_deleted:
raise FileNotFoundError(f"Invalid state of transcript {transcript.id}: audio_deleted mark is set true")
raise FileNotFoundError(
f"Invalid state of transcript {transcript.id}: audio_deleted mark is set true"
)
if transcript.audio_location == "local":
# store the audio on external storage if it's not already there
if not transcript.audio_mp3_filename.exists():
raise FileNotFoundError(f"Audio file not found: {transcript.audio_mp3_filename}")
raise FileNotFoundError(
f"Audio file not found: {transcript.audio_mp3_filename}"
)
await get_transcripts_storage().put_file(
transcript.storage_audio_path,
transcript.audio_mp3_filename.read_bytes(),