delayjob封装
This commit is contained in:
parent
d70f42b413
commit
a3abf09841
|
@ -167,17 +167,7 @@ class News < ActiveRecord::Base
|
|||
# 消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒
|
||||
def act_as_system_message
|
||||
if self.course
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
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
|
||||
content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200
|
||||
ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", content, format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.delay.send_message
|
||||
else
|
||||
if !self.project.nil?
|
||||
self.project.members.each do |m|
|
||||
|
@ -189,8 +179,19 @@ 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)
|
||||
def send_message
|
||||
self.course.members.each do |m|
|
||||
if m.user_id != self.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => user_id, :course_id => container_id, :viewed => false)
|
||||
# 微信相关
|
||||
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
|
||||
content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200
|
||||
ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", content, format_time(self.created_on)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
|
|
Loading…
Reference in New Issue