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
1 change: 0 additions & 1 deletion lib/Activity/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
$this->urlGenerator = $urlGenerator;
}


/**
* @inheritDoc
*/
Expand Down
1 change: 0 additions & 1 deletion lib/BackgroundJobs/EmptyTrashbinJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class EmptyTrashbinJob extends TimedJob {
public const INTERVAL = 5 * 60; // 5 minutes
public const TRASHBIN_TTL = 2 * 4 * 4 * 7 * 24 * 60 * 60; // Two months


public function __construct(
ITimeFactory $timeFactory,
private TreeMapper $treeMapper,
Expand Down
2 changes: 0 additions & 2 deletions lib/Controller/BookmarkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@ public function newBookmark(string $url = '', ?string $title = null, ?string $de
}
}


/**
* @throws UnauthenticatedError
*/
Expand Down Expand Up @@ -692,7 +691,6 @@ public function exportBookmark() {
return new ExportResponse($data);
}


/**
* @throws UnauthenticatedError
*/
Expand Down
1 change: 0 additions & 1 deletion lib/Controller/FoldersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ public function undeleteFromFolder(int $folderId, int $bookmarkId): JSONResponse
}
}


/**
* @throws UnauthenticatedError
*/
Expand Down
5 changes: 0 additions & 5 deletions lib/Controller/InternalFoldersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,12 @@ public function addFolder(string $title = '', int $parent_folder = -1): JSONResp
return $this->controller->addFolder($title, $parent_folder);
}



#[NoAdminRequired]
#[FrontpageRoute(verb: 'GET', url: '/folder/{folderId}/childorder')]
public function getFolderChildrenOrder(int $folderId, int $layers = 0): JSONResponse {
return $this->controller->getFolderChildrenOrder($folderId, $layers);
}


