From 0b21b0f5a8d03d8c811a8fb2aef68f4983f33b51 Mon Sep 17 00:00:00 2001 From: NovemLinguae Date: Tue, 16 Apr 2024 01:32:48 -0700 Subject: [PATCH] debug --- src/modules/core.js | 3 ++- src/modules/submissions.js | 24 +++++++++++++----------- src/templates/tpl-preferences.html | 1 + 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/modules/core.js b/src/modules/core.js index 69837ef5..1a369a33 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -1228,7 +1228,8 @@ logCsd: true, launchLinkPosition: 'p-cactions', logAfc: false, - noWatch: false + noWatch: false, + autoSubscribe: false }; /** diff --git a/src/modules/submissions.js b/src/modules/submissions.js index fc9bede1..96d258e5 100644 --- a/src/modules/submissions.js +++ b/src/modules/submissions.js @@ -2338,7 +2338,7 @@ message: AFCH.msg.get( 'accepted-submission', { $1: newPage, $2: data.newAssessment } ), summary: 'Notification: Your [[' + AFCH.consts.pagename + '|Articles for Creation submission]] has been accepted' - } ); + } ).then( subscribeToBottomSection( submitter ) ); } ); } @@ -2569,7 +2569,7 @@ AFCH.actions.notifyUser( submitter, { message: message, summary: 'Notification: Your [[' + AFCH.consts.pagename + '|Articles for Creation submission]] has been ' + ( isDecline ? 'declined' : 'rejected' ) - } ); + } ).then( subscribeToBottomSection( submitter ) ); } ); } ); } @@ -2619,26 +2619,25 @@ } } - // TODO: add to preferences screen, defaulting to off - // TODO: add to handleAccept, handleDecline, handleReject - // TODO: manually test - function subscribeToBottomSection( submitter ) { if ( !AFCH.prefs.autoSubscribe ) { return; } - var talkPage = 'User talk' + submitter; - + // Figure out the DiscussionTools ID of the section we want to subscribe to + var talkPage = 'User talk:' + submitter; AFCH.api.get( { action: 'discussiontoolspageinfo', format: 'json', page: talkPage, formatversion: 2 } ).then( function ( json ) { - // iterate from the bottom up, until a string beginning with "h-" is found. + debugger; + var transcludedFrom = json.discussiontoolspageinfo.transcludedfrom; + transcludedFrom = Object.keys( transcludedFrom ); var commentName = ''; + // Iterate from the bottom up, until a string beginning with "h-" is found. This is our user talk section that we just created. for ( var i = transcludedFrom.length; i > 0; i-- ) { var value = transcludedFrom[ i - 1 ]; if ( value.indexOf( 'h-' ) === 0 ) { @@ -2647,7 +2646,7 @@ } } - // Note: if the program code gets the commentName wrong, subscribing is likely to fail silently. That is, it will still subscribe to a section, but because the section does not exist, the AFC reviewer will not receive notifications. You can troubleshoot at https://en.wikipedia.org/wiki/Special:TopicSubscriptions + // Subscribe to that DiscussionTools section ID AFCH.api.post( { action: 'discussiontoolssubscribe', format: 'json', @@ -2655,6 +2654,9 @@ page: talkPage, commentname: commentName, subscribe: true + } ).then( function ( json ) { + debugger; + console.log( json ); } ); } ); } @@ -2780,7 +2782,7 @@ message: AFCH.msg.get( 'g13-submission', { $1: AFCH.consts.pagename } ), summary: 'Notification: [[WP:G13|G13]] speedy deletion nomination of [[' + AFCH.consts.pagename + ']]' - } ); + } ).then( subscribeToBottomSection( submitter ) ); } ); // And finally log the CSD nomination once all users have been notified diff --git a/src/templates/tpl-preferences.html b/src/templates/tpl-preferences.html index a82fa8f5..bdd5aaed 100644 --- a/src/templates/tpl-preferences.html +++ b/src/templates/tpl-preferences.html @@ -34,6 +34,7 @@ Receive a notification when a draft author replies to a user talk message you left them +