Index: trunk/extensions/CodeReview/modules/ext.codereview.linecomment.js |
— | — | @@ -68,9 +68,15 @@ |
69 | 69 | dataType: 'json', |
70 | 70 | type: 'POST', |
71 | 71 | success: function( data ) { |
72 | | - // FIXME |
73 | | - console.log( data.coderevisionupdate ); |
74 | | - //data.coderevisionupdate.commentid; |
| 72 | + // our API return usage error as a success! |
| 73 | + if( data.error !== undefined ) { |
| 74 | + console.log( lineComment.find( 'input' ) ); |
| 75 | + lineComment.find( 'input' ).after( |
| 76 | + $('<span class="errorbox"></span>') |
| 77 | + .text( data.error.info ) |
| 78 | + ); |
| 79 | + return; |
| 80 | + } |
75 | 81 | |
76 | 82 | var text = data.coderevisionupdate.HTML |
77 | 83 | lineComment.fadeOut( 200 ).remove(); |
Index: trunk/extensions/CodeReview/api/ApiRevisionUpdate.php |
— | — | @@ -32,6 +32,11 @@ |
33 | 33 | |
34 | 34 | $params = $this->extractRequestParams(); |
35 | 35 | |
| 36 | + if( $params['comment'] |
| 37 | + && !$wgUser->isAllowed( 'codereview-post-comment' ) ) { |
| 38 | + $this->dieUsage( 'You do not have permission to post comment', 'permissiondenied' ); |
| 39 | + } |
| 40 | + |
36 | 41 | $repo = CodeRepository::newFromName( $params['repo'] ); |
37 | 42 | if ( !$repo ) { |
38 | 43 | $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); |