diff --git a/src/modules/submissions.js b/src/modules/submissions.js index b58b0548..6f462c5e 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -1135,12 +1135,30 @@ } ); } + function checkForBlocks() { + return afchSubmission.getSubmitter().then( function ( creator ) { + return checkIfUserIsBlocked( creator ).then( function ( blockData ) { + if ( blockData !== null ) { + var date = 'infinity'; + if ( blockData.expiry !== 'infinity' ) { + var data = new Date( blockData.expiry ); + var monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; + date = data.getUTCDate() + ' ' + monthNames[ data.getUTCMonth() ] + ' ' + data.getUTCFullYear() + ' ' + data.getUTCHours() + ':' + data.getUTCMinutes() + ' UTC'; + } + var warning = 'Submitter ' + creator + ' was blocked by ' + blockData.by + ' with an expiry time of ' + date + '. Reason: ' + blockData.reason; + addWarning( warning ); + } + } ); + } ); + } + $.when( checkReferences(), checkDeletionLog(), checkReviewState(), checkLongComments(), - checkForCopyvio() + checkForCopyvio(), + checkForBlocks() ).then( function () { deferred.resolve( warnings ); } ); @@ -2025,6 +2043,30 @@ } } + function checkIfUserIsBlocked( userName ) { + return AFCH.api.get( { + action: 'query', + list: 'blocks', + bkusers: userName + } ).then( function ( data ) { + var blocks = data.query.blocks; + var blockData = null; + var currentTime = new Date().toISOString(); + + for ( var i = 0; i < blocks.length; i++ ) { + if ( blocks[ i ].expiry === 'infinity' || blocks[ i ].expiry > currentTime ) { + blockData = blocks[ i ]; + break; + } + } + + return blockData; + } ).catch( function ( err ) { + console.log( 'abort ' + err ); + return null; + } ); + } + function showCommentOptions() { loadView( 'comment', {} ); $( '#commentText' ).on( 'keyup', mw.util.debounce( 500, function () {