diff --git a/lib/Dav/SubscriptionManagementPlugin.php b/lib/Dav/SubscriptionManagementPlugin.php index 700acf8..4eb9de1 100644 --- a/lib/Dav/SubscriptionManagementPlugin.php +++ b/lib/Dav/SubscriptionManagementPlugin.php @@ -107,7 +107,7 @@ class SubscriptionManagementPlugin extends ServerPlugin { $subscriptionParameterIncluded = True; if(sizeof($parameter["value"]) == 1) { - $subscriptionType = $parameter["value"][0]["name"]; + $subscriptionType = preg_replace('/^\{DAV:Push\}/', '', $parameter["value"][0]["name"]); $subscriptionOptions = $parameter["value"][0]["value"]; } else { $errors[] = "only one subscription allowed"; @@ -121,7 +121,7 @@ class SubscriptionManagementPlugin extends ServerPlugin { $errors[] = "no subscription included"; } - $transport = $this->transportManager->getTransport(preg_replace('/^\{DAV:Push\}/', '', $subscriptionType)); + $transport = $this->transportManager->getTransport($subscriptionType); if($transport === null) { $errors[] = $subscriptionType . " transport does not exist"; @@ -151,6 +151,7 @@ class SubscriptionManagementPlugin extends ServerPlugin { $subscription = new Subscription(); $subscription->setUserId($this->userId); $subscription->setCollectionName($node->getName()); + $subscription->setTransport($subscriptionType); $subscription->setCreationTimestamp(time()); if(!$subscriptionExpires) { $subscription->setExpirationTimestamp(0); diff --git a/lib/Db/Subscription.php b/lib/Db/Subscription.php index 2f47c06..7670c66 100644 --- a/lib/Db/Subscription.php +++ b/lib/Db/Subscription.php @@ -9,6 +9,7 @@ use OCP\AppFramework\Db\Entity; class Subscription extends Entity implements JsonSerializable { protected $userId; protected $collectionName; + protected $transport; protected $data; protected $creationTimestamp; protected $expirationTimestamp; @@ -23,9 +24,10 @@ class Subscription extends Entity implements JsonSerializable { 'id' => $this->id, 'userId' => $this->userId, 'collectionName' => $this->collectionName, + 'transport' => $this->transport, 'data' => $this->data, 'creationTimestamp' => $this->creationTimestamp, - 'expirationTimestamp' => $this->expirationTimestampv + 'expirationTimestamp' => $this->expirationTimestamp ]; } } \ No newline at end of file diff --git a/lib/Migration/Version001Date20240515221000.php b/lib/Migration/Version001Date20240515221000.php index 5225593..7c862f6 100644 --- a/lib/Migration/Version001Date20240515221000.php +++ b/lib/Migration/Version001Date20240515221000.php @@ -4,6 +4,28 @@ declare(strict_types=1); namespace OCA\DavPush\Migration; +/** + * @copyright 2024 Jonathan Treffler + * + * @author Jonathan Treffler + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + use Closure; use OCP\DB\Types; use OCP\DB\ISchemaWrapper; @@ -38,6 +60,10 @@ class Version001Date20240515221000 extends SimpleMigrationStep { 'notnull' => true, 'length' => 100, ]); + $table->addColumn('transport', Types::STRING, [ + 'notnull' => true, + 'length' => 100, + ]); $table->addColumn('data', Types::TEXT, [ 'notnull' => true, ]);