课堂视频发布后给学生发送消息

schedule_job
anke1460 5 years ago
parent 0cb8fe37ac
commit 763791f936

@ -12,7 +12,7 @@ class TidingsController < ApplicationController
case params[:type]
when 'notice' then 'System'
when 'apply' then 'Apply'
when 'course' then %w(HomeworkCommon Exercise Poll GraduationTask GraduationTopic)
when 'course' then %w(HomeworkCommon Exercise Poll GraduationTask GraduationTopic PublishCourseVideo)
when 'project' then 'Project'
when 'interaction' then %w(Comment Mentioned Praise Fan)
when 'project_package' then %w(Created Destroyed Bidding BiddingEnd BiddingWon BiddingLost)
@ -25,6 +25,8 @@ class TidingsController < ApplicationController
tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package'
@count = tidings.count
@tidings = paginate(tidings.order(created_at: :desc), per_page: 10)
end

@ -403,6 +403,8 @@ module TidingDecorator
def video_content
if tiding_type == 'System'
I18n.t(locale_format(tiding_type, status), reason: extra) % container.try(:title)
elsif tiding_type == 'PublishCourseVideo'
I18n.t(locale_format(tiding_type)) % [belong_container&.name]
else
I18n.t(locale_format(tiding_type)) % [container.try(:title) || extra]
end
@ -419,4 +421,5 @@ module TidingDecorator
def hack_content
I18n.t(locale_format(parent_container_type)) % (container&.name || extra)
end
end

@ -0,0 +1,25 @@
class CourseVideoUploadedJob < ApplicationJob
queue_as :notify
def perform(video_id)
video = Video.select("id, user_id").find_by(id: video_id)
course_ids = video&.course_videos&.pluck(:course_id)
return unless course_ids.present?
course_members = CourseMember.where(course_id: course_ids, role: 'STUDENT').select("user_id, course_id")
Tiding.bulk_insert do |worker|
course_members.find_each do |m|
worker.add(
user_id: m.user_id,
tiding_type: 'PublishCourseVideo',
trigger_user_id: video.user_id,
container_id: video.id,
container_type: 'Video',
belong_container_type: 'Course',
belong_container_id: m.course_id)
end
end
end
end

@ -52,6 +52,7 @@ class Videos::BatchPublishService < ApplicationService
if param[:course_id].present?
video.video_applies.create!(status: "agreed")
CourseVideoUploadedJob.perform_later(video.id) if video.transcoded
else
video.video_applies.create!
end

@ -22,6 +22,7 @@ class Videos::DispatchCallbackService < ApplicationService
when 'StreamTranscodeComplete' then # 转码完成
#return if video.play_url.present?
video.update!(play_url: params['FileUrl'], transcoded: true)
CourseVideoUploadedJob.perform_later(video.id) if video.video_applies.exists?(status: 'agreed') #通过的情况基本上是课堂视频
when 'DeleteMediaComplete' #完成云端视频删除
video.update_column(:delete_state, Video::FINISH_DELETE)
end

@ -236,6 +236,7 @@
System:
1_end: "你提交的发布视频申请:%s审核已通过"
2_end: "你提交的发布视频申请:%s审核未通过<br/><span>原因:%{reason}</span>"
PublishCourseVideo_end: "在课堂 %s 发布了视频,观看视频可以增加平时分哦~"
PublicCourseStart_end: "你报名参与的开放课程:%s将于%s正式开课"
SubjectStartCourse_end: "您创建的开放课程:%s 已达到开课人数要求。您可以在24小时内自主开设新一期课程。如果超过24小时未开课平台将自动开课并复制您上一期的课程内容。"
LiveLink_end: "%s 直播将于30分钟后开始"

Loading…
Cancel
Save