Page MenuHomePhabricator

UDP_on_comment_and_status_change3.patch

Authored By
bzimport
Nov 21 2014, 11:02 PM
Size
2 KB
Referenced Files
None
Subscribers
None

UDP_on_comment_and_status_change3.patch

Index: extensions/CodeReview/backend/CodeRevision.php
===================================================================
--- extensions/CodeReview/backend/CodeRevision.php (revision 66970)
+++ extensions/CodeReview/backend/CodeRevision.php (revision )
@@ -175,6 +175,9 @@
__METHOD__
);
}
+
+ $this->sendStatusToUDP( $status, $oldStatus );
+
return true;
}
@@ -394,6 +397,8 @@
}
}
+ $this->sendCommentToUDP( $commentId, $text, $url );
+
return $commentId;
}
@@ -767,4 +772,40 @@
return false;
}
}
+
+ protected function sendCommentToUDP( $commentId, $text, $url = null ) {
+ global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgLang, $wgUser;
+
+ if( $wgCodeReviewUDPAddress ) {
+ if( is_null( $url ) ) {
+ $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mId );
+ $title->setFragment( "#c{$commentId}" );
+ $url = $title->getFullUrl();
-}
+ }
+
+ $line = wfMsg( 'code-rev-message' ) . " \00314(" . $this->mRepo->getName() .
+ ")\003 \0037" . $this->getIdString() . "\003 \00303" . RecentChange::cleanupForIRC( $wgUser->getName() ) .
+ "\003: \00310" . RecentChange::cleanupForIRC( $wgLang->truncate( $text, 100 ) ) . "\003 " . $url;
+
+ RecentChange::sendToUDP( $line, $wgCodeReviewUDPAddress, $wgCodeReviewUDPPrefix, $wgCodeReviewUDPPort );
+ }
+ }
+
+ protected function sendStatusToUDP( $status, $oldStatus ) {
+ global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgUser;
+
+ if( $wgCodeReviewUDPAddress ) {
+ $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->getId() );
+ $url = $title->getFullUrl();
+
+ $line = wfMsg( 'code-rev-status' ) . " \00314(" . $this->mRepo->getName() .
+ ")\00303 " . RecentChange::cleanupForIRC( $wgUser->getName() ) . "\003 " .
+ /* Remove three apostrophes as they are intended for the parser */
+ str_replace( "'''", '', wfMsg( 'code-change-status', "\0037" . $this->getIdString() . "\003" ) ) .
+ ": \00315" . wfMsg( 'code-status-' . $oldStatus ) . "\003 -> \00310" .
+ wfMsg( 'code-status-' . $status ) . "\003 " . $url;
+
+ RecentChange::sendToUDP( $line, $wgCodeReviewUDPAddress, $wgCodeReviewUDPPrefix, $wgCodeReviewUDPPort );
+ }
+ }
+}
Index: extensions/CodeReview/CodeReview.php
===================================================================
--- extensions/CodeReview/CodeReview.php (revision 65248)
+++ extensions/CodeReview/CodeReview.php (revision )
@@ -163,6 +163,13 @@
*/
$wgCodeReviewDeferredPaths = array();
+/**
+ * UDP comment and status changes notification
+ */
+$wgCRUDPAddress = false;
+$wgCRUDPPort = false;
+$wgCRUDPPrefix = '';
+
# Schema changes
$wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates';

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6168
Default Alt Text
UDP_on_comment_and_status_change3.patch (2 KB)

Event Timeline