Permalink
Browse files

only attempt to notify the requestor if we can *find* a user to notify

(otherwise, display an error message)
  • Loading branch information...
theopolisme committed Aug 22, 2013
1 parent 9de850f commit 785b69ac1d2bf781d50754453b778f99c6dd6599
Showing with 14 additions and 8 deletions.
  1. +14 −8 src/ffu.js
View
@@ -289,14 +289,20 @@ function afcHelper_ffu_performActions() {
// todo list: if more files in one request were handled, only notify once (would require change in structure of program)
if ((sub_m.action != 'none') && (sub_m.notify == true)) {
// assuming the first User/IP is the requester
- var requestinguser = /\[\[(User[_ ]talk:|User:|Special:Contributions\/)([^\||\]\]]*)([^\]]*?)\]\]/i.exec(text)[2];
- var userpagetext = afcHelper_getPageText('User talk:' + requestinguser, true);
- if (sub_m.action == 'decline') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|decline\}\} \~\~\~\~\n';
- else if (sub_m.action == 'comment') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|comment\}\} \~\~\~\~\n';
- else if (sub_m.action == 'hold') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|h\}\} \~\~\~\~\n';
- else if (sub_m.action == 'accept') if (sub_m.to === '') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu|comment\}\} \~\~\~\~\n';
- else userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|file=' + sub_m.to + '\}\} \~\~\~\~\n';
- afcHelper_editPage('User talk:' + requestinguser, userpagetext, 'Notifying user about [[WP:FFU|FFU]] request', false);
+ match = /\[\[(?:User[_ ]talk:|User:|Special:Contributions\/)([^\||\]\]]*)([^\]]*?)\]\]/i.exec(text)
+ // only notify if we can find a user to notify
+ if (match) {
+ var requestinguser = match[1];
+ var userpagetext = afcHelper_getPageText('User talk:' + requestinguser, true);
+ if (sub_m.action == 'decline') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|decline\}\} \~\~\~\~\n';
+ else if (sub_m.action == 'comment') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|comment\}\} \~\~\~\~\n';
+ else if (sub_m.action == 'hold') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|h\}\} \~\~\~\~\n';
+ else if (sub_m.action == 'accept') if (sub_m.to === '') userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu|comment\}\} \~\~\~\~\n';
+ else userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|file=' + sub_m.to + '\}\} \~\~\~\~\n';
+ afcHelper_editPage('User talk:' + requestinguser, userpagetext, 'Notifying user about [[WP:FFU|FFU]] request', false);
+ } else {
+ document.getElementById('afcHelper_status').innerHTML += '<li>Unable to notify user for ' + sub.title + ': Could not find a username to notify!</li>';
+ }
}
if (sub_m.action == 'accept') {
// create local file description talkpage

1 comment on commit 785b69a

Member

wikipedia-mabdul commented on 785b69a Aug 22, 2013

BTW: shouldn't we disamb. the headlines similar to the headlines when informing the user of declined submissions (this was a valid request a few months ago!)

Please sign in to comment.