Properly save audio and image notes when uploaded

Also fix the audio processing pipeline.
This commit is contained in:
Eli Ribble 2026-01-06 22:23:59 +00:00
parent 4d02357671
commit 39d9f6d258
11 changed files with 145 additions and 138 deletions

View file

@ -3,20 +3,25 @@ package db
import (
"context"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/google/uuid"
"github.com/rs/zerolog/log"
)
type NidusNotePayload struct {}
type NoteAudio struct {
Transcription string
Version int
UUID uuid.UUID
}
type NoteImage struct {}
func NoteAudioCreate(ctx context.Context, noteUUID uuid.UUID, payload NoteAudio, userID int32) error {
return nil
func NoteAudioCreate(ctx context.Context, org *models.Organization, userID int32, setter models.NoteAudioSetter) error {
err := org.InsertNoteAudios(ctx, PGInstance.BobDB, &setter)
if err == nil {
return nil
}
// Just ignore this failure, it means we already have this content
if err.Error() == "insertOrganizationNoteAudios0: ERROR: duplicate key value violates unique constraint \"note_audio_pkey\" (SQLSTATE 23505)" {
return nil
}
log.Warn().Err(err).Msg("Unrecognized error creating note audio")
return err
}
func NoteAudioGetLatest(ctx context.Context, uuid string) (*NoteAudio, error) {
func NoteAudioGetLatest(ctx context.Context, uuid string) (*models.NoteAudio, error) {
return nil, nil
}
func NoteAudioNormalized(uuid string) error {
@ -25,9 +30,19 @@ func NoteAudioNormalized(uuid string) error {
func NoteAudioTranscodedToOgg(uuid string) error {
return nil
}
func NoteImageCreate(ctx context.Context, noteUUID uuid.UUID, payload NoteImage, userID int32) error {
return nil
}
func NoteUpdate(ctx context.Context, noteUUID uuid.UUID, payload NidusNotePayload) error {
func NoteImageCreate(ctx context.Context, org *models.Organization, userID int32, setter models.NoteImageSetter) error {
err := org.InsertNoteImages(ctx, PGInstance.BobDB, &setter)
if err == nil {
return nil
}
// Just ignore this failure, it means we already have this content
if err.Error() == "insertOrganizationNoteImages0: ERROR: duplicate key value violates unique constraint \"note_image_pkey\" (SQLSTATE 23505)" {
return nil
}
log.Warn().Err(err).Msg("Unrecognized error creating note audio")
return err
}
func NoteUpdate(ctx context.Context, noteUUID uuid.UUID, setter models.NoteAudioSetter) error {
return nil
}