Index: trunk/extensions/CodeReview/backend/CodeRevision.php |
— | — | @@ -301,15 +301,23 @@ |
302 | 302 | $dbw->insert( 'code_relations', $data, __METHOD__, array( 'IGNORE' ) ); |
303 | 303 | } |
304 | 304 | |
305 | | - global $wgEnableEmail; |
| 305 | + global $wgEnableEmail, $wgUser; |
306 | 306 | // Email the authors of revisions that this follows up on |
307 | 307 | if ( $wgEnableEmail && $newRevision && count( $affectedRevs ) > 0 ) { |
308 | 308 | // Get committer wiki user name, or repo name at least |
309 | | - $user = $this->mRepo->authorWikiUser( $this->mAuthor ); |
| 309 | + $user = $this->getWikiUser(); |
310 | 310 | $committer = $user ? $user->getName() : htmlspecialchars( $this->mAuthor ); |
311 | 311 | // Get the authors of these revisions |
312 | 312 | $res = $dbw->select( 'code_rev', |
313 | | - array( 'cr_author', 'cr_id' ), |
| 313 | + array( |
| 314 | + 'cr_repo_id', |
| 315 | + 'cr_id', |
| 316 | + 'cr_author', |
| 317 | + 'cr_timestamp', |
| 318 | + 'cr_message', |
| 319 | + 'cr_status', |
| 320 | + 'cr_path', |
| 321 | + ), |
314 | 322 | array( |
315 | 323 | 'cr_repo_id' => $this->mRepoId, |
316 | 324 | 'cr_id' => $affectedRevs, |
— | — | @@ -326,18 +334,30 @@ |
327 | 335 | $url = $title->getFullUrl(); |
328 | 336 | |
329 | 337 | foreach ( $res as $row ) { |
330 | | - $user = $this->mRepo->authorWikiUser( $row->cr_author ); |
331 | | - // User must exist on wiki and have a valid email addy |
332 | | - if ( !$user || !$user->canReceiveEmail() ) { |
333 | | - continue; |
| 338 | + $revision = CodeRevision::newFromRow( $row ); |
| 339 | + $users = $revision->getCommentingUsers(); |
| 340 | + |
| 341 | + //Add the revision author if they have not already been added as a commentor (they won't want dupe emails!) |
| 342 | + if ( !array_key_exists( $user->getId(), $users ) { |
| 343 | + $users[$user->getId()] = $user; |
334 | 344 | } |
335 | 345 | |
336 | | - // Send message in receiver's language |
337 | | - $lang = array( 'language' => $user->getOption( 'language' ) ); |
338 | | - $user->sendMail( |
339 | | - wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(), $this->getIdString( $row->cr_id ) ), |
340 | | - wfMsgExt( 'codereview-email-body2', $lang, $committer, $this->getIdStringUnique( $row->cr_id ), $url, $this->mMessage ) |
341 | | - ); |
| 346 | + //Notify commenters and revision author of followup revision |
| 347 | + foreach ( $users as $userId => $user ) { |
| 348 | + // No sense in notifying the author if they are a commenter on the target rev |
| 349 | + if ( $wgUser->getId() == $user->getId() ) { |
| 350 | + continue; |
| 351 | + } |
| 352 | + |
| 353 | + if ( $user->canReceiveEmail() ) { |
| 354 | + // Send message in receiver's language |
| 355 | + $lang = array( 'language' => $user->getOption( 'language' ) ); |
| 356 | + $user->sendMail( |
| 357 | + wfMsgExt( 'codereview-email-subj2', $lang, $this->mRepo->getName(), $this->getIdString( $row->cr_id ) ), |
| 358 | + wfMsgExt( 'codereview-email-body2', $lang, $committer, $this->getIdStringUnique( $row->cr_id ), $url, $this->mMessage ) |
| 359 | + ); |
| 360 | + } |
| 361 | + } |
342 | 362 | } |
343 | 363 | } |
344 | 364 | $dbw->commit(); |