diff options
author | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2024-11-29 15:33:40 +0100 |
---|---|---|
committer | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2024-12-20 09:16:18 +0100 |
commit | a14a5985cd29b6cff0afac148c026633a5705479 (patch) | |
tree | 578cfa221b57ba9ba47f004cd7dcf09e58b62486 | |
parent | 1c292571499968f73da650f7d460b6fb94d80716 (diff) | |
download | nextcloud-server-a14a5985cd29b6cff0afac148c026633a5705479.tar.gz nextcloud-server-a14a5985cd29b6cff0afac148c026633a5705479.zip |
chore(systemtags): pre-compute user authorizationsfeat/dav-pagination
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
-rw-r--r-- | apps/dav/lib/SystemTag/SystemTagList.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/dav/lib/SystemTag/SystemTagList.php b/apps/dav/lib/SystemTag/SystemTagList.php index 087c84fabd9..63e69db0eda 100644 --- a/apps/dav/lib/SystemTag/SystemTagList.php +++ b/apps/dav/lib/SystemTag/SystemTagList.php @@ -19,18 +19,20 @@ use Sabre\Xml\Writer; */ class SystemTagList implements Element { public const NS_NEXTCLOUD = 'http://nextcloud.org/ns'; + private array $canAssignTagMap = []; /** * @param ISystemTag[] $tags */ public function __construct( private array $tags, - private ISystemTagManager $tagManager, - private ?IUser $user, + ISystemTagManager $tagManager, + ?IUser $user, ) { $this->tags = $tags; - $this->tagManager = $tagManager; - $this->user = $user; + foreach ($this->tags as $tag) { + $this->canAssignTagMap[$tag->getId()] = $tagManager->canUserAssignTag($tag, $user); + } } /** @@ -48,7 +50,7 @@ class SystemTagList implements Element { foreach ($this->tags as $tag) { $writer->startElement('{' . self::NS_NEXTCLOUD . '}system-tag'); $writer->writeAttributes([ - SystemTagPlugin::CANASSIGN_PROPERTYNAME => $this->tagManager->canUserAssignTag($tag, $this->user) ? 'true' : 'false', + SystemTagPlugin::CANASSIGN_PROPERTYNAME => $this->canAssignTagMap[$tag->getId()] ? 'true' : 'false', SystemTagPlugin::ID_PROPERTYNAME => $tag->getId(), SystemTagPlugin::USERASSIGNABLE_PROPERTYNAME => $tag->isUserAssignable() ? 'true' : 'false', SystemTagPlugin::USERVISIBLE_PROPERTYNAME => $tag->isUserVisible() ? 'true' : 'false', |