diff --git a/app/models/message.rb b/app/models/message.rb index 309291183..3b0f89ef5 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -328,17 +328,27 @@ class Message < ActiveRecord::Base def delay_message_send if self.course if self.parent_id.nil? # 发帖 - self.delay.contain_messages_message + dm = [] + self.course.members.includes(:user).each do |m| + if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 + dm << {course_message_type:'Message',course_message_id:self.id, :user_id => m.user_id, + :course_id => self.board.course_id, :viewed => false} + if dm.size >= 30 + self.delay.contain_messages_message(dm) + dm.clear + end + unless dm.empty? + self.delay.contain_messages_message(dm) + end + end + end + end end end - def contain_messages_message - self.course.members.includes(:user).each do |m| - if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 - self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) - end - end + def contain_messages_message vs + CourseMessage.create(vs) end #更新用户分数 -by zjc diff --git a/app/views/users/_my_issue_list.html.erb b/app/views/users/_my_issue_list.html.erb index 29e4c9264..d9729b5b9 100644 --- a/app/views/users/_my_issue_list.html.erb +++ b/app/views/users/_my_issue_list.html.erb @@ -50,7 +50,7 @@