From d70f42b4137d51b8c46d0d71052bb3e134868a76 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 23 May 2016 15:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=AF=BE=E7=A8=8B=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=B6=88=E6=81=AF=E5=BC=82=E6=AD=A5=E5=8F=91=E9=80=81?= =?UTF-8?q?=EF=BC=88=E6=B5=8B=E8=AF=95=E7=89=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/news.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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后删除对应的资源