Skip to content

Commit f05eef6

Browse files
committed
fix: remove redundant db column
Signed-off-by: Jana Peper <[email protected]>
1 parent 9760354 commit f05eef6

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

apps/webhook_listeners/lib/Db/EphemeralToken.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,30 @@
1313

1414
/**
1515
* @method int getTokenId()
16-
* @method string getToken()
1716
* @method ?string getUserId()
1817
* @method int getCreatedAt()
1918
* @psalm-suppress PropertyNotSetInConstructor
2019
*/
2120
class EphemeralToken extends Entity implements \JsonSerializable {
2221
/**
23-
* @var int id of the token that was created for a webhook
22+
* @var int id of the token in the oc_authtoken db table
2423
*/
2524
protected $tokenId;
2625

27-
/**
28-
* @var string the token
29-
*/
30-
protected $token;
31-
3226
/**
3327
* @var ?string id of the user wich the token belongs to
3428
* @psalm-suppress PropertyNotSetInConstructor
3529
*/
3630
protected $userId = null;
3731

3832
/**
39-
* @var int
33+
* @var int token creation timestamp
4034
* @psalm-suppress PropertyNotSetInConstructor
4135
*/
4236
protected $createdAt;
4337

4438
public function __construct() {
4539
$this->addType('tokenId', 'integer');
46-
$this->addType('token', 'string');
4740
$this->addType('userId', 'string');
4841
$this->addType('createdAt', 'integer');
4942
}

apps/webhook_listeners/lib/Db/EphemeralTokenMapper.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939
/**
4040
* @throws DoesNotExistException
4141
* @throws MultipleObjectsReturnedException
42-
* @throws Exception
42+
* @throws \Exception
4343
*/
4444
public function getById(int $id): EphemeralToken {
4545
$qb = $this->db->getQueryBuilder();
@@ -52,7 +52,7 @@ public function getById(int $id): EphemeralToken {
5252
}
5353

5454
/**
55-
* @throws Exception
55+
* @throws \Exception
5656
* @return EphemeralToken[]
5757
*/
5858
public function getAll(): array {
@@ -75,18 +75,16 @@ public function getOlderThan($olderThan): array {
7575
}
7676

7777
/**
78-
* @throws Exception
78+
* @throws \Exception
7979
*/
8080
public function addEphemeralToken(
8181
int $tokenId,
82-
string $token,
8382
?string $userId,
8483
int $createdAt,
8584
): EphemeralToken {
8685
$tempToken = EphemeralToken::fromParams(
8786
[
8887
'tokenId' => $tokenId,
89-
'token' => $token,
9088
'userId' => $userId,
9189
'createdAt' => $createdAt,
9290
]
@@ -95,7 +93,7 @@ public function addEphemeralToken(
9593
}
9694

9795
/**
98-
* @throws Exception
96+
* @throws \Exception
9997
*/
10098
public function deleteByTokenId(int $tokenId): bool {
10199
$qb = $this->db->getQueryBuilder();
@@ -112,7 +110,7 @@ public function invalidateOldTokens(int $token_lifetime = self::TOKEN_LIFETIME)
112110

113111
$this->logger->debug('Invalidating ephemeral webhook tokens older than ' . date('c', $olderThan), ['app' => 'webhook_listeners']);
114112
foreach ($tokensToDelete as $token) {
115-
$this->tokenMapper->invalidate($token->getToken()); // delete token itself
113+
$this->tokenMapper->invalidate($this->tokenMapper->getTokenById($token->getTokenId())->getToken()); // delete token itself
116114
$this->deleteByTokenId($token->getTokenId()); // delete db row in webhook_tokens
117115
}
118116
}

apps/webhook_listeners/lib/Migration/Version1500Date20251007130000.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5151
'length' => 4,
5252
'unsigned' => true,
5353
]);
54-
$table->addColumn('token', Types::STRING, [
55-
'notnull' => false,
56-
'length' => 200,
57-
]);
5854
$table->addColumn('user_id', Types::STRING, [
5955
'notnull' => false,
6056
'length' => 64,

apps/webhook_listeners/lib/Service/TokenService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ private function createEphemeralToken(string $userId): string {
104104
}
105105
$this->tokenMapper->addEphemeralToken(
106106
$deviceToken->getId(),
107-
$deviceToken->getToken(),
108107
$userId,
109108
$this->time->getTime());
110109
return $token;

0 commit comments

Comments
 (0)