mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +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:
parent
02f7ece868
commit
dad7c65bf5
3 changed files with 18 additions and 46 deletions
|
@ -48,4 +48,9 @@ class PhabricatorApplicationTransactionFeedStory
|
|||
return $view;
|
||||
}
|
||||
|
||||
public function renderText() {
|
||||
// TODO: This is grotesque; the feed notification handler relies on it.
|
||||
return strip_tags($this->renderView()->render());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,55 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group irc
|
||||
* @deprecated
|
||||
*/
|
||||
final class PhabricatorBotDifferentialNotificationHandler
|
||||
extends PhabricatorBotHandler {
|
||||
|
||||
private $skippedOldEvents;
|
||||
extends PhabricatorBotHandler {
|
||||
|
||||
public function receiveMessage(PhabricatorBotMessage $message) {
|
||||
return;
|
||||
}
|
||||
|
||||
public function runBackgroundTasks() {
|
||||
$iterator = new PhabricatorTimelineIterator('ircdiffx', array('difx'));
|
||||
$show = $this->getConfig('notification.actions');
|
||||
|
||||
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));
|
||||
}
|
||||
static $notified;
|
||||
if (!$notified) {
|
||||
phlog(
|
||||
'PhabricatorBotDifferentialNotificationHandler is deprecated, use '.
|
||||
'PhabricatorBotFeedNotificationHandler instead.');
|
||||
$notified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,11 @@ final class PhabricatorBotFeedNotificationHandler
|
|||
}
|
||||
|
||||
$channels = $this->getConfig('join');
|
||||
foreach ($channels as $channel) {
|
||||
foreach ($channels as $channel_name) {
|
||||
|
||||
$channel = id(new PhabricatorBotChannel())
|
||||
->setName($channel_name);
|
||||
|
||||
$this->writeMessage(
|
||||
id(new PhabricatorBotMessage())
|
||||
->setCommand('MESSAGE')
|
||||
|
|
Loading…
Reference in a new issue