- Timestamp:
- 11/01/2015 09:19:58 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/slack/trac/comment-handler.php
r1210 r2025 30 30 function process_message() { 31 31 $lines = array_map( 'rtrim', $this->lines ); 32 32 33 33 // Trim off headers. 34 34 while ( $lines && '' !== current( $lines ) ) { … … 39 39 list( $ticket_url, $comment_id ) = explode( '#comment:', $comment_url ); 40 40 list( $trac_url, $ticket_id ) = explode( '/ticket/', $ticket_url ); 41 41 42 42 $trac = Trac::get( $trac_url ); 43 43 if ( ! $trac ) { 44 44 return false; 45 45 } 46 47 46 } elseif ( 0 === strpos( $line, 'Content-Transfer-Encoding: base64' ) ) { 47 $base64 = true; 48 48 } 49 49 } 50 50 51 52 53 51 if ( ! empty( $base64 ) ) { 52 $lines = explode( "\n", base64_decode( implode( "\n", $lines ) ) ); 53 } 54 54 55 55 // Remove empty line between headers and body. 56 56 array_shift( $lines ); 57 57 58 58 $title = ''; 59 59 while ( $lines && 0 !== strpos( current( $lines ), '------' ) ) { … … 80 80 // Remove bottom border of table. 81 81 array_shift( $lines ); 82 82 83 83 // Remove empty line if present. (It is when it's a comment without changes.) 84 84 if ( current( $lines ) === '' ) { 85 85 array_shift( $lines ); 86 86 } 87 87 88 88 // Remove Trac email footer. 89 89 while ( $lines && end( $lines ) !== '--' ) { … … 94 94 // Remove empty line before footer. 95 95 array_pop( $lines ); 96 96 97 97 preg_match( '/^(Comment|Changes) \(by (.*)\):$/', array_shift( $lines ), $matches ); 98 98 $has_changes = $matches[1] === 'Changes'; … … 101 101 // Remove blank line after 'Comment|Changes (by author):' 102 102 array_shift( $lines ); 103 103 104 104 $changes = $comment = array(); 105 105 if ( $has_changes ) { … … 108 108 } 109 109 } 110 110 111 111 // Remove blank lines (should be two if it had changes). 112 112 while ( $lines && '' === current( $lines ) ) { 113 113 array_shift( $lines ); 114 114 } 115 115 116 116 // Next line should start with 'Comment' if there is one. 117 117 if ( $has_changes && 0 === strpos( current( $lines ), 'Comment' ) ) { … … 151 151 $this->send->set_icon( $this->trac->get_icon() ); 152 152 $this->send->set_username( $this->trac->get_ticket_username() ); 153 153 154 154 $comment = $this->format_comment_for_slack(); 155 155 $main_attachment = $this->changes ? implode( "\n", $this->changes ) : $comment; … … 164 164 ); 165 165 166 // Ensure the comment uses a darker gray color, even when alone. 166 // Ensure the comment uses a darker gray color, even when alone. 167 167 if ( ! $this->changes ) { 168 168 $attachment['color'] = '#999';
Note: See TracChangeset
for help on using the changeset viewer.