1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Fix some bot issues

Summary:
  - Deprecate differentialnotification in favor of feednotification; it's strictly better.
  - Fix feed notification + channels.
  - Fix rendering of new-style stories (pholio, macro), which currently fatal.

Test Plan: See chatlog.

Reviewers: codeblock, indiefan

Reviewed By: codeblock

CC: aran

Differential Revision: https://secure.phabricator.com/D4981
This commit is contained in:
epriestley 2013-02-15 17:10:51 -08:00
parent 02f7ece868
commit dad7c65bf5
3 changed files with 18 additions and 46 deletions

View file

@ -48,4 +48,9 @@ class PhabricatorApplicationTransactionFeedStory
return $view; return $view;
} }
public function renderText() {
// TODO: This is grotesque; the feed notification handler relies on it.
return strip_tags($this->renderView()->render());
}
} }

View file

@ -1,55 +1,18 @@
<?php <?php
/** /**
* @group irc * @deprecated
*/ */
final class PhabricatorBotDifferentialNotificationHandler final class PhabricatorBotDifferentialNotificationHandler
extends PhabricatorBotHandler { extends PhabricatorBotHandler {
private $skippedOldEvents;
public function receiveMessage(PhabricatorBotMessage $message) { public function receiveMessage(PhabricatorBotMessage $message) {
return; static $notified;
} if (!$notified) {
phlog(
public function runBackgroundTasks() { 'PhabricatorBotDifferentialNotificationHandler is deprecated, use '.
$iterator = new PhabricatorTimelineIterator('ircdiffx', array('difx')); 'PhabricatorBotFeedNotificationHandler instead.');
$show = $this->getConfig('notification.actions'); $notified = true;
if (!$this->skippedOldEvents) {
// Since we only want to post notifications about new events, skip
// everything that's happened in the past when we start up so we'll
// only process real-time events.
foreach ($iterator as $event) {
// Ignore all old events.
}
$this->skippedOldEvents = true;
return;
}
foreach ($iterator as $event) {
$data = $event->getData();
if (!$data || ($show !== null && !in_array($data['action'], $show))) {
continue;
}
$actor_phid = $data['actor_phid'];
$phids = array($actor_phid);
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$verb = DifferentialAction::getActionPastTenseVerb($data['action']);
$actor_name = $handles[$actor_phid]->getName();
$message_body =
"{$actor_name} {$verb} revision D".$data['revision_id'].".";
$channels = $this->getConfig('notification.channels', array());
foreach ($channels as $channel) {
$this->writeMessage(
id(new PhabricatorBotMessage())
->setCommand('MESSAGE')
->setTarget($channel)
->setBody($message_body));
}
} }
} }

View file

@ -149,7 +149,11 @@ final class PhabricatorBotFeedNotificationHandler
} }
$channels = $this->getConfig('join'); $channels = $this->getConfig('join');
foreach ($channels as $channel) { foreach ($channels as $channel_name) {
$channel = id(new PhabricatorBotChannel())
->setName($channel_name);
$this->writeMessage( $this->writeMessage(
id(new PhabricatorBotMessage()) id(new PhabricatorBotMessage())
->setCommand('MESSAGE') ->setCommand('MESSAGE')