fix: bug with name of shared groups

Shared groups were listed with their ID and not their display name
pull/281/head
Sebastien Marinier 2024-08-19 11:23:25 +02:00
parent a8591150de
commit ab314393e9
2 changed files with 18 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IGroupManager;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserManager; use OCP\IUserManager;
@ -24,6 +25,9 @@ class RoomShareController extends Controller {
/** @var IUserManager */ /** @var IUserManager */
private $userManager; private $userManager;
/** @var IGroupManager */
private $groupManager;
/** @var RoomService */ /** @var RoomService */
private $roomService; private $roomService;
@ -37,6 +41,7 @@ class RoomShareController extends Controller {
IRequest $request, IRequest $request,
RoomShareService $service, RoomShareService $service,
IUserManager $userManager, IUserManager $userManager,
IGroupManager $groupManager,
RoomService $roomService, RoomService $roomService,
CircleHelper $circleHelper, CircleHelper $circleHelper,
$userId $userId
@ -44,6 +49,7 @@ class RoomShareController extends Controller {
parent::__construct($appName, $request); parent::__construct($appName, $request);
$this->service = $service; $this->service = $service;
$this->userManager = $userManager; $this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->roomService = $roomService; $this->roomService = $roomService;
$this->circleHelper = $circleHelper; $this->circleHelper = $circleHelper;
$this->userId = $userId; $this->userId = $userId;
@ -90,6 +96,14 @@ class RoomShareController extends Controller {
} }
$roomShare->setShareWithDisplayName($circle->getName()); $roomShare->setShareWithDisplayName($circle->getName());
} elseif ($roomShare->getShareType() === RoomShare::SHARE_TYPE_GROUP) {
$shareWithGroup = $this->groupManager->get($roomShare->getShareWith());
if ($shareWithGroup === null) {
continue;
}
$roomShare->setShareWithDisplayName($shareWithGroup->getDisplayName());
} }
$shares[] = $roomShare; $shares[] = $roomShare;

View File

@ -9,6 +9,7 @@ use OCA\BigBlueButton\Db\RoomShare;
use OCA\BigBlueButton\Service\RoomService; use OCA\BigBlueButton\Service\RoomService;
use OCA\BigBlueButton\Service\RoomShareService; use OCA\BigBlueButton\Service\RoomShareService;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\IGroupManager;
use OCP\IRequest; use OCP\IRequest;
use OCP\IUserManager; use OCP\IUserManager;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -19,6 +20,7 @@ class RoomShareControllerTest extends TestCase {
private $roomService; private $roomService;
private $circleHelper; private $circleHelper;
private $userManager; private $userManager;
private $groupManager;
private $controller; private $controller;
private $userId = 'user_foo'; private $userId = 'user_foo';
@ -29,6 +31,7 @@ class RoomShareControllerTest extends TestCase {
$this->request = $this->createMock(IRequest::class); $this->request = $this->createMock(IRequest::class);
$this->service = $this->createMock(RoomShareService::class); $this->service = $this->createMock(RoomShareService::class);
$this->userManager = $this->createMock(IUserManager::class); $this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->roomService = $this->createMock(RoomService::class); $this->roomService = $this->createMock(RoomService::class);
$this->circleHelper = $this->createMock(CircleHelper::class); $this->circleHelper = $this->createMock(CircleHelper::class);
@ -37,6 +40,7 @@ class RoomShareControllerTest extends TestCase {
$this->request, $this->request,
$this->service, $this->service,
$this->userManager, $this->userManager,
$this->groupManager,
$this->roomService, $this->roomService,
$this->circleHelper, $this->circleHelper,
$this->userId $this->userId