Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/checkout@v4.2.2
with:
repository: nextcloud/server
ref: ${{ matrix.server-versions }}
ref: 'feature/54562/files-sharing-authoritative'
submodules: true

- name: Checkout app
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/Controller/CardApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public function create($title, $type = 'plain', $order = 999, $description = '',
$card = $this->cardService->create($title, $this->request->getParam('stackId'), $type, $order, $this->userId, $description, $duedate);

foreach ($labels as $labelId) {
$this->cardService->assignLabel($card->id, $labelId);
$this->cardService->assignLabel($card->getId(), $labelId);
}

foreach ($users as $user) {
$this->assignmentService->assignUser($card->id, $user['id'], $user['type']);
$this->assignmentService->assignUser($card->getId(), $user['id'], $user['type']);
}

return new DataResponse($card, HTTP::STATUS_OK);
Expand Down
1 change: 0 additions & 1 deletion lib/Db/Assignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use JsonSerializable;

class Assignment extends RelationalEntity implements JsonSerializable {
public $id;
protected $participant;
protected $cardId;
protected $type;
Expand Down
1 change: 0 additions & 1 deletion lib/Db/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use OCP\AppFramework\Db\Entity;

class Session extends Entity implements \JsonSerializable {
public $id;
protected $userId;
protected $token;
protected $lastContact;
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FilesAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function markAsDeleted(Attachment $attachment) {
*/
private function getShareForAttachment(Attachment $attachment): IShare {
try {
$share = $this->shareProvider->getShareById($attachment->getId());
$share = $this->shareProvider->getShareById((string)$attachment->getId());
} catch (ShareNotFound $e) {
throw new NoPermissionException('No permission to access the attachment from the card');
}
Expand Down
76 changes: 74 additions & 2 deletions lib/Sharing/DeckShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IPartialShareProvider;
use OCP\Share\IShare;

/** Taken from the talk shareapicontroller helper */
Expand All @@ -42,7 +43,7 @@ public function formatShare(IShare $share): array;
public function canAccessShare(IShare $share, string $user): bool;
}

class DeckShareProvider implements \OCP\Share\IShareProvider {
class DeckShareProvider implements \OCP\Share\IShareProvider, IPartialShareProvider {
public const DECK_FOLDER = '/Deck';
public const DECK_FOLDER_PLACEHOLDER = '/{DECK_PLACEHOLDER}';

Expand Down Expand Up @@ -419,7 +420,7 @@ public function restore(IShare $share, string $recipient): IShare {

$qb->executeStatement();

return $this->getShareById((int)$share->getId(), $recipient);
return $this->getShareById((string)$share->getId(), $recipient);
}

/**
Expand Down Expand Up @@ -772,6 +773,77 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset): arra
return $shares;
}

/**
* @inheritDoc
*/
public function getSharedWithByPath(
string $userId,
int $shareType,
string $path,
bool $forChildren,
int $limit,
int $offset,
): iterable {
/** @var IShare[] $shares */
$shares = [];

$qb = $this->dbConnection->getQueryBuilder();
// s is the parent share, s2 the child
$qb->select('s.*', 's2.permissions AS s2_permissions', 's2.file_target AS s2_file_target',
'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash',
'f.parent AS f_parent', 'f.name', 'f.mimetype', 'f.mimepart', 'f.size', 'f.mtime', 'f.storage_mtime',
'f.encrypted', 'f.unencrypted_size', 'f.etag', 'f.checksum'
)
->selectAlias('st.id', 'storage_string_id')
->from('share', 's2')
->orderBy('s2.id')
->leftJoin('s2', 'share', 's', $qb->expr()->eq('s2.parent', 's.id'))
->leftJoin('s2', 'filecache', 'f', $qb->expr()->eq('s2.file_source', 'f.fileid'))
->leftJoin('f', 'storages', 'st', $qb->expr()->eq('f.storage', 'st.numeric_id'))
->leftJoin('s2', 'deck_cards', 'dc', $qb->expr()->eq($qb->expr()
->castColumn('dc.id', IQueryBuilder::PARAM_STR), 's.share_with'));

if ($limit !== -1) {
$qb->setMaxResults($limit);
}

$qb->andWhere($qb->expr()->eq('s2.share_with', $qb->createNamedParameter($userId)))
->andWhere($qb->expr()->eq('s2.share_type',
$qb->createNamedParameter(IShare::TYPE_DECK_USER)))
->andWhere($qb->expr()->orX(
$qb->expr()->eq('s2.item_type', $qb->createNamedParameter('file')),
$qb->expr()->eq('s2.item_type', $qb->createNamedParameter('folder'))
));

if ($forChildren) {
$qb->andWhere($qb->expr()->like('s2.file_target', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($path) . '_%')));
} else {
$qb->andWhere($qb->expr()->eq('s2.file_target', $qb->createNamedParameter($path)));
}

$qb->andWhere($qb->expr()->eq('dc.deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)));

$cursor = $qb->executeQuery();
while ($data = $cursor->fetch()) {
if (!$this->isAccessibleResult($data)) {
continue;
}

if ($offset > 0) {
$offset--;
continue;
}
$share = $this->createShareObject($data);
// patch the share with the user-specific information
$this->applyBoardPermission($share, (int)$data['s2_permissions'], $userId);
$share->setTarget($data['s2_file_target']);
$shares[] = $share;
}
$cursor->closeCursor();

return $shares;
}

/**
* Get shared with the card
*
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ HIDE_OC_LOGS=$2

# Nextcloud integration tests composer
(
cd ${OC_PATH}build/integration
composer install
composer --working-dir $OC_PATH install
)
INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)

Expand Down
Loading