From 26a235ab8a1870df4a82dbc5cd4f0c6dfd8adc92 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 17 Nov 2015 06:27:12 +1100 Subject: [PATCH] Make Herald rules subscribable Summary: Fixes T9757. Test Plan: Created a Herald rule and then subscribed to it with a different account. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin Maniphest Tasks: T9757 Differential Revision: https://secure.phabricator.com/D14468 --- .../sql/autopatches/20151112.herald.edge.sql | 16 +++++++++++++++ src/__phutil_library_map__.php | 1 + .../herald/storage/HeraldRule.php | 20 ++++++++++++++++++- .../herald/storage/HeraldSchemaSpec.php | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 resources/sql/autopatches/20151112.herald.edge.sql diff --git a/resources/sql/autopatches/20151112.herald.edge.sql b/resources/sql/autopatches/20151112.herald.edge.sql new file mode 100644 index 0000000000..db71dfbd79 --- /dev/null +++ b/resources/sql/autopatches/20151112.herald.edge.sql @@ -0,0 +1,16 @@ +CREATE TABLE {$NAMESPACE}_herald.edge ( + src VARBINARY(64) NOT NULL, + type INT UNSIGNED NOT NULL, + dst VARBINARY(64) NOT NULL, + dateCreated INT UNSIGNED NOT NULL, + seq INT UNSIGNED NOT NULL, + dataID INT UNSIGNED, + PRIMARY KEY (src, type, dst), + KEY `src` (src, type, dateCreated, seq), + UNIQUE KEY `key_dst` (dst, type, src) +) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; + +CREATE TABLE {$NAMESPACE}_herald.edgedata ( + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT} +) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT}; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bcb6f630cc..83b604c6f6 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -5073,6 +5073,7 @@ phutil_register_library_map(array( 'PhabricatorFlaggableInterface', 'PhabricatorPolicyInterface', 'PhabricatorDestructibleInterface', + 'PhabricatorSubscribableInterface', ), 'HeraldRuleController' => 'HeraldController', 'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor', diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php index efdfcdece6..51707fcc8a 100644 --- a/src/applications/herald/storage/HeraldRule.php +++ b/src/applications/herald/storage/HeraldRule.php @@ -5,7 +5,8 @@ final class HeraldRule extends HeraldDAO PhabricatorApplicationTransactionInterface, PhabricatorFlaggableInterface, PhabricatorPolicyInterface, - PhabricatorDestructibleInterface { + PhabricatorDestructibleInterface, + PhabricatorSubscribableInterface { const TABLE_RULE_APPLIED = 'herald_ruleapplied'; @@ -320,8 +321,25 @@ final class HeraldRule extends HeraldDAO } +/* -( PhabricatorSubscribableInterface )----------------------------------- */ + + + public function isAutomaticallySubscribed($phid) { + return $this->isPersonalRule() && $phid == $this->getAuthorPHID(); + } + + public function shouldShowSubscribersProperty() { + return true; + } + + public function shouldAllowSubscription($phid) { + return true; + } + + /* -( PhabricatorDestructibleInterface )----------------------------------- */ + public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { diff --git a/src/applications/herald/storage/HeraldSchemaSpec.php b/src/applications/herald/storage/HeraldSchemaSpec.php index 33045634d7..1b7b574296 100644 --- a/src/applications/herald/storage/HeraldSchemaSpec.php +++ b/src/applications/herald/storage/HeraldSchemaSpec.php @@ -33,6 +33,7 @@ final class HeraldSchemaSpec extends PhabricatorConfigSchemaSpec { 'unique' => true, ), )); + $this->buildEdgeSchemata(new HeraldRule()); } }