Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
02a6eb4
bug: moved instance name out of l10n to fix issue with instance name …
byt3sage Dec 11, 2024
91a399e
chore: formatting
byt3sage Dec 11, 2024
5321597
Merge branch 'master' into bug/oauth-instance-name-decoding-39956
byt3sage Dec 11, 2024
cfafc3c
chore: reverted language files
byt3sage Dec 13, 2024
4c57f0b
Merge branch 'master' of github.com:byt3sage/server into bug/oauth-in…
byt3sage Dec 13, 2024
8bfe048
Merge branch 'bug/oauth-instance-name-decoding-39956' of github.com:b…
byt3sage Dec 13, 2024
ce6e450
Merge branch 'master' into bug/oauth-instance-name-decoding-39956
byt3sage Dec 13, 2024
4cd8a48
Merge branch 'bug/oauth-instance-name-decoding-39956' of github.com:b…
byt3sage Dec 13, 2024
7a9eb28
Merge branch 'bug/oauth-instance-name-decoding-39956' of github.com:b…
byt3sage Dec 13, 2024
d766b71
chore: formatting
byt3sage Dec 11, 2024
f259cbc
chore: reverted language files
byt3sage Dec 13, 2024
4f8eec1
fix: Fix ServiceWorker scope when Nextcloud installed in subfolder
Koc Dec 6, 2024
6ce16a9
chore(assets): Recompile assets
nextcloud-command Dec 6, 2024
f4993a6
chore: cleanup leftover debug statement
icewind1991 Dec 9, 2024
ab6bd5e
fix(files): throttle favorite with max 5 simultaneous requests
skjnldsv Dec 11, 2024
7d2508a
chore(assets): Recompile assets
nextcloud-command Dec 11, 2024
810a5bc
fix(files_sharing): Correct property enforced property names
nfebe Dec 11, 2024
1ac6a3a
chore(assets): Recompile assets
nextcloud-command Dec 11, 2024
f37a39c
Fix(l10n): Update translations from Transifex
nextcloud-bot Dec 12, 2024
0f464f8
fix(files_sharing): also submit new share on password submit
skjnldsv Dec 12, 2024
9687bb8
chore(assets): Recompile assets
nextcloud-command Dec 12, 2024
1690451
fix(dav): add activity logging for favorites in dav
grnd-alt Oct 24, 2024
9e18dbd
refactor(tags): move favorite event dispatching to tags.php
grnd-alt Nov 18, 2024
0443c66
fix(tests): remove redundant unit test for activity
grnd-alt Dec 3, 2024
931eb36
fix(files_sharing): Do not wrap password policy exception into a gene…
come-nc Nov 19, 2024
a230b74
fix(shares): Wrap exceptions from password validation to set code to 400
come-nc Dec 10, 2024
fe8c429
fix(tests): Adapt ManagerTest to change in Exception class used
come-nc Dec 10, 2024
4db03fc
fix: don't recalculate folder size in Cache::delete if the entry didn…
icewind1991 Aug 20, 2024
01bb204
feat(files): Right-align list actions
Pytal Dec 11, 2024
699abbb
feat(trashbin): Allow emptying trash
Pytal Dec 11, 2024
2eb7c31
fix(files_trashbin): update @nextcloud/files and adjust api + l10n fix
skjnldsv Dec 12, 2024
affe220
fix(files): protect filelist actions with try...catch
skjnldsv Dec 12, 2024
8f01172
feat(files_trashbin): add cypress tests
skjnldsv Dec 12, 2024
89d71d7
perf(files_trashbin): use empty trashbin endpoint instead of batch de…
skjnldsv Dec 12, 2024
6790fe7
feat(files_trashbin): improve wordings
skjnldsv Dec 12, 2024
c77f57f
fix(trashbin): Fix infinitely loading empty trash action on close
Pytal Dec 12, 2024
b73b62c
chore: compile assets
Pytal Dec 12, 2024
53905e7
chore(psalm): Update baseline
Pytal Dec 12, 2024
a6e54da
fix: handle calling select on partitioned queries with an array of co…
icewind1991 Dec 12, 2024
0a58000
fix: improve logic for ensuring join columns are selected for partiti…
icewind1991 Dec 12, 2024
a37e715
feat(dashboard): wish happy birthday
kesselb Dec 9, 2024
ab6e5b0
chore(deps): bump nanoid from 3.3.7 to 3.3.8
dependabot[bot] Dec 12, 2024
9eb8ab4
chore(assets): Recompile assets
nextcloud-command Dec 12, 2024
0c49e36
Fix(l10n): Update translations from Transifex
nextcloud-bot Dec 13, 2024
77ca4f5
Merge branch 'bug/oauth-instance-name-decoding-39956' of github.com:b…
byt3sage Dec 13, 2024
c9ffff9
Merge branch 'master' into bug/oauth-instance-name-decoding-39956
byt3sage Dec 13, 2024
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
Prev Previous commit
Next Next commit
refactor(tags): move favorite event dispatching to tags.php
Signed-off-by: grnd-alt <[email protected]>
Signed-off-by: byt3sage <[email protected]>
  • Loading branch information
