Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / herald / action / HeraldCallWebhookAction.php
blob186a7a741f6efec0e10cf2ca3467466817246120
1 <?php
3 final class HeraldCallWebhookAction extends HeraldAction {
5 const ACTIONCONST = 'webhook';
6 const DO_WEBHOOK = 'do.call-webhook';
8 public function getHeraldActionName() {
9 return pht('Call webhooks');
12 public function getActionGroupKey() {
13 return HeraldUtilityActionGroup::ACTIONGROUPKEY;
16 public function supportsObject($object) {
17 if (!$this->getAdapter()->supportsWebhooks()) {
18 return false;
21 return true;
24 public function supportsRuleType($rule_type) {
25 return ($rule_type !== HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
28 public function applyEffect($object, HeraldEffect $effect) {
29 $adapter = $this->getAdapter();
30 $rule = $effect->getRule();
31 $target = $effect->getTarget();
33 foreach ($target as $webhook_phid) {
34 $adapter->queueWebhook($webhook_phid, $rule->getPHID());
37 $this->logEffect(self::DO_WEBHOOK, $target);
40 public function getHeraldActionStandardType() {
41 return self::STANDARD_PHID_LIST;
44 protected function getActionEffectMap() {
45 return array(
46 self::DO_WEBHOOK => array(
47 'icon' => 'fa-cloud-upload',
48 'color' => 'green',
49 'name' => pht('Called Webhooks'),
54 public function renderActionDescription($value) {
55 return pht('Call webhooks: %s.', $this->renderHandleList($value));
58 protected function renderActionEffectDescription($type, $data) {
59 return pht('Called webhooks: %s.', $this->renderHandleList($data));
62 protected function getDatasource() {
63 return new HeraldWebhookDatasource();
66 public function getPHIDsAffectedByAction(HeraldActionRecord $record) {
67 return $record->getTarget();