From b02966a4819f02fe3914a5e77e3726b8a5c73bba Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Thu, 20 Nov 2025 13:18:44 +0100 Subject: [PATCH] fix: remove redundant db column Signed-off-by: Jana Peper --- apps/webhook_listeners/lib/Db/EphemeralToken.php | 11 ++--------- .../lib/Db/EphemeralTokenMapper.php | 12 +++++------- .../lib/Migration/Version1500Date20251007130000.php | 4 ---- apps/webhook_listeners/lib/Service/TokenService.php | 1 - 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/apps/webhook_listeners/lib/Db/EphemeralToken.php b/apps/webhook_listeners/lib/Db/EphemeralToken.php index 82e3a735bf4..41aad2ba2a9 100644 --- a/apps/webhook_listeners/lib/Db/EphemeralToken.php +++ b/apps/webhook_listeners/lib/Db/EphemeralToken.php @@ -13,22 +13,16 @@ use OCP\AppFramework\Db\Entity; /** * @method int getTokenId() - * @method string getToken() * @method ?string getUserId() * @method int getCreatedAt() * @psalm-suppress PropertyNotSetInConstructor */ class EphemeralToken extends Entity implements \JsonSerializable { /** - * @var int id of the token that was created for a webhook + * @var int id of the token in the oc_authtoken db table */ protected $tokenId; - /** - * @var string the token - */ - protected $token; - /** * @var ?string id of the user wich the token belongs to * @psalm-suppress PropertyNotSetInConstructor @@ -36,14 +30,13 @@ class EphemeralToken extends Entity implements \JsonSerializable { protected $userId = null; /** - * @var int + * @var int token creation timestamp * @psalm-suppress PropertyNotSetInConstructor */ protected $createdAt; public function __construct() { $this->addType('tokenId', 'integer'); - $this->addType('token', 'string'); $this->addType('userId', 'string'); $this->addType('createdAt', 'integer'); } diff --git a/apps/webhook_listeners/lib/Db/EphemeralTokenMapper.php b/apps/webhook_listeners/lib/Db/EphemeralTokenMapper.php index 8ef44628b78..08417a898fd 100644 --- a/apps/webhook_listeners/lib/Db/EphemeralTokenMapper.php +++ b/apps/webhook_listeners/lib/Db/EphemeralTokenMapper.php @@ -39,7 +39,7 @@ class EphemeralTokenMapper extends QBMapper { /** * @throws DoesNotExistException * @throws MultipleObjectsReturnedException - * @throws Exception + * @throws \Exception */ public function getById(int $id): EphemeralToken { $qb = $this->db->getQueryBuilder(); @@ -52,7 +52,7 @@ class EphemeralTokenMapper extends QBMapper { } /** - * @throws Exception + * @throws \Exception * @return EphemeralToken[] */ public function getAll(): array { @@ -75,18 +75,16 @@ class EphemeralTokenMapper extends QBMapper { } /** - * @throws Exception + * @throws \Exception */ public function addEphemeralToken( int $tokenId, - string $token, ?string $userId, int $createdAt, ): EphemeralToken { $tempToken = EphemeralToken::fromParams( [ 'tokenId' => $tokenId, - 'token' => $token, 'userId' => $userId, 'createdAt' => $createdAt, ] @@ -95,7 +93,7 @@ class EphemeralTokenMapper extends QBMapper { } /** - * @throws Exception + * @throws \Exception */ public function deleteByTokenId(int $tokenId): bool { $qb = $this->db->getQueryBuilder(); @@ -112,7 +110,7 @@ class EphemeralTokenMapper extends QBMapper { $this->logger->debug('Invalidating ephemeral webhook tokens older than ' . date('c', $olderThan), ['app' => 'webhook_listeners']); foreach ($tokensToDelete as $token) { - $this->tokenMapper->invalidate($token->getToken()); // delete token itself + $this->tokenMapper->invalidate($this->tokenMapper->getTokenById($token->getTokenId())->getToken()); // delete token itself $this->deleteByTokenId($token->getTokenId()); // delete db row in webhook_tokens } } diff --git a/apps/webhook_listeners/lib/Migration/Version1500Date20251007130000.php b/apps/webhook_listeners/lib/Migration/Version1500Date20251007130000.php index 4e3e31b124a..4ca578da989 100644 --- a/apps/webhook_listeners/lib/Migration/Version1500Date20251007130000.php +++ b/apps/webhook_listeners/lib/Migration/Version1500Date20251007130000.php @@ -51,10 +51,6 @@ class Version1500Date20251007130000 extends SimpleMigrationStep { 'length' => 4, 'unsigned' => true, ]); - $table->addColumn('token', Types::STRING, [ - 'notnull' => false, - 'length' => 200, - ]); $table->addColumn('user_id', Types::STRING, [ 'notnull' => false, 'length' => 64, diff --git a/apps/webhook_listeners/lib/Service/TokenService.php b/apps/webhook_listeners/lib/Service/TokenService.php index 8beefe727dd..ee170ccc8b6 100644 --- a/apps/webhook_listeners/lib/Service/TokenService.php +++ b/apps/webhook_listeners/lib/Service/TokenService.php @@ -104,7 +104,6 @@ class TokenService { } $this->tokenMapper->addEphemeralToken( $deviceToken->getId(), - $deviceToken->getToken(), $userId, $this->time->getTime()); return $token;