2026-03-12 23:49:16 +00:00
|
|
|
package platform
|
2025-12-16 16:37:53 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-03-16 19:52:29 +00:00
|
|
|
"fmt"
|
2025-12-16 16:37:53 +00:00
|
|
|
|
2026-03-12 23:49:16 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
2026-01-06 22:23:59 +00:00
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
2025-12-16 16:37:53 +00:00
|
|
|
"github.com/google/uuid"
|
2026-01-06 22:23:59 +00:00
|
|
|
"github.com/rs/zerolog/log"
|
2025-12-16 16:37:53 +00:00
|
|
|
)
|
|
|
|
|
|
2026-03-12 23:49:16 +00:00
|
|
|
func NoteAudioCreate(ctx context.Context, user User, setter models.NoteAudioSetter) error {
|
2026-03-16 19:52:29 +00:00
|
|
|
_, err := models.Organizations.Insert(&setter).One(ctx, db.PGInstance.BobDB)
|
|
|
|
|
if err != 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 fmt.Errorf("create note_audio: %w", err)
|
|
|
|
|
}
|
2026-01-06 22:23:59 +00:00
|
|
|
}
|
2026-03-16 19:52:29 +00:00
|
|
|
return nil
|
2025-12-16 16:37:53 +00:00
|
|
|
}
|
2026-01-06 22:23:59 +00:00
|
|
|
|
2025-12-16 16:37:53 +00:00
|
|
|
func NoteAudioNormalized(uuid string) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
func NoteAudioTranscodedToOgg(uuid string) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
2026-03-12 23:49:16 +00:00
|
|
|
func NoteImageCreate(ctx context.Context, user User, setter models.NoteImageSetter) error {
|
|
|
|
|
err := user.Organization.model.InsertNoteImages(ctx, db.PGInstance.BobDB, &setter)
|
2026-01-06 22:23:59 +00:00
|
|
|
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
|
2025-12-16 16:37:53 +00:00
|
|
|
}
|
2026-01-06 22:23:59 +00:00
|
|
|
|
|
|
|
|
func NoteUpdate(ctx context.Context, noteUUID uuid.UUID, setter models.NoteAudioSetter) error {
|
2025-12-16 16:37:53 +00:00
|
|
|
return nil
|
|
|
|
|
}
|