1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-02 09:58:24 +01:00

What's New flood protection

Summary:
Added what's new flood protection and fixed array_push issues.
Also added rhetoric for "Commit"

Test Plan: say "What's new?" twice within one minute

Reviewers: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1684
This commit is contained in:
Korvin Szanto 2012-02-23 19:16:18 -08:00
parent 5e39522ac4
commit 31cbb7fbe2

View file

@ -23,7 +23,10 @@
*/
final class PhabricatorIRCWhatsNewHandler extends PhabricatorIRCHandler {
private $floodblock = 0;
public function receiveMessage(PhabricatorIRCMessage $message) {
switch ($message->getCommand()) {
case 'PRIVMSG':
$reply_to = $message->getReplyTo();
@ -35,6 +38,11 @@ final class PhabricatorIRCWhatsNewHandler extends PhabricatorIRCHandler {
$prompt = '~what( i|\')?s new\?~i';
if (preg_match($prompt, $message)) {
if (time() < $this->floodblock) {
return;
}
$this->floodblock = time() + 60;
$this->getLatest($reply_to);
}
break;
@ -59,15 +67,15 @@ final class PhabricatorIRCWhatsNewHandler extends PhabricatorIRCHandler {
switch ($action['class']) {
case 'PhabricatorFeedStoryDifferential':
array_push($phids,$action['data']['revision_phid']);
$phids[] = $action['data']['revision_phid'];
break;
case 'PhabricatorFeedStoryManiphest':
array_push($phids,$action['data']['taskPHID']);
$phids[] = $action['data']['taskPHID'];
break;
default:
array_push($phids,$uid);
$phids[] = $uid;
break;
}
array_push($phids,$uid);
@ -120,19 +128,22 @@ final class PhabricatorIRCWhatsNewHandler extends PhabricatorIRCHandler {
public function getRhetoric($input) {
switch ($input) {
case "none":
case 'none':
return 'commented on';
break;
case "update":
case 'update':
return 'updated';
break;
case "create":
case 'commit':
return 'committed';
break;
case 'create':
return 'created';
break;
case "abandon":
case 'abandon':
return 'abandonned';
break;
case "accept":
case 'accept':
return 'accepted';
break;
default: