Skip to content

Commit 2a445a6

Browse files
committed
Fix integration "#hook" link using wrong base domain
1 parent 22e2af4 commit 2a445a6

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/Model/Integration.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ public function triggerHook()
3939
$this->sendRequest($hookUrl, 'post', $options);
4040
}
4141

42+
/**
43+
* {@inheritDoc}
44+
*
45+
* The hook link must use the integration's "self" link as the base, not
46+
* the overridden base URL. This is because the external API proxy does not
47+
* yet support unauthenticated requests.
48+
*/
49+
public function getLink($rel, $absolute = true)
50+
{
51+
if ($rel === '#hook') {
52+
if (!isset($this->data['_links'][$rel]['href'])) {
53+
throw new \InvalidArgumentException("Link not found: $rel");
54+
}
55+
if (!isset($this->data['_links']['self']['href'])) {
56+
throw new \RuntimeException('Failed to find integration "self" link');
57+
}
58+
return $this->makeAbsoluteUrl($this->data['_links'][$rel]['href'], $this->data['_links']['self']['href']);
59+
}
60+
return parent::getLink($rel, $absolute);
61+
}
62+
4263
/**
4364
* Validate the integration via the API.
4465
*

0 commit comments

Comments
 (0)