feat: audio track history

This commit is contained in:
Krispire Admin
2026-07-02 19:22:54 +05:30
parent 44a0016513
commit 9c9c46caf1
7 changed files with 273 additions and 0 deletions
+13
View File
@@ -54,6 +54,7 @@ type Server struct {
authH *handler.AuthHandler
oauthH *handler.OAuthHandler
userH *handler.UserHandler
audioH *handler.AudioProgressHandler
postH *handler.PostHandler
commentH *handler.CommentHandler
bookmarkH *handler.BookmarkHandler
@@ -194,6 +195,11 @@ func (s *Server) initAuth(cfg *config.Config, logger *zap.Logger) {
s.authH = handler.NewAuthHandler(authSvc, cookieOpts)
s.userH = handler.NewUserHandler(userSvc)
// Audio playback resume points — per-user, per-file last position that
// lets the floating player pick up where it left off across devices.
audioProgressRepo := repository.NewAudioProgressRepo(s.pg)
s.audioH = handler.NewAudioProgressHandler(service.NewAudioProgressService(audioProgressRepo))
// OAuth — wired only when at least one provider is configured. The
// registry skips providers with missing creds, so partial configs (e.g.
// Google only, no Facebook) work out of the box.
@@ -706,6 +712,13 @@ func (s *Server) setupRouter() {
// opaque JSON object.
r.Get("/me/reading-prefs", s.userH.GetReadingPrefs)
r.Put("/me/reading-prefs", s.userH.UpdateReadingPrefs)
// Audio player resume points roam with the account too, so a
// lecture picks up where you left off on any device. Schema is
// owned by the frontend; the server stores opaque key/position
// rows and merges newest-wins.
r.Get("/me/audio-progress", s.audioH.Get)
r.Put("/me/audio-progress", s.audioH.Put)
r.Delete("/me/audio-progress", s.audioH.Delete)
})
})