From b3776efc72cd5aaab7018b8782da046fd0bf0f16 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Thu, 11 Jul 2019 12:59:32 +0800 Subject: [PATCH] Add change-tags to MessagePoster Add the ability to add change tags to talk page messages submitted via wikitext MessagePoster, via a new 'options' parameter to the post() function. Bug: T227161 Change-Id: I80c401c56e231b34822791faffebc84d4933b922 --- .../WikitextMessagePoster.js | 15 ++++++++++++--- .../src/mediawiki.messagePoster/MessagePoster.js | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/resources/src/mediawiki.messagePoster.wikitext/WikitextMessagePoster.js b/resources/src/mediawiki.messagePoster.wikitext/WikitextMessagePoster.js index 20621d2fa4..fd65e8a5d9 100644 --- a/resources/src/mediawiki.messagePoster.wikitext/WikitextMessagePoster.js +++ b/resources/src/mediawiki.messagePoster.wikitext/WikitextMessagePoster.js @@ -21,20 +21,29 @@ /** * @inheritdoc + * @param {string} subject Section title. + * @param {string} body Message body, as wikitext. Signature code will automatically be added unless the message already contains the string ~~~. + * @param {Object} [options] Message options: + * @param {string} [options.tags] [Change tags](https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tags) to add to the message's revision, pipe-separated. */ - WikitextMessagePoster.prototype.post = function ( subject, body ) { - mw.messagePoster.WikitextMessagePoster.parent.prototype.post.call( this, subject, body ); + WikitextMessagePoster.prototype.post = function ( subject, body, options ) { + var additionalParams; + mw.messagePoster.WikitextMessagePoster.parent.prototype.post.call( this, subject, body, options ); // Add signature if needed if ( body.indexOf( '~~~' ) === -1 ) { body += '\n\n~~~~'; } + additionalParams = { redirect: true }; + if ( options.tags !== undefined ) { + additionalParams.tags = options.tags; + } return this.api.newSection( this.title, subject, body, - { redirect: true } + additionalParams ).then( function ( resp, jqXHR ) { if ( resp.edit.result === 'Success' ) { return $.Deferred().resolve( resp, jqXHR ); diff --git a/resources/src/mediawiki.messagePoster/MessagePoster.js b/resources/src/mediawiki.messagePoster/MessagePoster.js index 7f217e938c..14c971dce1 100644 --- a/resources/src/mediawiki.messagePoster/MessagePoster.js +++ b/resources/src/mediawiki.messagePoster/MessagePoster.js @@ -22,6 +22,7 @@ * @param {string} body Body, as wikitext. Signature code will automatically be added * by MessagePosters that require one, unless the message already contains the string * ~~~. + * @param {Object} [options] Message options. See MessagePoster implementations for details. * @return {jQuery.Promise} Promise completing when the post succeeds or fails. * For failure, will be rejected with three arguments: * -- 2.20.1