You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
819 B
31 lines
819 B
class Videos::DispatchCallbackService < ApplicationService
|
|
attr_reader :video, :params
|
|
|
|
def initialize(params)
|
|
@video = Video.find_by(uuid: params[:VideoId])
|
|
@params = params
|
|
end
|
|
|
|
def call
|
|
return if video.blank?
|
|
|
|
# TODO:: 拆分事件分发
|
|
case params['EventType']
|
|
when 'FileUploadComplete' then # 视频上传完成
|
|
video.file_url = params['FileUrl']
|
|
video.filesize = params['Size']
|
|
video.upload_success
|
|
video.save!
|
|
when 'SnapshotComplete' then # 封面截图完成
|
|
return if video.cover_url.present?
|
|
|
|
video.update!(cover_url: params['CoverUrl'])
|
|
when 'TranscodeComplete' then # 转码完成
|
|
return if video.play_url.present?
|
|
video.update!(play_url: params['FileUrl'])
|
|
end
|
|
|
|
rescue => ex
|
|
Util.logger_error(ex)
|
|
end
|
|
end |