mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 18:52:42 +01:00
4fa99374be
Summary: See <https://discourse.phabricator-community.org/t/herald-webhook-is-not-called-but-herald-transcript-tells-me-the-opposite/1098>. 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
66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
final class HeraldCallWebhookAction extends HeraldAction {
|
|
|
|
const ACTIONCONST = 'webhook';
|
|
const DO_WEBHOOK = 'do.call-webhook';
|
|
|
|
public function getHeraldActionName() {
|
|
return pht('Call webhooks');
|
|
}
|
|
|
|
public function getActionGroupKey() {
|
|
return HeraldUtilityActionGroup::ACTIONGROUPKEY;
|
|
}
|
|
|
|
public function supportsObject($object) {
|
|
if (!$this->getAdapter()->supportsWebhooks()) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function supportsRuleType($rule_type) {
|
|
return ($rule_type !== HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
|
|
}
|
|
|
|
public function applyEffect($object, HeraldEffect $effect) {
|
|
$adapter = $this->getAdapter();
|
|
$rule = $effect->getRule();
|
|
$target = $effect->getTarget();
|
|
|
|
foreach ($target as $webhook_phid) {
|
|
$adapter->queueWebhook($webhook_phid, $rule->getPHID());
|
|
}
|
|
|
|
$this->logEffect(self::DO_WEBHOOK, $target);
|
|
}
|
|
|
|
public function getHeraldActionStandardType() {
|
|
return self::STANDARD_PHID_LIST;
|
|
}
|
|
|
|
protected function getActionEffectMap() {
|
|
return array(
|
|
self::DO_WEBHOOK => array(
|
|
'icon' => 'fa-cloud-upload',
|
|
'color' => 'green',
|
|
'name' => pht('Called Webhooks'),
|
|
),
|
|
);
|
|
}
|
|
|
|
public function renderActionDescription($value) {
|
|
return pht('Call webhooks: %s.', $this->renderHandleList($value));
|
|
}
|
|
|
|
protected function renderActionEffectDescription($type, $data) {
|
|
return pht('Called webhooks: %s.', $this->renderHandleList($data));
|
|
}
|
|
|
|
protected function getDatasource() {
|
|
return new HeraldWebhookDatasource();
|
|
}
|
|
|
|
}
|