1
0
Fork 0

save transport of registration in db

This commit is contained in:
Jonathan Treffler 2024-06-12 03:03:35 +02:00
parent e42b7b34ad
commit af104a63f2
3 changed files with 32 additions and 3 deletions

View file

@ -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);

View file

@ -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
];
}
}

View file

@ -4,6 +4,28 @@ declare(strict_types=1);
namespace OCA\DavPush\Migration;
/**
* @copyright 2024 Jonathan Treffler <mail@jonathan-treffler.de>
*
* @author Jonathan Treffler <mail@jonathan-treffler.de>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/
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,
]);