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.
educoder/app/jobs/teacher_invite_join_course_...

24 lines
882 B

# 老师邀请用户加入课堂 消息通知
class TeacherInviteJoinCourseNotifyJob < ApplicationJob
queue_as :notify
def perform(inviter_id, course_id, role, user_ids)
inviter = User.find_by(id: inviter_id)
course = Course.find_by(id: course_id)
return if inviter.blank? || course.blank?
attrs = %i[user_id trigger_user_id container_id container_type belong_container_id
belong_container_type tiding_type extra created_at updated_at]
same_attrs = {
trigger_user_id: inviter.id, container_id: course.id, container_type: 'TeacherJoinCourse',
belong_container_id: course.id, belong_container_type: 'Course', tiding_type: 'System', extra: role
}
Tiding.bulk_insert(*attrs) do |worker|
user_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end