#[NoAdminRequired]
#[FrontpageRoute(verb: 'PATCH', url: '/folder/{folderId}/childorder')]
public function setFolderChildrenOrder(int $folderId, array $data = []): JSONResponse {
Expand Down Expand Up @@ -106,7 +103,6 @@ public function getFolderPublicToken(int $folderId): DataResponse {
return $this->controller->getFolderPublicToken($folderId);
}


#[NoAdminRequired]
#[FrontpageRoute(verb: 'POST', url: '/folder/{folderId}/publictoken')]
public function createFolderPublicToken(int $folderId): DataResponse {
Expand Down Expand Up @@ -137,7 +133,6 @@ public function findShares(): DataResponse {
return $this->controller->findShares();
}


#[NoAdminRequired]
#[FrontpageRoute(verb: 'POST', url: '/folder/{folderId}/shares')]
public function createShare(int $folderId, string $participant, int $type, bool $canWrite = false, bool $canShare = false): DataResponse {
Expand Down
1 change: 0 additions & 1 deletion lib/Controller/WebViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function __construct(
parent::__construct($appName, $request);
}


#[NoAdminRequired]
#[NoCSRFRequired]
#[FrontpageRoute(verb: 'GET', url: '/')]
Expand Down
1 change: 0 additions & 1 deletion lib/Dashboard/Frequent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function __construct(IL10N $l, \OCP\IURLGenerator $url) {
$this->url = $url;
}


/**
* @inheritDoc
*/
Expand Down
1 change: 0 additions & 1 deletion lib/Dashboard/Recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function __construct(IL10N $l, \OCP\IURLGenerator $url) {
$this->url = $url;
}


/**
* @inheritDoc
*/
Expand Down
2 changes: 0 additions & 2 deletions lib/Db/BookmarkMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ protected function mapRowToEntity(array $row): Bookmark {
return call_user_func($this->entityClass . '::fromRow', $row);
}


/**
* Find a specific bookmark by Id
*
Expand Down Expand Up @@ -782,7 +781,6 @@ public function findAllInPublicFolder(string $token, QueryParameters $queryParam
->from('*PREFIX*bookmarks', 'b')
->innerJoin('b', 'folder_tree', 'tree', 'tree.item_id = b.id AND tree.type = ' . $qb->createPositionalParameter(TreeMapper::TYPE_BOOKMARK) . ' AND tree.soft_deleted_at is NULL');


$this->_filterUrl($qb, $queryParams);
$this->_filterArchived($qb, $queryParams);
$this->_filterUnavailable($qb, $queryParams);
Expand Down
1 change: 0 additions & 1 deletion lib/Db/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Folder extends Entity {

public static $columns = ['id', 'title', 'user_id'];


public function __construct() {
// add types in constructor
$this->addType('title', 'string');
Expand Down
2 changes: 0 additions & 2 deletions lib/Db/FolderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class FolderMapper extends QBMapper {
*/
protected $sharedFolderMapper;


/**
* @var ShareMapper
*/
Expand Down Expand Up @@ -115,7 +114,6 @@ public function findRootFolder(string $userId): Folder {
return $rootFolder;
}


/**
* @param Entity $entity
* @psalm-param Folder $entity
Expand Down
5 changes: 1 addition & 4 deletions lib/Db/TreeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class TreeMapper extends QBMapper {

protected $entityColumns = [];


private IQueryBuilder $insertQuery;

private IQueryBuilder $parentQuery;
Expand Down Expand Up @@ -371,7 +370,6 @@ public function hasDescendant(int $folderId, string $type, int $descendantId): b
return true;
}


/**
* @param string $type
* @psalm-param TreeMapper::TYPE_* $type
Expand Down Expand Up @@ -690,7 +688,6 @@ public function move(string $type, int $itemId, int $newParentFolderId, ?int $in
));
}


/**
* @brief Add a bookmark to a set of folders
* @param string $type
Expand Down Expand Up @@ -1034,7 +1031,7 @@ public function countChildren(int $folderId): int {
->from('bookmarks_tree')
->where($qb->expr()->eq('parent_folder', $qb->createPositionalParameter($folderId)))
->andWhere($qb->expr()->isNull('soft_deleted_at'));
return $qb->executeQuery()->fetch(PDO::FETCH_COLUMN);
return (int)$qb->executeQuery()->fetch(PDO::FETCH_COLUMN);
}

/**
Expand Down
1 change: 0 additions & 1 deletion lib/Flow/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function __construct(IL10N $l, IURLGenerator $urlGenerator, BookmarkMappe
$this->authorizer = $authorizer;
}


/**
* @inheritDoc
*/
Expand Down
1 change: 0 additions & 1 deletion lib/QueryParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function setTags(array $tags): self {
return $this;
}


/**
* @return int
*/
Expand Down
1 change: 0 additions & 1 deletion lib/Service/Authorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Authorizer {

private $cors = false;


public function __construct(
private FolderMapper $folderMapper,
private BookmarkMapper $bookmarkMapper,
Expand Down
1 change: 0 additions & 1 deletion lib/Service/BookmarksParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class BookmarksParser {
*/
private $ignorePersonalToolbarFolder = true;


/**
* Constructor
*
Expand Down
1 change: 0 additions & 1 deletion lib/Service/CirclesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

declare(strict_types=1);


namespace OCA\Bookmarks\Service;

use OCP\App\IAppManager;
Expand Down
30 changes: 14 additions & 16 deletions lib/Service/CrawlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use Exception;
use fivefilters\Readability\Configuration;
use fivefilters\Readability\Readability;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use Mimey\MimeTypes;
use OC\User\NoUserException;
use OCA\Bookmarks\Db\Bookmark;
Expand All @@ -24,6 +22,9 @@
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\Lock\LockedException;
Expand All @@ -36,18 +37,21 @@ class CrawlService {
public const READ_TIMEOUT = 30;
public const UA_FIREFOX = 'Mozilla/5.0 (X11; Linux x86_64; rv:150.0) Gecko/20100101 Firefox/150.0';

private IClient $client;
private MimeTypes $mimey;

public function __construct(
private BookmarkMapper $bookmarkMapper,
private BookmarkPreviewer $bookmarkPreviewer,
private FaviconPreviewer $faviconPreviewer,
IClientService $clientService,
private IConfig $config,
private IRootFolder $rootFolder,
private IL10N $l,
private LoggerInterface $logger,
private UserSettingsService $userSettingsService,
) {
$this->client = $clientService->newClient();
$this->mimey = new MimeTypes;
}

Expand All @@ -60,9 +64,7 @@ public function crawl(Bookmark $bookmark): void {
return;
}
try {
$client = new Client();
/** @var Response $resp */
$resp = $client->get($bookmark->getUrl(), [
$resp = $this->client->get($bookmark->getUrl(), [
'headers' => [
'User-Agent' => self::UA_FIREFOX,
],
Expand Down Expand Up @@ -91,15 +93,13 @@ public function crawl(Bookmark $bookmark): void {
$this->bookmarkMapper->update($bookmark);
}

private function archiveContent(Bookmark $bookmark, Response $resp): void {
$header = $resp->getHeader('Content-Type');
private function archiveContent(Bookmark $bookmark, IResponse $resp): void {
$contentType = $resp->getHeader('Content-Type');

if (empty($header)) {
if ($contentType === '') {
return;
}

$contentType = $header[0] ?? null;

if ($contentType !== null && str_contains($contentType, 'text/html')) {
if ($bookmark->getHtmlContent() === null || $bookmark->getHtmlContent() === '') {
$config = new Configuration();
Expand All @@ -120,18 +120,16 @@ private function archiveContent(Bookmark $bookmark, Response $resp): void {
}
}

private function archiveFile(Bookmark $bookmark, Response $resp): void {
$header = $resp->getHeader('Content-Type');
private function archiveFile(Bookmark $bookmark, IResponse $resp): void {
$contentType = $resp->getHeader('Content-Type');

if (empty($header)) {
if ($contentType === '') {
return;
}

$contentType = $header[0] ?? null;

if ($contentType !== null && !str_contains($contentType, 'text/html') && $bookmark->getArchivedFile() === null) {
$contentLengthHeader = $resp->getHeader('Content-Length');
$contentLength = isset($contentLengthHeader[0]) ? (int)$contentLengthHeader[0] : 0;
$contentLength = $contentLengthHeader !== '' ? (int)$contentLengthHeader : 0;

if ($contentLength < self::MAX_BODY_LENGTH) {
try {
Expand Down
1 change: 0 additions & 1 deletion lib/Service/FolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ public function createShare($folderId, $participant, int $type, bool $canWrite =
$this->addSharedFolderForParticipant($share, $folder, $type, $participant);
}


return $share;
}

Expand Down
1 change: 0 additions & 1 deletion lib/Service/HtmlImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class HtmlImporter {

private int $transactionCounter = 0;


public function __construct(
private BookmarkMapper $bookmarkMapper,
private FolderMapper $folderMapper,
Expand Down
1 change: 0 additions & 1 deletion lib/Service/Previewers/GenericUrlBookmarkPreviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class GenericUrlBookmarkPreviewer implements IBookmarkPreviewer {
*/
private $client;


/** @var LoggerInterface */
private $logger;

Expand Down
1 change: 0 additions & 1 deletion lib/Service/Previewers/ScreeenlyBookmarkPreviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class ScreeenlyBookmarkPreviewer implements IBookmarkPreviewer {
*/
private $client;


/** @var LoggerInterface */
private $logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ScreenshotMachineBookmarkPreviewer implements IBookmarkPreviewer {
*/
private $height = 800;


public function __construct(IConfig $config, IClientService $clientService, LoggerInterface $logger) {
$this->apiKey = $config->getAppValue('bookmarks', 'previews.screenshotmachine.key', '');
$this->client = $clientService->newClient();
Expand Down
2 changes: 0 additions & 2 deletions lib/Service/Previewers/WebshotBookmarkPreviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ public function fetchImage($url): ?Image {
return null;
}



return new Image('image/jpeg', $body);
}
}
1 change: 0 additions & 1 deletion lib/Service/TreeCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public function __construct(
$this->caches[self::CATEGORY_CHILDORDER] = $cacheFactory->createDistributed('bookmarks:' . self::CATEGORY_CHILDORDER);
}


private function getTreeMapper(): TreeMapper {
return $this->appContainer->get(TreeMapper::class);
}
Expand Down
12 changes: 4 additions & 8 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="6.14.2@bbd217fc98c0daa0a13aea2a7f119d03ba3fc9a0">
<files psalm-version="6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac">
<file src="lib/AppInfo/Application.php">
<InvalidArgument>
<code><![CDATA[UsersGroupsCirclesListener::class]]></code>
Expand Down Expand Up @@ -106,14 +106,10 @@
</file>
<file src="lib/Service/CrawlService.php">
<UndefinedClass>
<code><![CDATA[Client]]></code>
<code><![CDATA[Response]]></code>
<code><![CDATA[Response]]></code>
<code><![CDATA[$e]]></code>
<code><![CDATA[$e]]></code>
<code><![CDATA[NoUserException]]></code>
</UndefinedClass>
<UndefinedDocblockClass>
<code><![CDATA[$resp]]></code>
<code><![CDATA[$resp]]></code>
</UndefinedDocblockClass>
</file>
<file src="lib/Service/FolderService.php">
<InvalidReturnStatement>
Expand Down
1 change: 0 additions & 1 deletion tests/BookmarkMapperTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace OCA\Bookmarks\Tests;

use OC;
Expand Down
Loading
Loading