diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go index e9667f1..39aecb7 100644 --- a/cmd/gonic/gonic.go +++ b/cmd/gonic/gonic.go @@ -17,8 +17,8 @@ import ( "github.com/peterbourgon/ff" "go.senan.xyz/gonic" - "go.senan.xyz/gonic/server" "go.senan.xyz/gonic/db" + "go.senan.xyz/gonic/server" ) const ( diff --git a/db/migrations.go b/db/migrations.go index 4e6d659..a84025b 100644 --- a/db/migrations.go +++ b/db/migrations.go @@ -349,7 +349,6 @@ func migratePodcastDropUserID(tx *gorm.DB, _ MigrationContext) error { return nil } - step = tx.Exec(` ALTER TABLE podcasts DROP COLUMN user_id; `) diff --git a/server/ctrlsubsonic/handlers_bookmark.go b/server/ctrlsubsonic/handlers_bookmark.go index 8d5de41..60e8f93 100644 --- a/server/ctrlsubsonic/handlers_bookmark.go +++ b/server/ctrlsubsonic/handlers_bookmark.go @@ -6,10 +6,10 @@ import ( "github.com/jinzhu/gorm" + "go.senan.xyz/gonic/db" "go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/spec" "go.senan.xyz/gonic/server/ctrlsubsonic/specid" - "go.senan.xyz/gonic/db" ) func (c *Controller) ServeGetBookmarks(r *http.Request) *spec.Response { diff --git a/server/ctrlsubsonic/handlers_podcast.go b/server/ctrlsubsonic/handlers_podcast.go index 2557a6c..90f827a 100644 --- a/server/ctrlsubsonic/handlers_podcast.go +++ b/server/ctrlsubsonic/handlers_podcast.go @@ -5,10 +5,10 @@ import ( "github.com/mmcdole/gofeed" + "go.senan.xyz/gonic/db" "go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/spec" "go.senan.xyz/gonic/server/ctrlsubsonic/specid" - "go.senan.xyz/gonic/db" ) func (c *Controller) ServeGetPodcasts(r *http.Request) *spec.Response { @@ -45,7 +45,7 @@ func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response { func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response { user := r.Context().Value(CtxUser).(*db.User) - if (!user.IsAdmin) { + if !user.IsAdmin { return spec.NewError(50, "user not admin") } params := r.Context().Value(CtxParams).(params.Params) @@ -61,7 +61,7 @@ func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response func (c *Controller) ServeCreatePodcastChannel(r *http.Request) *spec.Response { user := r.Context().Value(CtxUser).(*db.User) - if (!user.IsAdmin) { + if !user.IsAdmin { return spec.NewError(50, "user not admin") } params := r.Context().Value(CtxParams).(params.Params) @@ -79,7 +79,7 @@ func (c *Controller) ServeCreatePodcastChannel(r *http.Request) *spec.Response { func (c *Controller) ServeRefreshPodcasts(r *http.Request) *spec.Response { user := r.Context().Value(CtxUser).(*db.User) - if (!user.IsAdmin) { + if !user.IsAdmin { return spec.NewError(50, "user not admin") } if err := c.Podcasts.RefreshPodcasts(); err != nil { @@ -90,7 +90,7 @@ func (c *Controller) ServeRefreshPodcasts(r *http.Request) *spec.Response { func (c *Controller) ServeDeletePodcastChannel(r *http.Request) *spec.Response { user := r.Context().Value(CtxUser).(*db.User) - if (!user.IsAdmin) { + if !user.IsAdmin { return spec.NewError(50, "user not admin") } params := r.Context().Value(CtxParams).(params.Params) @@ -106,7 +106,7 @@ func (c *Controller) ServeDeletePodcastChannel(r *http.Request) *spec.Response { func (c *Controller) ServeDeletePodcastEpisode(r *http.Request) *spec.Response { user := r.Context().Value(CtxUser).(*db.User) - if (!user.IsAdmin) { + if !user.IsAdmin { return spec.NewError(50, "user not admin") } params := r.Context().Value(CtxParams).(params.Params) diff --git a/server/ctrlsubsonic/specid/ids.go b/server/ctrlsubsonic/specid/ids.go index dbddafe..75c6496 100644 --- a/server/ctrlsubsonic/specid/ids.go +++ b/server/ctrlsubsonic/specid/ids.go @@ -75,15 +75,15 @@ func (i ID) MarshalJSON() ([]byte, error) { return json.Marshal(i.String()) } -func (i *ID) UnmarshalJSON(data []byte) (error) { - if (len(data) <= 2) { +func (i *ID) UnmarshalJSON(data []byte) error { + if len(data) <= 2 { return fmt.Errorf("too short: %w", ErrBadJSON) } - id, err := New(string(data[1:len(data)-1])) // Strip quotes - if (err == nil) { - *i = id; + id, err := New(string(data[1 : len(data)-1])) // Strip quotes + if err == nil { + *i = id } - return err; + return err } func (i ID) MarshalText() ([]byte, error) { diff --git a/server/server.go b/server/server.go index ed6d669..1aa0672 100644 --- a/server/server.go +++ b/server/server.go @@ -11,10 +11,6 @@ import ( "github.com/gorilla/securecookie" "github.com/sentriz/gormstore" - "go.senan.xyz/gonic/server/assets" - "go.senan.xyz/gonic/server/ctrladmin" - "go.senan.xyz/gonic/server/ctrlbase" - "go.senan.xyz/gonic/server/ctrlsubsonic" "go.senan.xyz/gonic/db" "go.senan.xyz/gonic/jukebox" "go.senan.xyz/gonic/podcasts" @@ -23,6 +19,10 @@ import ( "go.senan.xyz/gonic/scrobble" "go.senan.xyz/gonic/scrobble/lastfm" "go.senan.xyz/gonic/scrobble/listenbrainz" + "go.senan.xyz/gonic/server/assets" + "go.senan.xyz/gonic/server/ctrladmin" + "go.senan.xyz/gonic/server/ctrlbase" + "go.senan.xyz/gonic/server/ctrlsubsonic" "go.senan.xyz/gonic/transcode" ) @@ -298,12 +298,12 @@ type ( func (s *Server) StartHTTP(listenAddr string, tlsCert string, tlsKey string) (FuncExecute, FuncInterrupt) { list := &http.Server{ - Addr: listenAddr, - Handler: s.router, - ReadTimeout: 5 * time.Second, - ReadHeaderTimeout: 5 * time.Second, - WriteTimeout: 80 * time.Second, - IdleTimeout: 60 * time.Second, + Addr: listenAddr, + Handler: s.router, + ReadTimeout: 5 * time.Second, + ReadHeaderTimeout: 5 * time.Second, + WriteTimeout: 80 * time.Second, + IdleTimeout: 60 * time.Second, } return func() error { log.Print("starting job 'http'\n")