diff --git a/app/models/news.rb b/app/models/news.rb index a411ccaca..7131969a4 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -163,13 +163,13 @@ class News < ActiveRecord::Base end end - #课程/项目通知 消息发送 - #消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒 + # 课程/项目通知 消息发送 + # 消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒 def act_as_system_message if self.course self.course.members.each do |m| if m.user_id != self.author_id - #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + self.delay.send_message(m.user_id, self.course_id) count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count if count == 0 ws = WechatService.new @@ -189,6 +189,10 @@ class News < ActiveRecord::Base end end + def send_message user_id, course_id + self.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course_id, :viewed => false) + end + # Time 2015-03-31 13:50:54 # Author lizanle # Description 删除news后删除对应的资源