This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -349,7 +349,6 @@ func migratePodcastDropUserID(tx *gorm.DB, _ MigrationContext) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
step = tx.Exec(`
|
||||
ALTER TABLE podcasts DROP COLUMN user_id;
|
||||
`)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user