jenkins-bot has submitted this change and it was merged.
Change subject: Use mw.api.postWithToken
......................................................................
Use mw.api.postWithToken
Remove explicit dependency to 'user.tokens' and 'mediawiki.user',
because they are not called explicitly anymore.
Depends-On:I7a0fec3c1ef2c7881d4c
Change-Id: I25a8a8832fab131e026fb062e7c4968193260b07
---
M UiFeedback.php
M resources/ext.uiFeedback.js
2 files changed, 15 insertions(+), 16 deletions(-)
Approvals:
TheDJ: Looks good to me, approved
jenkins-bot: Verified
diff --git a/UiFeedback.php b/UiFeedback.php
index 2497d62..ee31e06 100644
--- a/UiFeedback.php
+++ b/UiFeedback.php
@@ -46,14 +46,12 @@
'dependencies' => array(
'user.groups',
'user.options',
- 'user.tokens',
'jquery.cookie',
'jquery.ui.draggable',
'jquery.client',
'mediawiki.api',
- 'mediawiki.user',
'mediawiki.util',
),
'messages' => array(
diff --git a/resources/ext.uiFeedback.js b/resources/ext.uiFeedback.js
index 41980ee..556354c 100644
--- a/resources/ext.uiFeedback.js
+++ b/resources/ext.uiFeedback.js
@@ -733,23 +733,24 @@
mw.log( 'API
result:', data );
/* sending the
image to the upload api */
/* thanks to
danwe_wmde for pointing me at the upload-wizard extension */
- var xhr = new
XMLHttpRequest();
-
xhr.addEventListener( 'load', function ( e ) {
+
+
api.postWithToken( 'csrf',
+ {
+ action:
'upload',
+ format:
'json',
+
filename: filename,
+ file:
canvasBytes
+ }, {
+
contentType: 'multipart/form-data'
+ } )
+ .done( function
() {
show_notification( mw.message( 'ui-feedback-notify-upload-sent',
mw.util.getUrl( 'Special:UiFeedback' ) ), 5000, 'purple' );
resetForm();
- }, false );
-
xhr.addEventListener( 'error', function ( e ) {
-
show_notification( mw.message( 'ui-feedback-notify-upload-fail' ), 5000,
'purple' );
- }, false );
- var formData =
new FormData();
-
formData.append( 'action', 'upload' );
-
formData.append( 'format', 'json' );
-
formData.append( 'token', mw.user.tokens.get( 'editToken' ) );
-
formData.append( 'filename', filename );
-
formData.append( 'file', canvasBytes );
- xhr.open(
'POST', mw.util.wikiScript( 'api' ), true );
- xhr.send(
formData );
+ } )
+ .fail( function
() {
+
show_notification( mw.message( 'ui-feedback-notify-upload-fail' ), 5000,
'purple' );
+ } );
show_notification( mw.message( 'ui-feedback-notify-upload-progress' ), 5000,
'purple' );
} ).fail( function (
error ) {
mw.log( 'API
failed :(', error );
--
To view, visit https://gerrit.wikimedia.org/r/133059
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I25a8a8832fab131e026fb062e7c4968193260b07
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/UIFeedback
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Fomafix
Gerrit-Reviewer: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Lbenedix <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits