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
9 changes: 7 additions & 2 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ jobs:
# do not stop on another job's failure
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3', '8.4']
php-versions: ['8.2', '8.3', '8.4']
databases: ['sqlite', 'mysql', 'pgsql']
server-versions: ['stable32', 'master']
server-versions: ['stable32', 'stable33', 'master']
prev-version: ['stable']
include:
- databases: 'sqlite'
server-versions: 'stable32'
php-versions: '8.1'
prev-version: 'stable'

name: Update from ${{ matrix.prev-version }} on ${{ matrix.databases }}-${{ matrix.server-versions }}

Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Requirements:
- mbstring: *
- when using MySQL, use at least v8.0
]]></description>
<version>16.0.1</version>
<version>16.1.0-dev.0</version>
<licence>agpl</licence>
<author mail="mklehr@gmx.net" homepage="https://marcelklehr.de">Marcel Klehr</author>
<author mail="blizzz@arthur-schiwon.de" homepage="https://www.arthur-schiwon.de">Arthur Schiwon</author>
Expand All @@ -42,7 +42,7 @@ Requirements:
<database>pgsql</database>
<lib>intl</lib>
<lib>mbstring</lib>
<nextcloud min-version="32" max-version="32" />
<nextcloud min-version="32" max-version="33" />
</dependencies>
<background-jobs>
<job>OCA\Bookmarks\BackgroundJobs\CrawlJob</job>
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
['name' => 'internal_bookmark#import_bookmark', 'url' => '/bookmark/import', 'verb' => 'POST'],
['name' => 'internal_bookmark#count_unavailable', 'url' => '/bookmark/unavailable', 'verb' => 'GET'],
['name' => 'internal_bookmark#count_archived', 'url' => '/bookmark/archived', 'verb' => 'GET'],
['name' => 'internal_bookmark#count_deleted', 'url' => '/bookmark/deletedCount', 'verb' => 'GET'],
['name' => 'internal_bookmark#count_duplicated', 'url' => '/bookmark/duplicated', 'verb' => 'GET'],
['name' => 'internal_bookmark#get_deleted_bookmarks', 'url' => '/bookmark/deleted', 'verb' => 'GET'],
['name' => 'internal_bookmark#edit_bookmark', 'url' => '/bookmark/{id}', 'verb' => 'PUT'],
Expand Down
23 changes: 21 additions & 2 deletions lib/Controller/BookmarkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private function _returnBookmarkAsArray(Bookmark $bookmark): array {
if (!isset($array['tags'])) {
$array['tags'] = $this->tagMapper->findByBookmark($bookmark->getId());
}
if ($array['archivedFile'] !== 0 && $array['archivedFile'] !== null) {
if ($array['archivedFile'] !== 0 && $array['archivedFile'] !== null && $this->authorizer->getUserId() === $bookmark->getUserId()) {
$result = $this->rootFolder->getFirstNodeById($array['archivedFile']);
if ($result !== null) {
$array['archivedFilePath'] = $result->getPath();
Expand Down Expand Up @@ -744,7 +744,7 @@ public function importBookmark($folder = null): JSONResponse {
return new JSONResponse(['status' => 'error', 'data' => ['Could not import all bookmarks: User limit Exceeded']], Http::STATUS_BAD_REQUEST);
} catch (AlreadyExistsError $e) {
return new JSONResponse(['status' => 'error', 'data' => ['Could not import all bookmarks: Already exists']], Http::STATUS_BAD_REQUEST);
} catch (UnsupportedOperation $e) {
} catch (UnsupportedOperation|\OCP\DB\Exception $e) {
return new JSONResponse(['status' => 'error', 'data' => ['Internal server error']], Http::STATUS_INTERNAL_SERVER_ERROR);
}
if (count($result['errors']) !== 0) {
Expand Down Expand Up @@ -874,6 +874,25 @@ public function countDuplicated(): JSONResponse {
return new JSONResponse(['status' => 'success', 'item' => $count]);
}

/**
* @return JSONResponse
* @NoAdminRequired
* @NoCSRFRequired
* @BruteForceProtection
* @PublicPage
* @throws UnauthenticatedError
*/
public function countDeleted(): JSONResponse {
if (!Authorizer::hasPermission(Authorizer::PERM_READ, $this->authorizer->getPermissionsForFolder(-1, $this->request))) {
$res = new JSONResponse(['status' => 'error', 'data' => ['Unauthorized']], Http::STATUS_FORBIDDEN);
$res->throttle();
return $res;
}

$count = $this->bookmarkMapper->countDeleted($this->authorizer->getUserId());
return new JSONResponse(['status' => 'success', 'item' => $count]);
}

/**
* @return JSONResponse
* @NoAdminRequired
Expand Down
9 changes: 9 additions & 0 deletions lib/Controller/InternalBookmarkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,13 @@ public function countAllClicks(): DataResponse {
public function countWithClicks(): DataResponse {
return $this->publicController->countWithClicks();
}

/**
* @return JSONResponse
* @throws \OCA\Bookmarks\Exception\UnauthenticatedError
* @NoAdminRequired
*/
public function countDeleted() {
return $this->publicController->countDeleted();
}
}
1 change: 1 addition & 0 deletions lib/Controller/WebViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function index(): AugmentedTemplateResponse {
$this->initialState->provideInitialState($this->appName, 'folders', $this->folderController->getFolders()->getData()['data']);
$this->initialState->provideInitialState($this->appName, 'deletedFolders', $this->folderController->getDeletedFolders()->getData()['data']);
$this->initialState->provideInitialState($this->appName, 'archivedCount', $this->bookmarkController->countArchived()->getData()['item']);
$this->initialState->provideInitialState($this->appName, 'deletedCount', $this->bookmarkController->countDeleted()->getData()['item']);
$this->initialState->provideInitialState($this->appName, 'duplicatedCount', $this->bookmarkController->countDuplicated()->getData()['item']);
$this->initialState->provideInitialState($this->appName, 'unavailableCount', $this->bookmarkController->countUnavailable()->getData()['item']);
$this->initialState->provideInitialState($this->appName, 'allCount', $this->bookmarkController->countBookmarks(-1)->getData()['item']);
Expand Down
11 changes: 9 additions & 2 deletions lib/Db/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
* @method setArchivedFile(int $fileId)
* @method getUserId(): string
* @method setUserId(string $userId)
* @method setUrlHash(string $urlHash)
* @method getUrlHash():string
*/
class Bookmark extends Entity {
protected $url;
Expand All @@ -47,9 +49,10 @@ class Bookmark extends Entity {
protected $archivedFile;
protected $textContent;
protected $htmlContent;
protected $urlHash;

public static $columns = ['id', 'url', 'title', 'description', 'lastmodified', 'added', 'clickcount', 'last_preview', 'available', 'archived_file', 'user_id', 'text_content', 'html_content'];
public static $fields = ['id', 'url', 'title', 'description', 'lastmodified', 'added', 'clickcount', 'lastPreview', 'available', 'archivedFile', 'userId', 'textContent','htmlContent'];
public static $columns = ['id', 'url', 'title', 'description', 'lastmodified', 'added', 'clickcount', 'last_preview', 'available', 'archived_file', 'user_id', 'text_content', 'html_content', 'url_hash'];
public static $fields = ['id', 'url', 'title', 'description', 'lastmodified', 'added', 'clickcount', 'lastPreview', 'available', 'archivedFile', 'userId', 'textContent','htmlContent', 'urlHash'];

public static function fromArray($props): self {
$bookmark = new Bookmark();
Expand All @@ -75,6 +78,7 @@ public function __construct() {
$this->addType('lastPreview', 'integer');
$this->addType('available', 'boolean');
$this->addType('archivedFile', 'integer');
$this->addType('urlHash', 'string');
}

public function toArray(): array {
Expand All @@ -89,6 +93,9 @@ public function toArray(): array {
$array['target'] = $this->url;
continue;
}
if ($field === 'urlHash') {
continue;
}
$array[$field] = $this->{'get' . $field}();
}
return $array;
Expand Down
Loading
Loading