Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
636b804
refactor(Sharing): Tighten more types
provokateurin Nov 2, 2026
626be27
refactor(files_sharing): Set expiration date time to 23:59:59 only in…
provokateurin Sep 30, 2026
20b4361
feat(IShare): Add getProviderId()
provokateurin Sep 2, 2026
df61d55
getproviderid
icewind1991 Nov 26, 2026
d85da17
feat(Share20): Dispatch ShareUpdatedEvent and ShareRestoredEvent
provokateurin Sep 2, 2026
8f08124
feat(OCP\Share\Events): Add setters for the share property
provokateurin Sep 23, 2026
694a7ee
feat(SharingManager): Dispatch SharesUpdatedEvent and SharesDeletedEvent
provokateurin Sep 2, 2026
6cf00d1
feat(DefaultShareProvider): Allow fetching shares of TYPE_USERGROUP
provokateurin Sep 23, 2026
aaf665c
feat(ITeamManager): Allow calling getMembersOfTeam() without a user
provokateurin Sep 10, 2026
1cd79f8
feat(IShareRecipientType): Add getUsers()
provokateurin Sep 10, 2026
d1c0ea6
refactor(ISharePropertyTypeModifyValue): Modify values on format inst…
provokateurin Sep 21, 2026
910b2fd
refactor(ISharePropertyTypeModifyValue): Modify values on save in the…
provokateurin Nov 3, 2026
7539367
feat(Share): Add getCreatedAt() method
provokateurin Sep 23, 2026
26c2d84
feat(ISharingBackend): Add getUserStatuses() method
provokateurin Sep 23, 2026
1e6c1e2
fix(ShareByMailProvider): Set share status from DB
provokateurin Oct 13, 2026
de32518
fix(Share20): Fix setting target before and after the share is create…
provokateurin Oct 27, 2026
4b58c4a
fix(FederatedShareProvider): Use existing share time and token if ava…
provokateurin Oct 27, 2026
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
22 changes: 17 additions & 5 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

namespace OCA\FederatedFileSharing;

use DateTimeImmutable;
use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share;
use OCA\Files_Sharing\External\Storage as ExternalStorage;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Constants;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Federation\ICloudFederationProviderManager;
Expand Down Expand Up @@ -62,6 +64,7 @@ public function __construct(
private \OCP\GlobalScale\IConfig $gsConfig,
private ICloudFederationProviderManager $cloudFederationProviderManager,
private LoggerInterface $logger,
private ITimeFactory $timeFactory,
) {
}

