竞赛发布留言、回复留言的消息通知

This commit is contained in:
cxt 2017-01-18 14:13:25 +08:00
parent 8410273274
commit ac713a7136
1 changed files with 18 additions and 1 deletions

View File

@ -78,7 +78,7 @@ class JournalsForMessage < ActiveRecord::Base
validates :notes, presence: true, if: :is_homework_jour? validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_course_activity, :act_as_course_message, :act_as_contest_activity, 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_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_create :reset_counters!
#after_update :update_activity #after_update :update_activity
# after_destroy :reset_counters! # after_destroy :reset_counters!
@ -325,6 +325,23 @@ class JournalsForMessage < ActiveRecord::Base
end end
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 def act_as_student_score
if self.jour_type == "Course" if self.jour_type == "Course"