Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
NovemLinguae committed Apr 16, 2024
1 parent 62878c3 commit 0b21b0f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/modules/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,8 @@
logCsd: true,
launchLinkPosition: 'p-cactions',
logAfc: false,
noWatch: false
noWatch: false,
autoSubscribe: false
};

/**
Expand Down
24 changes: 13 additions & 11 deletions src/modules/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
} );
}

Expand Down Expand Up @@ -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 ) );
} );
} );
}
Expand Down Expand Up @@ -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 ) {
Expand All @@ -2647,14 +2646,17 @@
}
}

// 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',
formatversion: 2,
page: talkPage,
commentname: commentName,
subscribe: true
} ).then( function ( json ) {
debugger;
console.log( json );
} );
} );
}
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/templates/tpl-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<a href="https://www.mediawiki.org/wiki/Help:DiscussionTools#Topic_subscriptions" target="_blank">Receive a notification</a> when a draft author replies to a user talk message you left them <input type="checkbox" id="autoSubscribe" class="afch-input" {{#autoSubscribe}}checked{{/autoSubscribe}} />
</label>
</div>
<!-- When adding new preferences, don't forget to update core.js prefDefaults -->
</div>
<!-- /preferences -->

Expand Down

0 comments on commit 0b21b0f

Please sign in to comment.