From ac713a7136a5997736517108d74d154c412961a1 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Jan 2017 14:13:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E5=8F=91=E5=B8=83=E7=95=99?= =?UTF-8?q?=E8=A8=80=E3=80=81=E5=9B=9E=E5=A4=8D=E7=95=99=E8=A8=80=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 38c323798..933324e2b 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -78,7 +78,7 @@ class JournalsForMessage < ActiveRecord::Base validates :notes, presence: true, if: :is_homework_jour? after_create :act_as_course_activity, :act_as_course_message, :act_as_contest_activity, act_as_at_message(:notes, :user_id), :act_as_user_feedback_message, - :act_as_principal_activity + :act_as_principal_activity, :act_as_contest_message # after_create :reset_counters! #after_update :update_activity # after_destroy :reset_counters! @@ -325,6 +325,23 @@ class JournalsForMessage < ActiveRecord::Base end end + # 竞赛留言消息通知 + def act_as_contest_message + # 主留言 + if self.jour_type == 'Contest' + if self.m_parent_id.nil? + receivers = self.jour.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager") && cm.user_id != self.user_id} + receivers.each do |r| + self.contest_messages << ContestMessage.new(:user_id => r.user_id, :contest_id => self.jour.id, :viewed => false) + end + else # 留言回复 + if self.user_id != self.reply_id # 添加我回复的那个人 + self.contest_messages << ContestMessage.new(:user_id => self.reply_id, :contest_id => self.jour.id, :viewed => false) + end + end + end + end + # 课程成员得分(活跃度) def act_as_student_score if self.jour_type == "Course"