1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Add basic Herald support to Ponder

Summary: Ref T6919, Just a basic herald adapter (new questions) for Ponder

Test Plan: Created a Personal Rule, got subscribed to new question, saw transcript.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T6919

Differential Revision: https://secure.phabricator.com/D13828
This commit is contained in:
Chad Little 2015-08-08 10:22:18 -07:00
parent 3d1783b2da
commit dc687dbd92
4 changed files with 81 additions and 0 deletions

View file

@ -1063,6 +1063,7 @@ phutil_register_library_map(array(
'HeraldNotifyActionGroup' => 'applications/herald/action/HeraldNotifyActionGroup.php', 'HeraldNotifyActionGroup' => 'applications/herald/action/HeraldNotifyActionGroup.php',
'HeraldObjectTranscript' => 'applications/herald/storage/transcript/HeraldObjectTranscript.php', 'HeraldObjectTranscript' => 'applications/herald/storage/transcript/HeraldObjectTranscript.php',
'HeraldPholioMockAdapter' => 'applications/pholio/herald/HeraldPholioMockAdapter.php', 'HeraldPholioMockAdapter' => 'applications/pholio/herald/HeraldPholioMockAdapter.php',
'HeraldPonderQuestionAdapter' => 'applications/ponder/herald/HeraldPonderQuestionAdapter.php',
'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php', 'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php',
'HeraldPreCommitContentAdapter' => 'applications/diffusion/herald/HeraldPreCommitContentAdapter.php', 'HeraldPreCommitContentAdapter' => 'applications/diffusion/herald/HeraldPreCommitContentAdapter.php',
'HeraldPreCommitRefAdapter' => 'applications/diffusion/herald/HeraldPreCommitRefAdapter.php', 'HeraldPreCommitRefAdapter' => 'applications/diffusion/herald/HeraldPreCommitRefAdapter.php',
@ -4789,6 +4790,7 @@ phutil_register_library_map(array(
'HeraldNotifyActionGroup' => 'HeraldActionGroup', 'HeraldNotifyActionGroup' => 'HeraldActionGroup',
'HeraldObjectTranscript' => 'Phobject', 'HeraldObjectTranscript' => 'Phobject',
'HeraldPholioMockAdapter' => 'HeraldAdapter', 'HeraldPholioMockAdapter' => 'HeraldAdapter',
'HeraldPonderQuestionAdapter' => 'HeraldAdapter',
'HeraldPreCommitAdapter' => 'HeraldAdapter', 'HeraldPreCommitAdapter' => 'HeraldAdapter',
'HeraldPreCommitContentAdapter' => 'HeraldPreCommitAdapter', 'HeraldPreCommitContentAdapter' => 'HeraldPreCommitAdapter',
'HeraldPreCommitRefAdapter' => 'HeraldPreCommitAdapter', 'HeraldPreCommitRefAdapter' => 'HeraldPreCommitAdapter',

View file

@ -45,6 +45,9 @@ final class HeraldTestConsoleController extends HeraldController {
} else if ($object instanceof PhrictionDocument) { } else if ($object instanceof PhrictionDocument) {
$adapter = id(new PhrictionDocumentHeraldAdapter()) $adapter = id(new PhrictionDocumentHeraldAdapter())
->setDocument($object); ->setDocument($object);
} else if ($object instanceof PonderQuestion) {
$adapter = id(new HeraldPonderQuestionAdapter())
->setQuestion($object);
} else { } else {
throw new Exception(pht('Can not build adapter for object!')); throw new Exception(pht('Can not build adapter for object!'));
} }

View file

@ -252,4 +252,18 @@ final class PonderQuestionEditor
return $body; return $body;
} }
protected function shouldApplyHeraldRules(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function buildHeraldAdapter(
PhabricatorLiskDAO $object,
array $xactions) {
return id(new HeraldPonderQuestionAdapter())
->setQuestion($object);
}
} }

View file

@ -0,0 +1,62 @@
<?php
final class HeraldPonderQuestionAdapter extends HeraldAdapter {
private $question;
protected function newObject() {
return new PonderQuestion();
}
public function getAdapterApplicationClass() {
return 'PhabricatorPonderApplication';
}
public function getAdapterContentDescription() {
return pht('React to questions being created or updated.');
}
protected function initializeNewAdapter() {
$this->question = $this->newObject();
}
public function supportsApplicationEmail() {
return true;
}
public function getRepetitionOptions() {
return array(
HeraldRepetitionPolicyConfig::EVERY,
HeraldRepetitionPolicyConfig::FIRST,
);
}
public function supportsRuleType($rule_type) {
switch ($rule_type) {
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL:
return true;
case HeraldRuleTypeConfig::RULE_TYPE_OBJECT:
default:
return false;
}
}
public function setQuestion(PonderQuestion $question) {
$this->question = $question;
return $this;
}
public function getObject() {
return $this->question;
}
public function getAdapterContentName() {
return pht('Ponder Questions');
}
public function getHeraldName() {
return 'Q'.$this->getObject()->getID();
}
}