Expand Down Expand Up @@ -137,7 +140,11 @@ public function create(IShare $share): IShare {

if ($remoteShare) {
$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
$token = $share->getToken();
if ($token === null || $token === '') {
$token = 'tmp_token_' . time();
}
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, $token, $shareType, $expirationDate, DateTimeImmutable::createFromMutable($share->getShareTime()) ?? $this->timeFactory->now());
[$token, $remoteId] = $this->notifications->requestReShare(
$remoteShare['refresh_token'],
$remoteShare['remote_id'],
Expand Down Expand Up @@ -172,7 +179,11 @@ public function create(IShare $share): IShare {
* @throws \Exception
*/
protected function createFederatedShare(IShare $share): string {
$token = $this->tokenHandler->generateToken();
$token = $share->getToken();
if ($token === null || $token === '') {
$token = $this->tokenHandler->generateToken();
}

$shareId = $this->addShareToDB(
$share->getNodeId(),
$share->getNodeType(),
Expand All @@ -182,7 +193,8 @@ protected function createFederatedShare(IShare $share): string {
$share->getPermissions(),
$token,
$share->getShareType(),
$share->getExpirationDate()
$share->getExpirationDate(),
DateTimeImmutable::createFromMutable($share->getShareTime()) ?? $this->timeFactory->now(),
);

$failure = false;
Expand Down Expand Up @@ -282,7 +294,7 @@ protected function getShareFromExternalShareTable(string $owner, string $target)
* @param int $shareType
* @param \DateTime $expirationDate
*/
private function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $shareType, $expirationDate): string {
private function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $shareType, $expirationDate, DateTimeImmutable $shareTime): string {
$qb = $this->dbConnection->getQueryBuilder();
$qb->insert('share')
->setValue('share_type', $qb->createNamedParameter($shareType))
Expand All @@ -295,7 +307,7 @@ private function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ui
->setValue('permissions', $qb->createNamedParameter($permissions))
->setValue('expiration', $qb->createNamedParameter($expirationDate, IQueryBuilder::PARAM_DATETIME_MUTABLE))
->setValue('token', $qb->createNamedParameter($token))
->setValue('stime', $qb->createNamedParameter(time()));
->setValue('stime', $qb->createNamedParameter($shareTime->getTimestamp()));

/*
* Added to fix https://github.com/owncloud/core/issues/22215
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
use OCA\Files_Sharing\External\Storage as ExternalStorage;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Constants;
use OCP\DB\IResult;
use OCP\DB\QueryBuilder\IExpressionBuilder;
Expand All @@ -30,6 +31,7 @@
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\Server;
use OCP\Share\IShare;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -78,6 +80,7 @@ protected function setUp(): void {
$this->gsConfig,
$this->cloudFederationProviderManager,
$this->logger,
Server::get(ITimeFactory::class),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Constants;
use OCP\Contacts\IManager as IContactsManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
Expand Down Expand Up @@ -103,6 +104,7 @@ protected function setUp(): void {
$this->gsConfig,
$this->cloudFederationProviderManager,
$this->logger,
Server::get(ITimeFactory::class),
);

$this->shareManager = Server::get(IManager::class);
Expand Down Expand Up @@ -473,6 +475,7 @@ public function testUpdate(string $owner, string $sharedBy, ?\DateTime $expirati
$this->gsConfig,
$this->cloudFederationProviderManager,
$this->logger,
Server::get(ITimeFactory::class),
]
)
->onlyMethods(['sendPermissionUpdate'])
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ public function createShare(
if ($expireDate !== '') {
try {
$expireDateTime = $this->parseDate($expireDate);
$expireDateTime->setTime(23, 59, 59);
$share->setExpirationDate($expireDateTime);
} catch (\Exception $e) {
throw new OCSNotFoundException($e->getMessage(), $e);
Expand Down Expand Up @@ -1385,6 +1386,7 @@ public function updateShare(
} elseif ($expireDate !== null) {
try {
$expireDateTime = $this->parseDate($expireDate);
$expireDateTime->setTime(23, 59, 59);
$share->setExpirationDate($expireDateTime);
} catch (\Exception $e) {
throw new OCSBadRequestException($e->getMessage(), $e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ public function testCreateShareValidExpireDate(): void {
$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (IShare $share) use ($path) {
$date = new \DateTime('2000-01-01');
$date->setTime(0, 0, 0);
$date->setTime(23, 59, 59);

return $share->getNode() === $path
&& $share->getShareType() === IShare::TYPE_LINK
Expand Down Expand Up @@ -2749,7 +2749,7 @@ public function testUpdateLinkShareSet(): void {
$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) {
$date = new \DateTime('2000-01-01');
$date->setTime(0, 0, 0);
$date->setTime(23, 59, 59);

return $share->getPermissions() === (Constants::PERMISSION_READ | Constants::PERMISSION_CREATE | Constants::PERMISSION_UPDATE | Constants::PERMISSION_DELETE)
&& $share->getPassword() === 'password'
Expand Down Expand Up @@ -3233,7 +3233,7 @@ public function testUpdateLinkShareExpireDateDoesNotChangeOther(): void {
$this->shareManager->expects($this->once())->method('updateShare')->with(
$this->callback(function (IShare $share) {
$date = new \DateTime('2010-12-23');
$date->setTime(0, 0, 0);
$date->setTime(23, 59, 59);

return $share->getPermissions() === Constants::PERMISSION_ALL
&& $share->getPassword() === 'password'
Expand Down
9 changes: 7 additions & 2 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,8 @@ protected function createShareObject(array $data): IShare {
->setTarget($data['file_target'])
->setMailSend((bool)$data['mail_send'])
->setNote($data['note'])
->setToken($data['token']);
->setToken($data['token'])
->setStatus((int)$data['accepted']);

$shareTime = new \DateTime();
$shareTime->setTimestamp((int)$data['stime']);
Expand Down Expand Up @@ -1253,7 +1254,11 @@ public function getAccessList($nodes, $currentAccess): array {
}

#[\Override]
public function getAllShares(): iterable {
public function getAllShares(bool $withUserGroup = false): iterable {
if ($withUserGroup) {
throw new RuntimeException('Unintended usage.');
}

$qb = $this->dbConnection->getQueryBuilder();

$qb->select('*')
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/AddShareRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<IShareRecipientType> $class */
$class = $input->getArgument('class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/AddShareSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<IShareSourceType> $class */
$class = $input->getArgument('class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/DeleteShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
$this->applyActor($input);

Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/GetShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');

return $this->wrapExecution($input, $output, fn (): Share => $this->manager->getShare($this->accessContext, $id));
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/GetShares.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function execute(InputInterface $input, OutputInterface $output): int {
}
}

/** @var ?string $lastShareID */
/** @var ?non-empty-string $lastShareID */
$lastShareID = $input->getOption('last-share-id');
/** @var ?string $limit */
$limit = $input->getOption('limit');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/RemoveShareRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<IShareRecipientType> $class */
$class = $input->getArgument('class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/RemoveShareSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<IShareSourceType> $class */
$class = $input->getArgument('class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/SelectSharePermissionPreset.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<ISharePermissionPreset> $permissionPresetClass */
$permissionPresetClass = $input->getArgument('permission-preset');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/UpdateSharePermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<ISharePermissionType> $class */
$class = $input->getArgument('class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/UpdateShareProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<ISharePropertyType> $class */
$class = $input->getArgument('class');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<ISharePermissionType> $permissionClass */
$permissionClass = $input->getArgument('permission-class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/UpdateShareRecipientSecret.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var class-string<IShareRecipientType> $class */
$class = $input->getArgument('class');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/UpdateShareState.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var string $state */
$state = $input->getArgument('state');
Expand Down
2 changes: 1 addition & 1 deletion apps/sharing/lib/Command/UpdateShareUserStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function configure(): void {

#[\Override]
public function execute(InputInterface $input, OutputInterface $output): int {
/** @var string $id */
/** @var non-empty-string $id */
$id = $input->getArgument('id');
/** @var string $userStatus */
$userStatus = $input->getArgument('user-status');
Expand Down
Loading
Loading