Skip to content

Commit 211bb99

Browse files
committed
add code to fetch webhooks
1 parent 9f5a0a7 commit 211bb99

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

solid/lib/Notifications/SolidWebhook.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55

66
class SolidWebhook implements SolidNotificationsInterface
77
{
8+
public function __construct(\OCA\Solid\Service\SolidWebhookService $webhookService) {
9+
$this->webhookService = $webhookService;
10+
}
11+
812
public function send($path, $type) {
9-
$subscribedUrls = $this->getSubscribedUrls($path, $type);
10-
foreach ($subscribedUrls as $webhookUrl) {
11-
$this->postUpdate($webhookUrl, $path, $type);
13+
$webhooks = $this->getWebhooks($path);
14+
foreach ($webhooks as $webhook) {
15+
try {
16+
$this->postUpdate($webhook['url'], $path, $type);
17+
} catch(\Exception $e) {
18+
// FIXME: add retry code here?
19+
}
1220
}
1321
}
14-
private function getSubscribedUrls($path, $type) {
15-
return []; // FIXME: Read this from the subscriptions
22+
private function getWebhooks($path, $type) {
23+
$urls = $this->webhookService->findByPath($path);
24+
return $urls;
1625
}
1726
private function postUpdate($webhookUrl, $path, $type) {
1827
try {

0 commit comments

Comments
 (0)