From 4fa99374be1ca54077705fbc50796fa17f3e5b3f Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 11 Feb 2018 05:55:02 -0800 Subject: [PATCH] Prevent "Call webhooks" Herald action from appearing in UI for adapters which can't fire it Summary: See . The "Commit Hook" events don't operate on objects and don't use TransactionEditors. They can't call webhooks in a normal way and currently don't call webhooks at all. Stop offering these actions in the UI. The "Outbound Mail" event also fires oddly and likely doesn't make much sense to hook anyway. Test Plan: Verified that these events no longer offer "Call webhooks", while normal events still do. Differential Revision: https://secure.phabricator.com/D19061 --- src/applications/diffusion/herald/HeraldPreCommitAdapter.php | 4 ++++ src/applications/herald/action/HeraldCallWebhookAction.php | 4 ++++ src/applications/herald/adapter/HeraldAdapter.php | 5 +++++ .../herald/PhabricatorMailOutboundMailHeraldAdapter.php | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php index 3f1bc6bfd0..f63f647da6 100644 --- a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php +++ b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php @@ -87,4 +87,8 @@ abstract class HeraldPreCommitAdapter extends HeraldAdapter { $this->hookEngine->getRepository()->getProjectPHIDs()); } + public function supportsWebhooks() { + return false; + } + } diff --git a/src/applications/herald/action/HeraldCallWebhookAction.php b/src/applications/herald/action/HeraldCallWebhookAction.php index a2003f4f33..953958e5c6 100644 --- a/src/applications/herald/action/HeraldCallWebhookAction.php +++ b/src/applications/herald/action/HeraldCallWebhookAction.php @@ -14,6 +14,10 @@ final class HeraldCallWebhookAction extends HeraldAction { } public function supportsObject($object) { + if (!$this->getAdapter()->supportsWebhooks()) { + return false; + } + return true; } diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php index 7764332f11..08a0ca7a52 100644 --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -1211,6 +1211,11 @@ abstract class HeraldAdapter extends Phobject { /* -( Webhooks )----------------------------------------------------------- */ + public function supportsWebhooks() { + return true; + } + + final public function queueWebhook($webhook_phid, $rule_phid) { $this->webhookMap[$webhook_phid][] = $rule_phid; return $this; diff --git a/src/applications/metamta/herald/PhabricatorMailOutboundMailHeraldAdapter.php b/src/applications/metamta/herald/PhabricatorMailOutboundMailHeraldAdapter.php index f96a6f86bd..94c13c9e0a 100644 --- a/src/applications/metamta/herald/PhabricatorMailOutboundMailHeraldAdapter.php +++ b/src/applications/metamta/herald/PhabricatorMailOutboundMailHeraldAdapter.php @@ -64,4 +64,8 @@ final class PhabricatorMailOutboundMailHeraldAdapter return pht('Mail %d', $this->getObject()->getID()); } + public function supportsWebhooks() { + return false; + } + }