Skip to content
Closed
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
24 changes: 16 additions & 8 deletions lib/Db/BoardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function findAllByUser(string $userId, ?int $limit = null, ?int $offset =
// FIXME this used to be a UNION to get boards owned by $userId and the user shares in one single query
// Is it possible with the query builder?
$qb = $this->db->getQueryBuilder();
$qb->select('id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
// this does not work in MySQL/PostgreSQL
//->selectAlias('0', 'shared')
->from('deck_boards', 'b')
Expand Down Expand Up @@ -247,7 +247,7 @@ public function findAllByUser(string $userId, ?int $limit = null, ?int $offset =

// shared with user
$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
//->selectAlias('1', 'shared')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
Expand Down Expand Up @@ -329,7 +329,7 @@ public function findAllByGroups(string $userId, array $groups, ?int $limit = nul
return [];
}
$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
//->selectAlias('2', 'shared')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
Expand Down Expand Up @@ -385,7 +385,7 @@ public function findAllByCircles(string $userId, ?int $limit = null, ?int $offse
}

$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
//->selectAlias('2', 'shared')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
Expand Down Expand Up @@ -435,7 +435,7 @@ public function findAllByCircles(string $userId, ?int $limit = null, ?int $offse

public function findAllByTeam(string $teamId): array {
$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
->where($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)))
Expand Down Expand Up @@ -463,7 +463,7 @@ public function findTeamsForBoard(int $boardId): array {

public function isSharedWithTeam(int $boardId, string $teamId): bool {
$qb = $this->db->getQueryBuilder();
$qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('b.id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
->from('deck_boards', 'b')
->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
->where($qb->expr()->eq('b.id', $qb->createNamedParameter($boardId, IQueryBuilder::PARAM_INT)))
Expand All @@ -487,7 +487,7 @@ public function findAll(): array {

public function findToDelete(int $timeLimit) {
$qb = $this->db->getQueryBuilder();
$qb->select('id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
$qb->select('id', 'title', 'owner', 'team_id', 'color', 'archived', 'deleted_at', 'last_modified', 'external_id', 'share_token')
->from('deck_boards')
->where($qb->expr()->gt('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->lt('deleted_at', $qb->createNamedParameter($timeLimit, IQueryBuilder::PARAM_INT)));
Expand Down Expand Up @@ -570,8 +570,16 @@ public function mapAcl(Acl &$acl): void {
public function mapOwner(Board &$board) {
$userManager = $this->userManager;
$cloudIdManager = $this->cloudIdManager;
$circlesService = $this->circlesService;
$externalId = $board->getExternalId();
$board->resolveRelation('owner', function ($owner) use (&$userManager, &$cloudIdManager, $externalId) {
$teamId = $board->getTeamId();
$board->resolveRelation('owner', function ($owner) use (&$userManager, &$cloudIdManager, &$circlesService, $externalId, $teamId) {
if ($teamId !== null && $teamId !== '' && $circlesService->isCirclesEnabled()) {
$circle = $circlesService->getCircle($teamId);
if ($circle !== null) {
return new TeamOwner($owner, $circle);
}
}
if ($externalId !== null) {
$cloudId = $cloudIdManager->resolveCloudId($owner);
return new FederatedUser($cloudId);
Expand Down
34 changes: 34 additions & 0 deletions lib/Db/TeamOwner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Deck\Db;

use OCA\Circles\Model\Circle;

/**
* Keeps the real user id as primary key and exposing the team display name in API responses.
*/
class TeamOwner extends RelationalObject {

/** @var Circle */
protected $object;

public function __construct(string $ownerUserId, Circle $circle) {
parent::__construct($ownerUserId, $circle);
}

public function getObjectSerialization(): array {
return [
'uid' => $this->getPrimaryKey(),
'displayname' => $this->object->getDisplayName(),
'type' => Acl::PERMISSION_TYPE_CIRCLE,
'teamId' => $this->object->getSingleId(),
];
}
}
7 changes: 6 additions & 1 deletion src/components/board/SharingTabSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
<ul id="shareWithList"
class="shareWithList">
<li>
<NcAvatar :user="board.owner.uid" />
<div v-if="isTeamOwnedBoard" class="avatardiv icon icon-circles" />
<NcAvatar v-else :user="board.owner.uid" />
<span class="username">
{{ board.owner.displayname }}
<span v-if="isTeamOwnedBoard">{{ t('deck', '(Team)') }}</span>
<span class="board-owner-label">
{{ t('deck', 'Board owner') }}
</span>
Expand Down Expand Up @@ -135,6 +137,9 @@ export default {
isCurrentUser() {
return (uid) => uid === getCurrentUser().uid
},
isTeamOwnedBoard() {
return this.board?.owner?.type === 7 || !!this.board?.teamId
},
formatedSharees() {
const result = this.unallocatedSharees.map(item => {
const res = {
Expand Down
7 changes: 6 additions & 1 deletion src/components/boards/BoardItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
{{ board.title }}
</div>
<div class="board-list-avatars-cell" title="">
<NcAvatar :user="board.owner.uid"
<div v-if="isTeamOwnedBoard" class="avatardiv icon icon-circles board-list-avatar" />
<NcAvatar v-else
:user="board.owner.uid"
:display-name="board.owner.displayname"
class="board-list-avatar"
:hide-status="true" />
Expand Down Expand Up @@ -53,6 +55,9 @@ export default {
params: { id: this.board.id },
}
},
isTeamOwnedBoard() {
return this.board?.owner?.type === 7 || !!this.board?.teamId
},
limitedAcl() {
return [...this.board.acl].splice(0, 5)
},
Expand Down
7 changes: 6 additions & 1 deletion src/views/BoardReferenceWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
</div>
<div class="line">
{{ t('deck', 'Owner') + ': ' }}
<NcUserBubble :user="boardOwnerUserId"
<span v-if="isTeamOwnedBoard">{{ boardOwnerDisplayName }}</span>
<NcUserBubble v-else
:user="boardOwnerUserId"
:display-name="boardOwnerDisplayName" />
</div>
</div>
Expand Down Expand Up @@ -95,6 +97,9 @@ export default {
boardOwnerDisplayName() {
return this.board.owner?.displayname ?? this.boardOwnerUserId
},
isTeamOwnedBoard() {
return this.board?.owner?.type === 7 || !!this.board?.teamId
},
},

created() {
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/Db/TeamOwnerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Deck\Db;

use OCA\Circles\Model\Circle;
use PHPUnit\Framework\TestCase;

class TeamOwnerTest extends TestCase {
public function testJsonSerializeUsesTeamDisplayNameAndKeepsUserId(): void {
if (!class_exists(Circle::class)) {
$this->markTestSkipped('Circles app is not available');
}

$circle = $this->createMock(Circle::class);
$circle->method('getDisplayName')->willReturn('toasted');
$circle->method('getSingleId')->willReturn('team-single-id');

$owner = new TeamOwner('user1', $circle);

$this->assertEquals([
'primaryKey' => 'user1',
'uid' => 'user1',
'displayname' => 'team board',
'type' => Acl::PERMISSION_TYPE_CIRCLE,
'teamId' => 'team-single-id',
], $owner->jsonSerialize());
}
}
Loading