@@ -58,7 +58,7 @@ def create_thread
5858 notification = "New comment thread on #{ @comment . root . title } : #{ @comment_thread . title } "
5959
6060 NewThreadFollower . where ( post : @post ) . each do |ntf |
61- unless ntf . user . same_as? ( current_user )
61+ unless ntf . user . same_as? ( current_user ) || pings . include? ( ntf . user_id )
6262 ntf . user . create_notification ( notification , helpers . comment_link ( @comment ) )
6363 end
6464 ThreadFollower . create ( user : ntf . user , comment_thread : @comment_thread )
@@ -92,9 +92,8 @@ def create
9292 . where ( 'link LIKE ?' , "#{ thread_url } %" )
9393 next if existing_notification . exists?
9494
95- title = @post . parent . nil? ? @post . title : @post . parent . title
9695 follower . user . create_notification ( "There are new comments in a followed thread '#{ @comment_thread . title } ' " \
97- "on the post '#{ title } '" ,
96+ "on the post '#{ @comment . root . title } '" ,
9897 helpers . comment_link ( @comment ) )
9998 end
10099 else
@@ -473,16 +472,15 @@ def restrict_thread_response(thread, status)
473472
474473 # @param pings [Array<Integer>] list of pinged user ids
475474 def apply_pings ( pings )
475+ context = @comment_thread . comments . first . same_as? ( @comment ) ? 'new' : 'comment in the'
476+ notification_text =
477+ "You were mentioned in a #{ context } thread '#{ @comment_thread . title } ' on the post '#{ @comment . root . title } '"
478+
476479 pings . each do |p |
477480 user = User . where ( id : p ) . first
478481 next if user . nil?
479482
480- next if user . same_as? ( @comment . post . user )
481-
482- title = @post . parent . nil? ? @post . title : @post . parent . title
483- user . create_notification ( "You were mentioned in a comment in the thread '#{ @comment_thread . title } ' " \
484- "on the post '#{ title } '" ,
485- helpers . comment_link ( @comment ) )
483+ user . create_notification ( notification_text , helpers . comment_link ( @comment ) )
486484 end
487485 end
488486
0 commit comments