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
16 changes: 16 additions & 0 deletions lib/Db/BoardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ public function findByExternalId(int $externalId): array {
return $this->findEntities($qb);
}

/**
* Used by ISignedCloudFederationProvider to resolve a board from a share token.
*
* @param string $shareToken
* @return Board
* @throws DoesNotExistException
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
*/
public function findByShareToken(string $shareToken): Board {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('deck_boards')
->where($qb->expr()->eq('share_token', $qb->createNamedParameter($shareToken, IQueryBuilder::PARAM_STR)));
return $this->findEntity($qb);
}

public function findAllForUser(string $userId, ?int $since = null, bool $includeArchived = true, ?int $before = null,
?string $term = null): array {
$useCache = ($since === -1 && $includeArchived === true && $before === null && $term === null);
Expand Down
15 changes: 13 additions & 2 deletions lib/Federation/DeckFederationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Db\ChangeHelper;
use OCA\Deck\Service\ConfigService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\Common\Exception\NotFoundException;
use OCP\Federation\ICloudFederationProvider;
use OCP\Federation\ICloudFederationShare;
use OCP\Federation\ICloudIdManager;
use OCP\Federation\ISignedCloudFederationProvider;
use OCP\Notification\IManager as INotificationManager;

class DeckFederationProvider implements ICloudFederationProvider {
class DeckFederationProvider implements ISignedCloudFederationProvider {
public const PROVIDER_ID = 'deck';

public function __construct(
Expand Down Expand Up @@ -106,4 +108,13 @@ public function notificationReceived($notificationType, $providerId, $notificati
public function getSupportedShareTypes(): array {
return ['user'];
}

#[\Override]
public function getFederationIdFromSharedSecret(#[\SensitiveParameter] string $sharedSecret, array $payload): string {
try {
return $this->boardMapper->findByShareToken($sharedSecret)->getOwner();
} catch (DoesNotExistException|MultipleObjectsReturnedException) {
return '';
}
}
}
Loading