diff --git a/resources/sql/autopatches/20220401.phameinteract.04.postinteract.sql b/resources/sql/autopatches/20220401.phameinteract.04.postinteract.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20220401.phameinteract.04.postinteract.sql @@ -0,0 +1,6 @@ +ALTER TABLE {$NAMESPACE}_phame.phame_post + ADD interactPolicy VARBINARY(64) NOT NULL; + +UPDATE {$NAMESPACE}_phame.phame_post + SET interactPolicy = 'obj.phame.blog' + WHERE interactPolicy = ''; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -5277,6 +5277,7 @@ 'PhameDescriptionView' => 'applications/phame/view/PhameDescriptionView.php', 'PhameDraftListView' => 'applications/phame/view/PhameDraftListView.php', 'PhameHomeController' => 'applications/phame/controller/PhameHomeController.php', + 'PhameInheritBlogPolicyRule' => 'applications/phame/policyrule/PhameInheritBlogPolicyRule.php', 'PhameLiveController' => 'applications/phame/controller/PhameLiveController.php', 'PhameNextPostView' => 'applications/phame/view/PhameNextPostView.php', 'PhamePost' => 'applications/phame/storage/PhamePost.php', @@ -12167,6 +12168,7 @@ 'PhameDescriptionView' => 'AphrontTagView', 'PhameDraftListView' => 'AphrontTagView', 'PhameHomeController' => 'PhamePostController', + 'PhameInheritBlogPolicyRule' => 'PhabricatorPolicyRule', 'PhameLiveController' => 'PhameController', 'PhameNextPostView' => 'AphrontTagView', 'PhamePost' => array( diff --git a/src/applications/phame/editor/PhamePostEditor.php b/src/applications/phame/editor/PhamePostEditor.php --- a/src/applications/phame/editor/PhamePostEditor.php +++ b/src/applications/phame/editor/PhamePostEditor.php @@ -21,6 +21,8 @@ public function getTransactionTypes() { $types = parent::getTransactionTypes(); + + $types[] = PhabricatorTransactions::TYPE_INTERACT_POLICY; $types[] = PhabricatorTransactions::TYPE_COMMENT; return $types; diff --git a/src/applications/phame/policyrule/PhameInheritBlogPolicyRule.php b/src/applications/phame/policyrule/PhameInheritBlogPolicyRule.php new file mode 100644 --- /dev/null +++ b/src/applications/phame/policyrule/PhameInheritBlogPolicyRule.php @@ -0,0 +1,51 @@ +getBlog(), + PhabricatorPolicyCapability::CAN_INTERACT); + } + + public function getValueControlType() { + return self::CONTROL_TYPE_NONE; + } + +} diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -27,6 +27,7 @@ protected $blogPHID; protected $mailKey; protected $headerImagePHID; + protected $interactPolicy; private $blog = self::ATTACHABLE; private $headerImageFile = self::ATTACHABLE; @@ -40,7 +41,10 @@ ->setBlogPHID($blog->getPHID()) ->attachBlog($blog) ->setDatePublished(PhabricatorTime::getNow()) - ->setVisibility(PhameConstants::VISIBILITY_PUBLISHED); + ->setVisibility(PhameConstants::VISIBILITY_PUBLISHED) + ->setInteractPolicy( + id(new PhameInheritBlogPolicyRule()) + ->getObjectPolicyFullKey()); return $post; } @@ -140,6 +144,8 @@ // T6203/NULLABILITY // This one probably should be nullable? 'datePublished' => 'epoch', + + 'interactPolicy' => 'policy', ), self::CONFIG_KEY_SCHEMA => array( 'key_phid' => null, @@ -196,6 +202,7 @@ return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, + PhabricatorPolicyCapability::CAN_INTERACT, ); } @@ -220,6 +227,8 @@ } else { return PhabricatorPolicies::POLICY_NOONE; } + case PhabricatorPolicyCapability::CAN_INTERACT: + return $this->getInteractPolicy(); } } @@ -230,6 +239,8 @@ case PhabricatorPolicyCapability::CAN_VIEW: case PhabricatorPolicyCapability::CAN_EDIT: return ($user->getPHID() == $this->getBloggerPHID()); + case PhabricatorPolicyCapability::CAN_INTERACT: + return false; } }