Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Those groups of people can then be used by any other app for sharing purpose.
<step>OCA\Circles\Migration\Migration</step>
<step>OCA\Circles\Migration\SyncGroupCircles</step>
</post-migration>
<live-migration>
<step>OCA\Circles\Migration\RemoveShareTokens</step>
</live-migration>
</repair-steps>

<commands>
Expand Down
2 changes: 2 additions & 0 deletions lib/ConfigLexicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
class ConfigLexicon implements ILexicon {
public const USER_SINGLE_ID = 'userSingleId';
public const REMOVE_SHARE_TOKENS_DONE = 'remove_share_tokens_done';

public function getStrictness(): Strictness {
return Strictness::IGNORE;
Expand All @@ -34,6 +35,7 @@ public function getAppConfigs(): array {
public function getUserConfigs(): array {
return [
new Entry(key: self::USER_SINGLE_ID, type: ValueType::STRING, defaultRaw: '', definition: 'caching singleId for each local account', lazy: false, flags: IUserConfig::FLAG_INDEXED),
new Entry(key: self::REMOVE_SHARE_TOKENS_DONE, type: ValueType::BOOL, defaultRaw: false, definition: 'whether the remove share tokens repair step has already been executed', lazy: true),
];
}
}
58 changes: 58 additions & 0 deletions lib/Migration/RemoveShareTokens.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Circles\Migration;

use OCA\Circles\ConfigLexicon;
use OCP\AppFramework\Services\IAppConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Share\IShare;

/**
* Class RemoveShareTokens
*
* @package OCA\Circles\Migration
*/
class RemoveShareTokens implements IRepairStep {

public function __construct(
private IDBConnection $dbConnection,
private readonly IAppConfig $appConfig,
) {
}

public function getName(): string {
return 'Remove token from shares related to circles';
}

public function run(IOutput $output): void {
if ($this->appConfig->getAppValueBool(ConfigLexicon::REMOVE_SHARE_TOKENS_DONE)) {
return;
}

$qb = $this->dbConnection->getQueryBuilder();
$qb->update('share')
->set('token', $qb->createNamedParameter(null, IQueryBuilder::PARAM_NULL))
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_CIRCLE, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->isNotNull('token'))
->setMaxResults(1000);

while (true) {
$updated = $qb->executeStatement();
if ($updated === 0) {
break;
}
}

$this->appConfig->setAppValueBool(ConfigLexicon::REMOVE_SHARE_TOKENS_DONE, true);
}
}
2 changes: 1 addition & 1 deletion lib/Model/ShareWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function setToken(string $token): self {
}

public function getToken(): string {
return $this->token;
return $this->shareToken?->getToken() ?? '';
}

public function setStatus(int $status): self {
Expand Down
1 change: 0 additions & 1 deletion lib/ShareByCircleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public function create(IShare $share): IShare {
->add(DataProbe::INITIATOR, [DataProbe::BASED_ON]);

$circle = $this->circleService->probeCircle($share->getSharedWith(), $circleProbe, $dataProbe);
$share->setToken($this->token(15));
$share->setMailSend(true);
$owner = $circle->getInitiator();
$this->shareWrapperService->save($share);
Expand Down
Loading