Add owner_id to playlist

This commit is contained in:
Deluan
2021-10-29 22:55:28 -04:00
committed by Deluan Quintão
parent 84bbcdbfc2
commit 133fed344f
38 changed files with 173 additions and 100 deletions
+3 -3
View File
@@ -64,12 +64,12 @@ func (e subError) Error() string {
return msg
}
func getUser(ctx context.Context) string {
func getUser(ctx context.Context) model.User {
user, ok := request.UserFrom(ctx)
if ok {
return user.UserName
return user
}
return ""
return model.User{}
}
func toArtists(ctx context.Context, artists model.Artists) []responses.Artist {
+4 -6
View File
@@ -74,14 +74,12 @@ func (c *PlaylistsController) create(ctx context.Context, playlistId, name strin
if err != nil {
return err
}
if owner != pls.Owner {
if owner.ID != pls.OwnerID {
return model.ErrNotAuthorized
}
} else {
pls = &model.Playlist{
Name: name,
Owner: owner,
}
pls = &model.Playlist{Name: name}
pls.OwnerID = owner.ID
}
pls.Tracks = nil
pls.AddTracks(ids)
@@ -178,7 +176,7 @@ func (c *PlaylistsController) buildPlaylist(p model.Playlist) *responses.Playlis
pls.Name = p.Name
pls.Comment = p.Comment
pls.SongCount = p.SongCount
pls.Owner = p.Owner
pls.Owner = p.OwnerName
pls.Duration = int(p.Duration)
pls.Public = p.Public
pls.Created = p.CreatedAt