Favorite and playlist models
This commit is contained in:
@@ -43,6 +43,36 @@ class UserController < ApplicationController
|
||||
render :json => @res
|
||||
end
|
||||
|
||||
def fav
|
||||
@res = {status: 'fail'}
|
||||
check = check_auth(params)
|
||||
|
||||
if check == true
|
||||
fav = Favorite.new
|
||||
if not params[:artist].nil?
|
||||
artist = Artist.find(params[:artist]);
|
||||
unless artist.nil?
|
||||
fav.artist_id = artist.id
|
||||
res[:status] = 'added'
|
||||
end
|
||||
elsif not params[:album].nil?
|
||||
album = Album.find(params[:album]);
|
||||
unless album.nil?
|
||||
fav.album_id = album.id
|
||||
res[:status] = 'added'
|
||||
end
|
||||
elsif not params[:track].nil?
|
||||
track = Track.find(params[:track]);
|
||||
unless track.nil?
|
||||
fav.track_id = track.id
|
||||
res[:status] = 'added'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render :json => @res
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_auth params
|
||||
|
||||
Reference in New Issue
Block a user