Better implementation of Bookmarks, using its own table
This commit is contained in:
@@ -21,8 +21,8 @@ func NewBookmarksController(ds model.DataStore) *BookmarksController {
|
||||
func (c *BookmarksController) GetBookmarks(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||
user, _ := request.UserFrom(r.Context())
|
||||
|
||||
repo := c.ds.PlayQueue(r.Context())
|
||||
bmks, err := repo.GetBookmarks(user.ID)
|
||||
repo := c.ds.MediaFile(r.Context())
|
||||
bmks, err := repo.GetBookmarks()
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
@@ -52,10 +52,8 @@ func (c *BookmarksController) CreateBookmark(w http.ResponseWriter, r *http.Requ
|
||||
comment := utils.ParamString(r, "comment")
|
||||
position := utils.ParamInt64(r, "position", 0)
|
||||
|
||||
user, _ := request.UserFrom(r.Context())
|
||||
|
||||
repo := c.ds.PlayQueue(r.Context())
|
||||
err = repo.AddBookmark(user.ID, id, comment, position)
|
||||
repo := c.ds.MediaFile(r.Context())
|
||||
err = repo.AddBookmark(id, comment, position)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
@@ -68,10 +66,8 @@ func (c *BookmarksController) DeleteBookmark(w http.ResponseWriter, r *http.Requ
|
||||
return nil, err
|
||||
}
|
||||
|
||||
user, _ := request.UserFrom(r.Context())
|
||||
|
||||
repo := c.ds.PlayQueue(r.Context())
|
||||
err = repo.DeleteBookmark(user.ID, id)
|
||||
repo := c.ds.MediaFile(r.Context())
|
||||
err = repo.DeleteBookmark(id)
|
||||
if err != nil {
|
||||
return nil, NewError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ func ToChild(ctx context.Context, entry engine.Entry) responses.Child {
|
||||
child.TranscodedSuffix = format
|
||||
child.TranscodedContentType = mime.TypeByExtension("." + format)
|
||||
}
|
||||
child.BookmarkPosition = entry.BookmarkPosition
|
||||
return child
|
||||
}
|
||||
|
||||
@@ -203,6 +204,7 @@ func ChildFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child
|
||||
child.TranscodedSuffix = format
|
||||
child.TranscodedContentType = mime.TypeByExtension("." + format)
|
||||
}
|
||||
child.BookmarkPosition = mf.BookmarkPosition
|
||||
return child
|
||||
}
|
||||
|
||||
|
||||
@@ -117,9 +117,9 @@ type Child struct {
|
||||
UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"`
|
||||
SongCount int `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
|
||||
IsVideo bool `xml:"isVideo,attr" json:"isVideo"`
|
||||
BookmarkPosition int64 `xml:"bookmarkPosition,attr,omitempty" json:"bookmarkPosition,omitempty"`
|
||||
/*
|
||||
<xs:attribute name="averageRating" type="sub:AverageRating" use="optional"/> <!-- Added in 1.6.0 -->
|
||||
<xs:attribute name="bookmarkPosition" type="xs:long" use="optional"/> <!-- In millis. Added in 1.10.1 -->
|
||||
<xs:attribute name="originalWidth" type="xs:int" use="optional"/> <!-- Added in 1.13.0 -->
|
||||
<xs:attribute name="originalHeight" type="xs:int" use="optional"/> <!-- Added in 1.13.0 -->
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user