[refs #265] fixed comment to commit feed

This commit is contained in:
Alexander Machehin 2012-03-14 20:33:16 +06:00
parent 1ff3cf5662
commit d9c3f9ddc8
2 changed files with 7 additions and 5 deletions

View File

@ -51,7 +51,12 @@ class ActivityFeedObserver < ActiveRecord::Observer
subscribes = Subscribe.comment_subscribes(record).where(:status => true)
subscribes.each do |subscribe|
next if record.own_comment?(subscribe.user)
UserMailer.delay.new_comment_notification(record, subscribe.user) if subscribe.user.notifier.can_notify
if subscribe.user.notifier.can_notify and
( (subscribe.project.owner?(subscribe.user) && subscribe.user.notifier.new_comment_commit_repo_owner) or
(subscribe.user.commentor?(record.commentable) && subscribe.user.notifier.new_comment_commit_commentor) or
(subscribe.user.committer?(record.commentable) && subscribe.user.notifier.new_comment_commit_owner) )
UserMailer.delay.new_comment_notification(record, subscribe.user)
end
ActivityFeed.create(
:user => subscribe.user,
:kind => 'new_comment_commit_notification',

View File

@ -21,10 +21,7 @@ class Subscribe < ActiveRecord::Base
def self.subscribed_to_commit?(project, user, commit)
subscribe = user.subscribes.where(:subscribeable_id => commit.id.hex, :subscribeable_type => commit.class.name, :project_id => project.id).first
return subscribe.subscribed? if subscribe # return status if already subscribe present
# return status by settings
(project.owner?(user) && user.notifier.new_comment_commit_repo_owner) or
(user.commentor?(commit) && user.notifier.new_comment_commit_commentor) or
(user.committer?(commit) && user.notifier.new_comment_commit_owner)
true
end
def self.subscribe_to_commit(options)