fix notify
This commit is contained in:
parent
7aefdcca3d
commit
7bc211dc37
3 changed files with 6 additions and 4 deletions
|
@ -62,7 +62,7 @@ class CalendarListener implements IEventListener {
|
||||||
foreach($subscriptions as $subscription) {
|
foreach($subscriptions as $subscription) {
|
||||||
$transport = $this->transportManager->getTransport($subscription->getTransport());
|
$transport = $this->transportManager->getTransport($subscription->getTransport());
|
||||||
try {
|
try {
|
||||||
$transport->notify($subscription->getUserId(), $collectionName, json_decode($subscription->getData(), True));
|
$transport->notify($subscription->getUserId(), $collectionName, $subscription->getId());
|
||||||
} catch (Error $e) {
|
} catch (Error $e) {
|
||||||
$this->logger->error("transport " . $subscription->getTransport() . " failed to deliver notification to subscription " . $subscription->getId());
|
$this->logger->error("transport " . $subscription->getTransport() . " failed to deliver notification to subscription " . $subscription->getId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,9 +79,11 @@ class WebPushTransport extends Transport {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notify(string $userId, string $collectionName, $data) {
|
public function notify(string $userId, string $collectionName, int $subscriptionId) {
|
||||||
$xmlService = new Service();
|
$xmlService = new Service();
|
||||||
|
|
||||||
|
$pushResource = $this->webPushSubscriptionService->findBySubscriptionId($subscriptionId)->getPushResource();
|
||||||
|
|
||||||
$content = $xmlService->write('{DAV:Push}push-message', [
|
$content = $xmlService->write('{DAV:Push}push-message', [
|
||||||
'{DAV:Push}topic' => $collectionName,
|
'{DAV:Push}topic' => $collectionName,
|
||||||
]);
|
]);
|
||||||
|
@ -94,7 +96,7 @@ class WebPushTransport extends Transport {
|
||||||
];
|
];
|
||||||
|
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
$result = file_get_contents($data["pushResource"], false, $context);
|
$result = file_get_contents($pushResource, false, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubscriptionIdFromOptions($options): ?int {
|
public function getSubscriptionIdFromOptions($options): ?int {
|
||||||
|
|
|
@ -67,5 +67,5 @@ abstract class Transport {
|
||||||
// Change mutable options of the subscription (if any exist)
|
// Change mutable options of the subscription (if any exist)
|
||||||
abstract public function updateSubscription($subsciptionId, $options);
|
abstract public function updateSubscription($subsciptionId, $options);
|
||||||
|
|
||||||
abstract public function notify(string $userId, string $collectionName, $data);
|
abstract public function notify(string $userId, string $collectionName, int $subscriptionId);
|
||||||
}
|
}
|
Loading…
Reference in a new issue