diff --git a/app/controllers/users/videos_controller.rb b/app/controllers/users/videos_controller.rb index 0ae240dd7..645c25362 100644 --- a/app/controllers/users/videos_controller.rb +++ b/app/controllers/users/videos_controller.rb @@ -1,6 +1,6 @@ class Users::VideosController < Users::BaseController before_action :private_user_resources!, :check_account - before_action :require_teacher! + before_action :require_teacher!, except: [:destroy] before_action :require_auth_teacher!, except: [:index, :review] helper_method :current_video @@ -53,6 +53,19 @@ class Users::VideosController < Users::BaseController render_error(ex.message) end + def destroy + video = observed_user.videos.find_by(id: params[:video_id]) + render_forbidden unless video.user_id != observed_user.id || !current_user.admin_or_business? + return render_not_found if video.blank? + return render_error('该状态下不能删除视频') unless video.pending? + + video.destroy! + + AliyunVod::Service.delete_video([video.uuid]) rescue nil + + render_ok + end + private def current_video