grnd-alt authored and byt3sage committed Dec 13, 2024
commit 9e18dbd74cd38e479172f67b8a488612eeca33f7
4 changes: 0 additions & 4 deletions apps/dav/lib/Connector/Sabre/TagsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
*
*/
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\NodeAddedToFavorite;
use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\ITagManager;
use OCP\ITags;
use OCP\IUserSession;
Expand Down Expand Up @@ -260,10 +258,8 @@ public function handleUpdateProperties($path, PropPatch $propPatch) {
$propPatch->handle(self::FAVORITE_PROPERTYNAME, function ($favState) use ($node, $path) {
if ((int)$favState === 1 || $favState === 'true') {
$this->getTagger()->tagAs($node->getId(), self::TAG_FAVORITE);
$this->eventDispatcher->dispatchTyped(new NodeAddedToFavorite($this->userSession->getUser(), $node->getId(), $path));
} else {
$this->getTagger()->unTag($node->getId(), self::TAG_FAVORITE);
$this->eventDispatcher->dispatchTyped(new NodeRemovedFromFavorite($this->userSession->getUser(), $node->getId(), $path));
}

if (is_null($favState)) {
Expand Down
2 changes: 0 additions & 2 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Collaboration\Reference\RenderReferenceEvent;
use OCP\Collaboration\Resources\IProviderManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Cache\CacheEntryRemovedEvent;
use OCP\Files\Events\Node\BeforeNodeCopiedEvent;
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
Expand Down Expand Up @@ -100,7 +99,6 @@ public function register(IRegistrationContext $context): void {
$c->get(IActivityManager::class),
$c->get(ITagManager::class)->load(self::APP_ID),
$server->getUserFolder(),
$c->get(IEventDispatcher::class),
);
});

Expand Down
10 changes: 0 additions & 10 deletions apps/files/lib/Service/TagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
namespace OCA\Files\Service;

use OCP\Activity\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\NodeAddedToFavorite;
use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
use OCP\ITags;
Expand All @@ -26,7 +23,6 @@ public function __construct(
private IManager $activityManager,
private ?ITags $tagger,
private ?Folder $homeFolder,
private IEventDispatcher $dispatcher,
) {
}

Expand Down Expand Up @@ -58,16 +54,10 @@ public function updateFileTags($path, $tags) {

$newTags = array_diff($tags, $currentTags);
foreach ($newTags as $tag) {
if ($tag === ITags::TAG_FAVORITE) {
$this->dispatcher->dispatchTyped(new NodeAddedToFavorite($this->userSession->getUser(), $fileId, $path));
}
$this->tagger->tagAs($fileId, $tag);
}
$deletedTags = array_diff($currentTags, $tags);
foreach ($deletedTags as $tag) {
if ($tag === ITags::TAG_FAVORITE) {
$this->dispatcher->dispatchTyped(new NodeRemovedFromFavorite($this->userSession->getUser(), $fileId, $path));
}
$this->tagger->unTag($fileId, $tag);
}

Expand Down
1 change: 0 additions & 1 deletion apps/files/tests/Service/TagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ protected function getTagService(array $methods = []) {
$this->activityManager,
$this->tagger,
$this->root,
$this->dispatcher,
])
->setMethods($methods)
->getMock();
Expand Down
19 changes: 9 additions & 10 deletions lib/private/TagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCP\Db\Exception as DBException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\EventDispatcher\IEventListener;
use OCP\IDBConnection;
use OCP\ITagManager;
Expand All @@ -23,16 +24,14 @@
* @template-implements IEventListener<UserDeletedEvent>
*/
class TagManager implements ITagManager, IEventListener {
private TagMapper $mapper;
private IUserSession $userSession;
private IDBConnection $connection;
private LoggerInterface $logger;

public function __construct(TagMapper $mapper, IUserSession $userSession, IDBConnection $connection, LoggerInterface $logger) {
$this->mapper = $mapper;
$this->userSession = $userSession;
$this->connection = $connection;
$this->logger = $logger;
public function __construct(
private TagMapper $mapper,
private IUserSession $userSession,
private IDBConnection $connection,
private LoggerInterface $logger,
private IEventDispatcher $dispatcher,
) {
}

/**
Expand All @@ -57,7 +56,7 @@ public function load($type, $defaultTags = [], $includeShared = false, $userId =
}
$userId = $this->userSession->getUser()->getUId();
}
return new Tags($this->mapper, $userId, $type, $this->logger, $this->connection, $defaultTags);
return new Tags($this->mapper, $userId, $type, $this->logger, $this->connection, $this->dispatcher, $this->userSession, $defaultTags);
}

/**
Expand Down
39 changes: 22 additions & 17 deletions lib/private/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
use OC\Tagging\TagMapper;
use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\NodeAddedToFavorite;
use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\IDBConnection;
use OCP\ITags;
use OCP\IUserSession;
use OCP\Share_Backend;
use Psr\Log\LoggerInterface;

Expand All @@ -21,10 +25,6 @@ class Tags implements ITags {
* Used for storing objectid/categoryname pairs while rescanning.
*/
private static array $relations = [];
private string $type;
private string $user;
private IDBConnection $db;
private LoggerInterface $logger;
private array $tags = [];

/**
Expand All @@ -38,11 +38,6 @@ class Tags implements ITags {
*/
private array $owners = [];

/**
* The Mapper we are using to communicate our Tag objects to the database.
*/
private TagMapper $mapper;

/**
* The sharing backend for objects of $this->type. Required if
* $this->includeShared === true to determine ownership of items.
Expand All @@ -62,14 +57,18 @@ class Tags implements ITags {
*
* since 20.0.0 $includeShared isn't used anymore
*/
public function __construct(TagMapper $mapper, string $user, string $type, LoggerInterface $logger, IDBConnection $connection, array $defaultTags = []) {
$this->mapper = $mapper;
$this->user = $user;
$this->type = $type;
public function __construct(
private TagMapper $mapper,
private string $user,
private string $type,
private LoggerInterface $logger,
private IDBConnection $db,
private IEventDispatcher $dispatcher,
private IUserSession $userSession,
array $defaultTags = [],
) {
$this->owners = [$this->user];
$this->tags = $this->mapper->loadTags($this->owners, $this->type);
$this->db = $connection;
$this->logger = $logger;

if (count($defaultTags) > 0 && count($this->tags) === 0) {
$this->addMultiple($defaultTags, true);
Expand Down Expand Up @@ -502,7 +501,7 @@ public function removeFromFavorites($objid) {
* @param string $tag The id or name of the tag
* @return boolean Returns false on error.
*/
public function tagAs($objid, $tag) {
public function tagAs($objid, $tag, string $path = '') {
if (is_string($tag) && !is_numeric($tag)) {
$tag = trim($tag);
if ($tag === '') {
Expand Down Expand Up @@ -532,6 +531,9 @@ public function tagAs($objid, $tag) {
]);
return false;
}
if ($tag === ITags::TAG_FAVORITE) {
$this->dispatcher->dispatchTyped(new NodeAddedToFavorite($this->userSession->getUser(), $objid, $path));
}
return true;
}

Expand All @@ -542,7 +544,7 @@ public function tagAs($objid, $tag) {
* @param string $tag The id or name of the tag
* @return boolean
*/
public function unTag($objid, $tag) {
public function unTag($objid, $tag, string $path = '') {
if (is_string($tag) && !is_numeric($tag)) {
$tag = trim($tag);
if ($tag === '') {
Expand All @@ -569,6 +571,9 @@ public function unTag($objid, $tag) {
]);
return false;
}
if ($tag === ITags::TAG_FAVORITE) {
$this->dispatcher->dispatchTyped(new NodeRemovedFromFavorite($this->userSession->getUser(), $objid, $path));
}
return true;
}

Expand Down
5 changes: 3 additions & 2 deletions tests/lib/TagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Test;

use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
use OCP\IUser;
use OCP\IUserSession;
Expand Down Expand Up @@ -48,7 +49,7 @@ protected function setUp(): void {

$this->objectType = $this->getUniqueID('type_');
$this->tagMapper = new \OC\Tagging\TagMapper(\OC::$server->get(IDBConnection::class));
$this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession, \OC::$server->get(IDBConnection::class), \OC::$server->get(LoggerInterface::class));
$this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession, \OC::$server->get(IDBConnection::class), \OC::$server->get(LoggerInterface::class), \OC::$server->get(IEventDispatcher::class));
}

protected function tearDown(): void {
Expand All @@ -65,7 +66,7 @@ public function testTagManagerWithoutUserReturnsNull(): void {
->expects($this->any())
->method('getUser')
->willReturn(null);
$this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession, \OC::$server->getDatabaseConnection(), \OC::$server->get(LoggerInterface::class));
$this->tagMgr = new \OC\TagManager($this->tagMapper, $this->userSession, \OC::$server->getDatabaseConnection(), \OC::$server->get(LoggerInterface::class), \OC::$server->get(IEventDispatcher::class));
$this->assertNull($this->tagMgr->load($this->objectType));
}

Expand Down