jenkins-bot has submitted this change and it was merged.

Change subject: Use mw.Api.postWithToken to automatically re-try badtoken errors
......................................................................


Use mw.Api.postWithToken to automatically re-try badtoken errors

Bug: T101664
Change-Id: I93188099e24102b47384c08113e8dbd26dac8df1
---
M modules/overlay/ext.echo.overlay.js
M modules/special/ext.echo.special.js
M tests/qunit/overlay/test_ext.echo.overlay.js
3 files changed, 5 insertions(+), 4 deletions(-)

Approvals:
  Alex Monk: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/overlay/ext.echo.overlay.js 
b/modules/overlay/ext.echo.overlay.js
index 61c3e59..76de9a5 100644
--- a/modules/overlay/ext.echo.overlay.js
+++ b/modules/overlay/ext.echo.overlay.js
@@ -82,7 +82,6 @@
                        if ( this.unread.length ) {
                                data = {
                                        action: 'echomarkread',
-                                       token: mw.user.tokens.get( 'editToken' 
),
                                        uselang: 'user'
                                };
                                if ( id ) {
@@ -92,7 +91,7 @@
                                        data.sections = this.name;
                                }
 
-                               return this.api.post( data ).then( function ( 
result ) {
+                               return this.api.postWithToken( 'edit', data 
).then( function ( result ) {
                                        return result.query.echomarkread;
                                } ).done( function ( result ) {
                                        // reset internal state of unread 
messages
diff --git a/modules/special/ext.echo.special.js 
b/modules/special/ext.echo.special.js
index 1d5726e..74c4502 100644
--- a/modules/special/ext.echo.special.js
+++ b/modules/special/ext.echo.special.js
@@ -133,10 +133,9 @@
                                api = new mw.Api(),
                                that = this;
 
-                       api.post( {
+                       api.postWithToken( 'edit', {
                                action: 'echomarkread',
                                list: unread.join( '|' ),
-                               token: mw.user.tokens.get( 'editToken' ),
                                uselang: 'user'
                        } ).done( function ( result ) {
                                // update the badge if the link is enabled
diff --git a/tests/qunit/overlay/test_ext.echo.overlay.js 
b/tests/qunit/overlay/test_ext.echo.overlay.js
index 3d9acd1..52b9241 100644
--- a/tests/qunit/overlay/test_ext.echo.overlay.js
+++ b/tests/qunit/overlay/test_ext.echo.overlay.js
@@ -27,6 +27,9 @@
 
                                        return $.Deferred().resolve( data );
                                },
+                               postWithToken: function ( type, data ) {
+                                       return this.post( data );
+                               },
                                get: function () {
                                        var i, id,
                                                index = [],

-- 
To view, visit https://gerrit.wikimedia.org/r/216596
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I93188099e24102b47384c08113e8dbd26dac8df1
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to