From 168a47fabb7b8bc2a29d6f3f1b011124d333ce3d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 12 Sep 2016 17:34:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=80=9A=E7=9F=A5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=A2=AB=E5=88=A0=E9=99=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 13 +++++++++++++ app/models/news.rb | 22 +++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 190c3852b..33ff2a248 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -212,6 +213,18 @@ class NewsController < ApplicationController @news.safe_attributes = params[:news] @news.save_attachments(params[:attachments]) if @news.save + @course.members.each do |m| + if m.user_id != User.current.id + #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{@news.course_id}").count + if count == 0 + ws = WechatService.new + content = @news.title + ws.class_notice m.user_id, "course_notice", @news.id, "#{l(:label_new_notice_template)}", @news.course.name, @news.author.show_name, format_time(@news.created_on), content, "点击查看通知详情" + end + end + end + if params[:asset_id] ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS diff --git a/app/models/news.rb b/app/models/news.rb index cd7156cca..0e83a39f8 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -167,17 +167,17 @@ 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.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_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 = self.title - ws.class_notice m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.course.name, self.author.show_name, format_time(self.created_on), content, "点击查看通知详情" - end - end - end + # 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) + # 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 = self.title + # ws.class_notice m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.course.name, self.author.show_name, format_time(self.created_on), content, "点击查看通知详情" + # end + # end + # end else if !self.project.nil? self.project.members.each do |m|