fix web push transport getSubscriptionIdFromOptions
This commit is contained in:
parent
3d5b2c191a
commit
3551e6fc38
2 changed files with 8 additions and 3 deletions
|
@ -28,6 +28,7 @@ namespace OCA\DavPush\PushTransports;
|
||||||
|
|
||||||
use OCA\DavPush\Transport\Transport;
|
use OCA\DavPush\Transport\Transport;
|
||||||
use OCA\DavPush\Service\WebPushSubscriptionService;
|
use OCA\DavPush\Service\WebPushSubscriptionService;
|
||||||
|
use OCA\DavPush\Errors\WebPushSubscriptionNotFound;
|
||||||
|
|
||||||
use Sabre\Xml\Service;
|
use Sabre\Xml\Service;
|
||||||
|
|
||||||
|
@ -96,10 +97,14 @@ class WebPushTransport extends Transport {
|
||||||
$result = file_get_contents($data["pushResource"], false, $context);
|
$result = file_get_contents($data["pushResource"], false, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubscriptionIdFromOptions($options): int {
|
public function getSubscriptionIdFromOptions($options): ?int {
|
||||||
['pushResource' => $pushResource] = $this->parseOptions($options);
|
['pushResource' => $pushResource] = $this->parseOptions($options);
|
||||||
|
|
||||||
|
try {
|
||||||
return $this->webPushSubscriptionService->findByPushResource($pushResource)->getSubscriptionId();
|
return $this->webPushSubscriptionService->findByPushResource($pushResource)->getSubscriptionId();
|
||||||
|
} catch (WebPushSubscriptionNotFound $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateSubscription($subsciptionId, $options) {
|
public function updateSubscription($subsciptionId, $options) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ abstract class Transport {
|
||||||
// Transport needs to be able to map subscription options back to a subscription id.
|
// Transport needs to be able to map subscription options back to a subscription id.
|
||||||
// API Requests to create and update a subscription are the same, therefore if a subscription id is associated with the given options the subscription is updated, otherwise a new subscription is added.
|
// API Requests to create and update a subscription are the same, therefore if a subscription id is associated with the given options the subscription is updated, otherwise a new subscription is added.
|
||||||
// Which option(s) uniquely identify a subscription is implementation specific.
|
// Which option(s) uniquely identify a subscription is implementation specific.
|
||||||
abstract public function getSubscriptionIdFromOptions($options): int;
|
abstract public function getSubscriptionIdFromOptions($options): ?int;
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
Loading…
Reference in a new issue