Skip to content

Commit 79094c1

Browse files
authored
add welcome option
fixes wikimedia-gadgets#386
1 parent 35144d4 commit 79094c1

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/modules/submissions.js

+28-6
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,9 @@
12651265
// $1 = article name
12661266
'g13-submission': '{{subst:Db-afc-notice|$1}} ~~~~',
12671267

1268-
'teahouse-invite': '{{subst:Wikipedia:Teahouse/AFC invitation|sign=~~~~}}'
1268+
'teahouse-invite': '{{subst:Wikipedia:Teahouse/AFC invitation|sign=~~~~}}',
1269+
1270+
'welcomedraft-user': '{{subst:Welcome draft}} ~~~~'
12691271
} );
12701272
}
12711273

@@ -2584,7 +2586,7 @@
25842586
afchSubmission.getSubmitter().done( ( submitter ) => {
25852587
const userTalk = new AFCH.Page( ( new mw.Title( submitter, 3 ) ).getPrefixedText() ),
25862588
shouldTeahouse = data.inviteToTeahouse ? $.Deferred() : false;
2587-
2589+
shouldWelcomeUser = data.sendWelcomeDraft ? $.Deferred() : false;
25882590
// Check categories on the page to ensure that if the user has already been
25892591
// invited to the Teahouse, we don't invite them again.
25902592
if ( data.inviteToTeahouse ) {
@@ -2605,11 +2607,31 @@
26052607
shouldTeahouse.resolve( !hasTeahouseCat );
26062608
} );
26072609
}
2608-
2609-
$.when( shouldTeahouse ).then( ( teahouse ) => {
2610+
// Check if the user has already been welcomed.
2611+
if ( data.sendWelcomeDraft ) {
2612+
userTalk.getCategories(true).done((categories) => {
2613+
let hasWelcomeDraftCat = false,
2614+
welcomeDraftCategories = [
2615+
'Category:Wikipedians who have received a AfC welcome message'
2616+
];
2617+
$.each( categories, ( _, cat ) => {
2618+
if ( welcomeDraftCategories.indexOf( cat ) !== -1 ) {
2619+
hasWelcomeDraftCat = true;
2620+
return false;
2621+
}
2622+
});
2623+
2624+
shouldWelcomeUser.resolve(!hasWelcomeDraftCat);
2625+
});
2626+
}
2627+
$.when( shouldTeahouse, shouldWelcomeUser ).then( ( teahouse, welcomeDraft ) => {
26102628
let message;
2629+
2630+
if ( welcomeDraft ) {
2631+
message = AFCH.msg.get( 'welcomedraft-user' ) + '\n\n';
2632+
}
26112633
if ( isDecline ) {
2612-
message = AFCH.msg.get( 'declined-submission', {
2634+
message += AFCH.msg.get( 'declined-submission', {
26132635
$1: AFCH.consts.pagename,
26142636
$2: afchSubmission.shortTitle,
26152637
$3: ( declineReason === 'cv' || declineReason2 === 'cv' ) ?
@@ -2622,7 +2644,7 @@
26222644
'' : data.declineTextarea
26232645
} );
26242646
} else {
2625-
message = AFCH.msg.get( 'rejected-submission', {
2647+
message += AFCH.msg.get( 'rejected-submission', {
26262648
$1: AFCH.consts.pagename,
26272649
$2: afchSubmission.shortTitle,
26282650
$3: data.rejectReason[ 0 ],

0 commit comments

Comments
 (0)