From 744215d5ffe4f14f4ca3a488aa192aa2b9dde249 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Sun, 27 Dec 2015 20:19:39 -0800 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 4 ++ .../phame/editor/PhameBlogEditor.php | 14 +++++ .../phame/editor/PhamePostEditor.php | 14 +++++ .../phame/herald/HeraldPhameBlogAdapter.php | 62 +++++++++++++++++++ .../phame/herald/HeraldPhamePostAdapter.php | 62 +++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 src/applications/phame/herald/HeraldPhameBlogAdapter.php create mode 100644 src/applications/phame/herald/HeraldPhamePostAdapter.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 0be7b1db7f..bfba62e253 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1155,6 +1155,8 @@ phutil_register_library_map(array( 'HeraldNewObjectField' => 'applications/herald/field/HeraldNewObjectField.php', 'HeraldNotifyActionGroup' => 'applications/herald/action/HeraldNotifyActionGroup.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', 'HeraldPonderQuestionAdapter' => 'applications/ponder/herald/HeraldPonderQuestionAdapter.php', 'HeraldPreCommitAdapter' => 'applications/diffusion/herald/HeraldPreCommitAdapter.php', @@ -5213,6 +5215,8 @@ phutil_register_library_map(array( 'HeraldNewObjectField' => 'HeraldField', 'HeraldNotifyActionGroup' => 'HeraldActionGroup', 'HeraldObjectTranscript' => 'Phobject', + 'HeraldPhameBlogAdapter' => 'HeraldAdapter', + 'HeraldPhamePostAdapter' => 'HeraldAdapter', 'HeraldPholioMockAdapter' => 'HeraldAdapter', 'HeraldPonderQuestionAdapter' => 'HeraldAdapter', 'HeraldPreCommitAdapter' => 'HeraldAdapter', diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php index c73c2be0a4..a59ede32be 100644 --- a/src/applications/phame/editor/PhameBlogEditor.php +++ b/src/applications/phame/editor/PhameBlogEditor.php @@ -230,4 +230,18 @@ final class PhameBlogEditor return false; } + protected function shouldApplyHeraldRules( + PhabricatorLiskDAO $object, + array $xactions) { + return true; + } + + protected function buildHeraldAdapter( + PhabricatorLiskDAO $object, + array $xactions) { + + return id(new HeraldPhameBlogAdapter()) + ->setBlog($object); + } + } diff --git a/src/applications/phame/editor/PhamePostEditor.php b/src/applications/phame/editor/PhamePostEditor.php index 8978be89b6..fa43a131ff 100644 --- a/src/applications/phame/editor/PhamePostEditor.php +++ b/src/applications/phame/editor/PhamePostEditor.php @@ -264,4 +264,18 @@ final class PhamePostEditor return false; } + protected function shouldApplyHeraldRules( + PhabricatorLiskDAO $object, + array $xactions) { + return true; + } + + protected function buildHeraldAdapter( + PhabricatorLiskDAO $object, + array $xactions) { + + return id(new HeraldPhamePostAdapter()) + ->setPost($object); + } + } diff --git a/src/applications/phame/herald/HeraldPhameBlogAdapter.php b/src/applications/phame/herald/HeraldPhameBlogAdapter.php new file mode 100644 index 0000000000..d8956ba4a6 --- /dev/null +++ b/src/applications/phame/herald/HeraldPhameBlogAdapter.php @@ -0,0 +1,62 @@ +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(); + } + +} diff --git a/src/applications/phame/herald/HeraldPhamePostAdapter.php b/src/applications/phame/herald/HeraldPhamePostAdapter.php new file mode 100644 index 0000000000..4776bbbdbc --- /dev/null +++ b/src/applications/phame/herald/HeraldPhamePostAdapter.php @@ -0,0 +1,62 @@ +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(); + } + +}