This commit is contained in:
sentriz
2022-11-03 15:27:59 +00:00
parent 5c6855f671
commit 1f8de66fc0
6 changed files with 24 additions and 25 deletions

View File

@@ -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 (

View File

@@ -349,7 +349,6 @@ func migratePodcastDropUserID(tx *gorm.DB, _ MigrationContext) error {
return nil
}
step = tx.Exec(`
ALTER TABLE podcasts DROP COLUMN user_id;
`)

View File

@@ -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 {

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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"
)