From e59665ccb1aecf02fe4a07372b7e68f06152d127 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Mar 2020 21:11:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A7=86=E9=A2=91=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users/videos_controller.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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