|
1265 | 1265 | // $1 = article name
|
1266 | 1266 | 'g13-submission': '{{subst:Db-afc-notice|$1}} ~~~~',
|
1267 | 1267 |
|
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}} ~~~~' |
1269 | 1271 | } );
|
1270 | 1272 | }
|
1271 | 1273 |
|
|
2584 | 2586 | afchSubmission.getSubmitter().done( ( submitter ) => {
|
2585 | 2587 | const userTalk = new AFCH.Page( ( new mw.Title( submitter, 3 ) ).getPrefixedText() ),
|
2586 | 2588 | shouldTeahouse = data.inviteToTeahouse ? $.Deferred() : false;
|
2587 |
| - |
| 2589 | + shouldWelcomeUser = data.sendWelcomeDraft ? $.Deferred() : false; |
2588 | 2590 | // Check categories on the page to ensure that if the user has already been
|
2589 | 2591 | // invited to the Teahouse, we don't invite them again.
|
2590 | 2592 | if ( data.inviteToTeahouse ) {
|
|
2605 | 2607 | shouldTeahouse.resolve( !hasTeahouseCat );
|
2606 | 2608 | } );
|
2607 | 2609 | }
|
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 ) => { |
2610 | 2628 | let message;
|
| 2629 | + |
| 2630 | + if ( welcomeDraft ) { |
| 2631 | + message = AFCH.msg.get( 'welcomedraft-user' ) + '\n\n'; |
| 2632 | + } |
2611 | 2633 | if ( isDecline ) {
|
2612 |
| - message = AFCH.msg.get( 'declined-submission', { |
| 2634 | + message += AFCH.msg.get( 'declined-submission', { |
2613 | 2635 | $1: AFCH.consts.pagename,
|
2614 | 2636 | $2: afchSubmission.shortTitle,
|
2615 | 2637 | $3: ( declineReason === 'cv' || declineReason2 === 'cv' ) ?
|
|
2622 | 2644 | '' : data.declineTextarea
|
2623 | 2645 | } );
|
2624 | 2646 | } else {
|
2625 |
| - message = AFCH.msg.get( 'rejected-submission', { |
| 2647 | + message += AFCH.msg.get( 'rejected-submission', { |
2626 | 2648 | $1: AFCH.consts.pagename,
|
2627 | 2649 | $2: afchSubmission.shortTitle,
|
2628 | 2650 | $3: data.rejectReason[ 0 ],
|
|
0 commit comments