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

Add Herald Adapters to Phame

Summary: Adds a basic HeraldAdapter to Phame Blogs and Posts.

Test Plan: Make a Herald rule to CC me on new posts or blogs automatically.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14897
This commit is contained in:
Chad Little 2015-12-27 20:19:39 -08:00
parent b471ebe987
commit 744215d5ff
5 changed files with 156 additions and 0 deletions

View file

@ -1155,6 +1155,8 @@ phutil_register_library_map(array(
'HeraldNewObjectField' => 'applications/herald/field/HeraldNewObjectField.php', 'HeraldNewObjectField' => 'applications/herald/field/HeraldNewObjectField.php',
'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',
'HeraldPhameBlogAdapter' => 'applications/phame/herald/HeraldPhameBlogAdapter.php',
'HeraldPhamePostAdapter' => 'applications/phame/herald/HeraldPhamePostAdapter.php',
'HeraldPholioMockAdapter' => 'applications/pholio/herald/HeraldPholioMockAdapter.php', 'HeraldPholioMockAdapter' => 'applications/pholio/herald/HeraldPholioMockAdapter.php',
'HeraldPonderQuestionAdapter' => 'applications/ponder/herald/HeraldPonderQuestionAdapter.php', 'HeraldPonderQuestionAdapter' => 'applications/ponder/herald/HeraldPonderQuestionAdapter.php',
'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php', 'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php',
@ -5213,6 +5215,8 @@ phutil_register_library_map(array(
'HeraldNewObjectField' => 'HeraldField', 'HeraldNewObjectField' => 'HeraldField',
'HeraldNotifyActionGroup' => 'HeraldActionGroup', 'HeraldNotifyActionGroup' => 'HeraldActionGroup',
'HeraldObjectTranscript' => 'Phobject', 'HeraldObjectTranscript' => 'Phobject',
'HeraldPhameBlogAdapter' => 'HeraldAdapter',
'HeraldPhamePostAdapter' => 'HeraldAdapter',
'HeraldPholioMockAdapter' => 'HeraldAdapter', 'HeraldPholioMockAdapter' => 'HeraldAdapter',
'HeraldPonderQuestionAdapter' => 'HeraldAdapter', 'HeraldPonderQuestionAdapter' => 'HeraldAdapter',
'HeraldPreCommitAdapter' => 'HeraldAdapter', 'HeraldPreCommitAdapter' => 'HeraldAdapter',

View file

@ -230,4 +230,18 @@ final class PhameBlogEditor
return false; return false;
} }
protected function shouldApplyHeraldRules(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function buildHeraldAdapter(
PhabricatorLiskDAO $object,
array $xactions) {
return id(new HeraldPhameBlogAdapter())
->setBlog($object);
}
} }

View file

@ -264,4 +264,18 @@ final class PhamePostEditor
return false; return false;
} }
protected function shouldApplyHeraldRules(
PhabricatorLiskDAO $object,
array $xactions) {
return true;
}
protected function buildHeraldAdapter(
PhabricatorLiskDAO $object,
array $xactions) {
return id(new HeraldPhamePostAdapter())
->setPost($object);
}
} }

View file

@ -0,0 +1,62 @@
<?php
final class HeraldPhameBlogAdapter extends HeraldAdapter {
private $blog;
protected function newObject() {
return new PhameBlog();
}
public function getAdapterApplicationClass() {
return 'PhabricatorPhameApplication';
}
public function getAdapterContentDescription() {
return pht('React to Phame Blogs being created or updated.');
}
protected function initializeNewAdapter() {
$this->blog = $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 setBlog(PhameBlog $blog) {
$this->blog = $blog;
return $this;
}
public function getObject() {
return $this->blog;
}
public function getAdapterContentName() {
return pht('Phame Blogs');
}
public function getHeraldName() {
return 'BLOG'.$this->getObject()->getID();
}
}

View file

@ -0,0 +1,62 @@
<?php
final class HeraldPhamePostAdapter extends HeraldAdapter {
private $post;
protected function newObject() {
return new PhamePost();
}
public function getAdapterApplicationClass() {
return 'PhabricatorPhameApplication';
}
public function getAdapterContentDescription() {
return pht('React to Phame Posts being created or updated.');
}
protected function initializeNewAdapter() {
$this->post = $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 setPost(PhamePost $post) {
$this->post = $post;
return $this;
}
public function getObject() {
return $this->post;
}
public function getAdapterContentName() {
return pht('Phame Posts');
}
public function getHeraldName() {
return 'POST'.$this->getObject()->getID();
}
}