topics notification
This commit is contained in:
parent
4dc1709436
commit
8904573da1
@ -12,32 +12,34 @@ class ForumMessage < ActiveRecord::Base
|
||||
|
||||
|
||||
after_create do
|
||||
topic = ForumTopic.find(self.forum_topic_id)
|
||||
|
||||
user_to_notify = []
|
||||
|
||||
ForumUser.where(:new_messages_notifications => true).each do |forum_user|
|
||||
|
||||
user_to_notify << forum_user
|
||||
topic = self.topic
|
||||
if topic.forum_messages.count > 1
|
||||
|
||||
|
||||
user_to_notify = []
|
||||
|
||||
ForumUser.where(:new_messages_notifications => true).each do |forum_user|
|
||||
|
||||
user_to_notify << forum_user
|
||||
|
||||
|
||||
end
|
||||
FollowedTopic.where(:forum_topic_id => self.forum_topic_id).each do |followed_topic|
|
||||
user_to_notify << followed_topic.forum_user
|
||||
end
|
||||
|
||||
if self.forum_user.follow_participated_topics
|
||||
folowed_topic = forum_user.followed_topics.find_or_initialize_by_forum_topic_id(topic.id)
|
||||
folowed_topic.save
|
||||
end
|
||||
|
||||
|
||||
user_to_notify.uniq!
|
||||
|
||||
user_to_notify.each do |forum_user|
|
||||
ForumMails.message_notification(self, forum_user).deliver
|
||||
end
|
||||
end
|
||||
FollowedTopic.where(:forum_topic_id => self.forum_topic_id).each do |followed_topic|
|
||||
user_to_notify << followed_topic.forum_user
|
||||
end
|
||||
|
||||
if self.forum_user.follow_participated_topics
|
||||
folowed_topic = forum_user.followed_topics.find_or_initialize_by_forum_topic_id(topic.id)
|
||||
folowed_topic.save
|
||||
end
|
||||
|
||||
|
||||
user_to_notify.uniq!
|
||||
|
||||
user_to_notify.each do |forum_user|
|
||||
ForumMails.message_notification(self, forum_user).deliver
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user