Path: blob/master/src/applications/herald/action/HeraldCallWebhookAction.php
12256 views
<?php12final class HeraldCallWebhookAction extends HeraldAction {34const ACTIONCONST = 'webhook';5const DO_WEBHOOK = 'do.call-webhook';67public function getHeraldActionName() {8return pht('Call webhooks');9}1011public function getActionGroupKey() {12return HeraldUtilityActionGroup::ACTIONGROUPKEY;13}1415public function supportsObject($object) {16if (!$this->getAdapter()->supportsWebhooks()) {17return false;18}1920return true;21}2223public function supportsRuleType($rule_type) {24return ($rule_type !== HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);25}2627public function applyEffect($object, HeraldEffect $effect) {28$adapter = $this->getAdapter();29$rule = $effect->getRule();30$target = $effect->getTarget();3132foreach ($target as $webhook_phid) {33$adapter->queueWebhook($webhook_phid, $rule->getPHID());34}3536$this->logEffect(self::DO_WEBHOOK, $target);37}3839public function getHeraldActionStandardType() {40return self::STANDARD_PHID_LIST;41}4243protected function getActionEffectMap() {44return array(45self::DO_WEBHOOK => array(46'icon' => 'fa-cloud-upload',47'color' => 'green',48'name' => pht('Called Webhooks'),49),50);51}5253public function renderActionDescription($value) {54return pht('Call webhooks: %s.', $this->renderHandleList($value));55}5657protected function renderActionEffectDescription($type, $data) {58return pht('Called webhooks: %s.', $this->renderHandleList($data));59}6061protected function getDatasource() {62return new HeraldWebhookDatasource();63}6465public function getPHIDsAffectedByAction(HeraldActionRecord $record) {66return $record->getTarget();67}6869}707172