diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7d970c762..cda3ce53c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3238,6 +3238,7 @@ def strip_html(text,len=0,endss="...") ss = "" if text.length>0 ss=text.gsub(/<\/?.*?>/, '').strip + ss = ss.gsub(/ /, ' ') if len > 0 && ss.length > len ss = ss[0, len] + endss diff --git a/app/models/journal.rb b/app/models/journal.rb index 02086fa62..eeaa17dd6 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -239,8 +239,10 @@ class Journal < ActiveRecord::Base #缺陷回复微信模板消息 def issue_wechat_message - ws = WechatService.new - content = strip_html self.notes.html_safe, 200 - ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + if !self.notes.nil? && self.notes.gsub(' ','') != '' + ws = WechatService.new + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + end end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 68b747ab9..d0113744c 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -259,19 +259,26 @@ class JournalsForMessage < ActiveRecord::Base if self.m_parent_id.nil? if self.user_id != self.jour.user_id self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.course.id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count + if count == 0 + ws = WechatService.new + #content = truncate(strip_tags(self.notes.to_s), length: 200) + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + end end else if self.user_id != self.parent.user_id self.course_messages << CourseMessage.new(:user_id => self.parent.user_id,:course_id => self.jour.course.id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.parent.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count + if count == 0 + ws = WechatService.new + #content = truncate(strip_tags(self.notes.to_s), length: 200) + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.parent.user_id, "homework", self.jour_id, "#{l(:label_new_second_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + end end end - count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count - if count == 0 - ws = WechatService.new - #content = truncate(strip_tags(self.notes.to_s), length: 200) - content = strip_html self.notes.html_safe, 200 - ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content - end end end diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index d46c45593..d4fbeb234 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -395,9 +395,9 @@