mirror of https://github.com/sualko/cloud_bbb
parent
2c5ff0dbb7
commit
2c75653329
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 57 57" width="64" height="64"><path d="M7.1 28.5A21.4 21.4 0 0 1 28.5 7.1m10.7 40A21.4 21.4 0 0 1 10 39M39.2 10A21.4 21.4 0 0 1 47 39.2" fill="none" stroke="#fff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><circle cx="28.5" cy="7.1" r="6.5" fill="#fff" /><circle cx="39.2" cy="-10" r="6.5" transform="rotate(90)" fill="#fff" /><circle cx="39.2" cy="-47" r="6.5" transform="rotate(90)" fill="#fff" /></svg>
|
After Width: | Height: | Size: 480 B |
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\BigBlueButton;
|
||||||
|
|
||||||
|
use OCA\BigBlueButton\AppInfo\Application;
|
||||||
|
use OCP\App\IAppManager;
|
||||||
|
|
||||||
|
class CircleHelper {
|
||||||
|
public const LEVEL_NONE = 0;
|
||||||
|
public const LEVEL_MEMBER = 1;
|
||||||
|
public const LEVEL_MODERATOR = 4;
|
||||||
|
public const LEVEL_ADMIN = 8;
|
||||||
|
public const LEVEL_OWNER = 9;
|
||||||
|
|
||||||
|
private $api;
|
||||||
|
|
||||||
|
/** @var Application */
|
||||||
|
private $app;
|
||||||
|
|
||||||
|
/** @var IAppManager */
|
||||||
|
private $appManager;
|
||||||
|
|
||||||
|
private $cache = [];
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
Application $app,
|
||||||
|
IAppManager $appManager
|
||||||
|
) {
|
||||||
|
$this->app = $app;
|
||||||
|
$this->appManager = $appManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isInCircle(string $userId, string $circleId): bool {
|
||||||
|
return \in_array($circleId, $this->getCircleIds($userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCircleIds(string $userId): array {
|
||||||
|
if (!\array_key_exists($userId, $this->cache)) {
|
||||||
|
$this->cache[$userId] = [];
|
||||||
|
|
||||||
|
$api = $this->getCircleAPI();
|
||||||
|
|
||||||
|
if ($api !== false) {
|
||||||
|
$circles = $api->listCircles(\OCA\Circles\Api\v1\Circles::CIRCLES_ALL, '', \OCA\Circles\Api\v1\Circles::LEVEL_MEMBER);
|
||||||
|
|
||||||
|
foreach ($circles as $circle) {
|
||||||
|
$this->cache[$userId][] = $circle->getUniqueId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->cache[$userId];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCircleAPI() {
|
||||||
|
if ($this->api === null) {
|
||||||
|
if ($this->appManager->isEnabledForUser('circles') && class_exists('\OCA\Circles\Api\v1\Circles')) {
|
||||||
|
$container = $this->app->getContainer();
|
||||||
|
$this->api = $container->query(\OCA\Circles\Api\v1\Circles::class);
|
||||||
|
} else {
|
||||||
|
$this->api = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->api;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ namespace OCA\BigBlueButton\Controller;
|
||||||
use OCA\BigBlueButton\Service\RoomService;
|
use OCA\BigBlueButton\Service\RoomService;
|
||||||
use OCA\BigBlueButton\Permission;
|
use OCA\BigBlueButton\Permission;
|
||||||
use OCA\BigBlueButton\Db\Room;
|
use OCA\BigBlueButton\Db\Room;
|
||||||
|
use OCA\BigBlueButton\CircleHelper;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
@ -25,6 +26,9 @@ class RoomController extends Controller {
|
||||||
/** @var Permission */
|
/** @var Permission */
|
||||||
private $permission;
|
private $permission;
|
||||||
|
|
||||||
|
/** @var CircleHelper */
|
||||||
|
private $circleHelper;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $userId;
|
private $userId;
|
||||||
|
|
||||||
|
@ -37,6 +41,7 @@ class RoomController extends Controller {
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
Permission $permission,
|
Permission $permission,
|
||||||
|
CircleHelper $circleHelper,
|
||||||
$userId
|
$userId
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
@ -44,6 +49,7 @@ class RoomController extends Controller {
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->groupManager = $groupManager;
|
$this->groupManager = $groupManager;
|
||||||
$this->permission = $permission;
|
$this->permission = $permission;
|
||||||
|
$this->circleHelper = $circleHelper;
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +59,9 @@ class RoomController extends Controller {
|
||||||
public function index(): DataResponse {
|
public function index(): DataResponse {
|
||||||
$user = $this->userManager->get($this->userId);
|
$user = $this->userManager->get($this->userId);
|
||||||
$groupIds = $this->groupManager->getUserGroupIds($user);
|
$groupIds = $this->groupManager->getUserGroupIds($user);
|
||||||
|
$circleIds = $this->circleHelper->getCircleIds($this->userId);
|
||||||
|
|
||||||
return new DataResponse($this->service->findAll($this->userId, $groupIds));
|
return new DataResponse($this->service->findAll($this->userId, $groupIds, $circleIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace OCA\BigBlueButton\Controller;
|
||||||
use OCA\BigBlueButton\Db\RoomShare;
|
use OCA\BigBlueButton\Db\RoomShare;
|
||||||
use OCA\BigBlueButton\Service\RoomService;
|
use OCA\BigBlueButton\Service\RoomService;
|
||||||
use OCA\BigBlueButton\Service\RoomShareNotFound;
|
use OCA\BigBlueButton\Service\RoomShareNotFound;
|
||||||
|
use OCA\BigBlueButton\CircleHelper;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
@ -26,6 +27,9 @@ class RoomShareController extends Controller {
|
||||||
/** @var RoomService */
|
/** @var RoomService */
|
||||||
private $roomService;
|
private $roomService;
|
||||||
|
|
||||||
|
/** @var CircleHelper */
|
||||||
|
private $circleHelper;
|
||||||
|
|
||||||
use Errors;
|
use Errors;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
@ -34,12 +38,14 @@ class RoomShareController extends Controller {
|
||||||
RoomShareService $service,
|
RoomShareService $service,
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
RoomService $roomService,
|
RoomService $roomService,
|
||||||
|
CircleHelper $circleHelper,
|
||||||
$userId
|
$userId
|
||||||
) {
|
) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->service = $service;
|
$this->service = $service;
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->roomService = $roomService;
|
$this->roomService = $roomService;
|
||||||
|
$this->circleHelper = $circleHelper;
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,17 +64,38 @@ class RoomShareController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$roomShares = $this->service->findAll($roomId);
|
$roomShares = $this->service->findAll($roomId);
|
||||||
|
$shares = [];
|
||||||
|
|
||||||
|
$circleAPI = $this->circleHelper->getCircleAPI();
|
||||||
|
|
||||||
/** @var RoomShare $roomShare */
|
/** @var RoomShare $roomShare */
|
||||||
foreach ($roomShares as $roomShare) {
|
foreach ($roomShares as $roomShare) {
|
||||||
$shareWithUser = $this->userManager->get($roomShare->getShareWith());
|
if ($roomShare->getShareType() === RoomShare::SHARE_TYPE_USER) {
|
||||||
|
$shareWithUser = $this->userManager->get($roomShare->getShareWith());
|
||||||
|
|
||||||
|
if ($shareWithUser === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($shareWithUser !== null) {
|
|
||||||
$roomShare->setShareWithDisplayName($shareWithUser->getDisplayName());
|
$roomShare->setShareWithDisplayName($shareWithUser->getDisplayName());
|
||||||
|
} elseif ($roomShare->getShareType() === RoomShare::SHARE_TYPE_CIRCLE) {
|
||||||
|
if ($circleAPI === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$circle = $circleAPI->detailsCircle($roomShare->getShareWith());
|
||||||
|
|
||||||
|
if ($circle === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$roomShare->setShareWithDisplayName($circle->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$shares[] = $roomShare;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DataResponse($roomShares);
|
return new DataResponse($shares);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@ class RoomMapper extends QBMapper {
|
||||||
/**
|
/**
|
||||||
* @return array<Room>
|
* @return array<Room>
|
||||||
*/
|
*/
|
||||||
public function findAll(string $userId, array $groupIds): array {
|
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
||||||
/* @var $qb IQueryBuilder */
|
/* @var $qb IQueryBuilder */
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
$qb->select('r.*')
|
$qb->select('r.*')
|
||||||
|
@ -63,6 +63,11 @@ class RoomMapper extends QBMapper {
|
||||||
$qb->expr()->eq('s.permission', $qb->createNamedParameter(RoomShare::PERMISSION_ADMIN, IQueryBuilder::PARAM_INT)),
|
$qb->expr()->eq('s.permission', $qb->createNamedParameter(RoomShare::PERMISSION_ADMIN, IQueryBuilder::PARAM_INT)),
|
||||||
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_GROUP, IQueryBuilder::PARAM_INT)),
|
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_GROUP, IQueryBuilder::PARAM_INT)),
|
||||||
$qb->expr()->in('s.share_with', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY))
|
$qb->expr()->in('s.share_with', $qb->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY))
|
||||||
|
),
|
||||||
|
$qb->expr()->andX(
|
||||||
|
$qb->expr()->eq('s.permission', $qb->createNamedParameter(RoomShare::PERMISSION_ADMIN, IQueryBuilder::PARAM_INT)),
|
||||||
|
$qb->expr()->eq('s.share_type', $qb->createNamedParameter(RoomShare::SHARE_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)),
|
||||||
|
$qb->expr()->in('s.share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,6 +5,7 @@ namespace OCA\BigBlueButton\Db;
|
||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
|
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
use OCP\Share\IShare;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method int getRoomId()
|
* @method int getRoomId()
|
||||||
|
@ -24,8 +25,9 @@ class RoomShare extends Entity implements JsonSerializable {
|
||||||
public const PERMISSION_MODERATOR = 1;
|
public const PERMISSION_MODERATOR = 1;
|
||||||
public const PERMISSION_USER = 2;
|
public const PERMISSION_USER = 2;
|
||||||
|
|
||||||
public const SHARE_TYPE_USER = 0;
|
public const SHARE_TYPE_USER = IShare::TYPE_USER;
|
||||||
public const SHARE_TYPE_GROUP = 1;
|
public const SHARE_TYPE_GROUP = IShare::TYPE_GROUP;
|
||||||
|
public const SHARE_TYPE_CIRCLE = IShare::TYPE_CIRCLE;
|
||||||
|
|
||||||
protected $roomId;
|
protected $roomId;
|
||||||
protected $shareType;
|
protected $shareType;
|
||||||
|
|
|
@ -29,18 +29,23 @@ class Permission {
|
||||||
/** @var RoomShareService */
|
/** @var RoomShareService */
|
||||||
private $roomShareService;
|
private $roomShareService;
|
||||||
|
|
||||||
|
/** @var CircleHelper */
|
||||||
|
private $circleHelper;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IUserManager $userManager,
|
IUserManager $userManager,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
RoomService $roomService,
|
RoomService $roomService,
|
||||||
RestrictionService $restrictionService,
|
RestrictionService $restrictionService,
|
||||||
RoomShareService $roomShareService
|
RoomShareService $roomShareService,
|
||||||
|
CircleHelper $circleHelper
|
||||||
) {
|
) {
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
$this->groupManager = $groupManager;
|
$this->groupManager = $groupManager;
|
||||||
$this->roomService = $roomService;
|
$this->roomService = $roomService;
|
||||||
$this->restrictionService = $restrictionService;
|
$this->restrictionService = $restrictionService;
|
||||||
$this->roomShareService = $roomShareService;
|
$this->roomShareService = $roomShareService;
|
||||||
|
$this->circleHelper = $circleHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRestriction(string $uid): Restriction {
|
public function getRestriction(string $uid): Restriction {
|
||||||
|
@ -51,7 +56,7 @@ class Permission {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAllowedToCreateRoom(string $uid) {
|
public function isAllowedToCreateRoom(string $uid) {
|
||||||
$numberOfCreatedRooms = count($this->roomService->findAll($uid, []));
|
$numberOfCreatedRooms = count($this->roomService->findAll($uid, [], []));
|
||||||
$restriction = $this->getRestriction($uid);
|
$restriction = $this->getRestriction($uid);
|
||||||
|
|
||||||
return $restriction->getMaxRooms() < 0 || $restriction->getMaxRooms() > $numberOfCreatedRooms;
|
return $restriction->getMaxRooms() < 0 || $restriction->getMaxRooms() > $numberOfCreatedRooms;
|
||||||
|
@ -104,6 +109,10 @@ class Permission {
|
||||||
if ($this->groupManager->isInGroup($uid, $share->getShareWith())) {
|
if ($this->groupManager->isInGroup($uid, $share->getShareWith())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} elseif ($share->getShareType() === RoomShare::SHARE_TYPE_CIRCLE) {
|
||||||
|
if ($this->circleHelper->isInCircle($uid, $share->getShareWith())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ class RoomService {
|
||||||
$this->mapper = $mapper;
|
$this->mapper = $mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findAll(string $userId, array $groupIds): array {
|
public function findAll(string $userId, array $groupIds, array $circleIds): array {
|
||||||
return $this->mapper->findAll($userId, $groupIds);
|
return $this->mapper->findAll($userId, $groupIds, $circleIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handleException(Exception $e): void {
|
private function handleException(Exception $e): void {
|
||||||
|
|
|
@ -8,4 +8,4 @@ script('bbb', 'manager');
|
||||||
<div id="bbb-warning">
|
<div id="bbb-warning">
|
||||||
<span class="icon icon-error-color icon-visible"></span> <?php p($_['warning']); ?>
|
<span class="icon icon-error-color icon-visible"></span> <?php p($_['warning']); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -80,18 +80,20 @@ class RoomMapperTest extends TestCase {
|
||||||
$foreignRoom2 = $this->insert($this->getRandomString(), $this->getRandomString());
|
$foreignRoom2 = $this->insert($this->getRandomString(), $this->getRandomString());
|
||||||
$foreignRoom3 = $this->insert($this->getRandomString(), $this->getRandomString());
|
$foreignRoom3 = $this->insert($this->getRandomString(), $this->getRandomString());
|
||||||
|
|
||||||
$this->assertCount(1, $this->mapper->findAll($this->userId, []));
|
$this->assertCount(1, $this->mapper->findAll($this->userId, [], []));
|
||||||
|
|
||||||
$shares = [];
|
$shares = [];
|
||||||
$shares[] = $this->insertShare($foreignRoom1->getId(), RoomShare::SHARE_TYPE_USER, $this->userId);
|
$shares[] = $this->insertShare($foreignRoom1->getId(), RoomShare::SHARE_TYPE_USER, $this->userId);
|
||||||
$shares[] = $this->insertShare($foreignRoom1->getId(), RoomShare::SHARE_TYPE_GROUP, 'foo bar');
|
$shares[] = $this->insertShare($foreignRoom1->getId(), RoomShare::SHARE_TYPE_GROUP, 'foo bar');
|
||||||
$shares[] = $this->insertShare($foreignRoom2->getId(), RoomShare::SHARE_TYPE_GROUP, 'foo bar');
|
$shares[] = $this->insertShare($foreignRoom2->getId(), RoomShare::SHARE_TYPE_GROUP, 'foo bar');
|
||||||
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_USER, $this->getRandomString());
|
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_USER, $this->getRandomString());
|
||||||
|
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_CIRCLE, 'c1');
|
||||||
|
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_CIRCLE, 'c2');
|
||||||
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_USER, $this->userId, RoomShare::PERMISSION_MODERATOR);
|
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_USER, $this->userId, RoomShare::PERMISSION_MODERATOR);
|
||||||
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_GROUP, 'foo bar', RoomShare::PERMISSION_USER);
|
$shares[] = $this->insertShare($foreignRoom3->getId(), RoomShare::SHARE_TYPE_GROUP, 'foo bar', RoomShare::PERMISSION_USER);
|
||||||
|
|
||||||
$rooms = $this->mapper->findAll($this->userId, ['foo bar']);
|
$rooms = $this->mapper->findAll($this->userId, ['foo bar'], ['c1']);
|
||||||
$this->assertCount(3, $rooms);
|
$this->assertCount(4, $rooms);
|
||||||
|
|
||||||
$this->mapper->delete($room);
|
$this->mapper->delete($room);
|
||||||
$this->mapper->delete($foreignRoom1);
|
$this->mapper->delete($foreignRoom1);
|
||||||
|
|
|
@ -9,6 +9,7 @@ use OCA\BigBlueButton\Controller\RoomShareController;
|
||||||
use OCA\BigBlueButton\Db\Room;
|
use OCA\BigBlueButton\Db\Room;
|
||||||
use OCA\BigBlueButton\Db\RoomShare;
|
use OCA\BigBlueButton\Db\RoomShare;
|
||||||
use OCA\BigBlueButton\Service\RoomShareService;
|
use OCA\BigBlueButton\Service\RoomShareService;
|
||||||
|
use OCA\BigBlueButton\CircleHelper;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@ class RoomShareControllerTest extends TestCase {
|
||||||
private $request;
|
private $request;
|
||||||
private $service;
|
private $service;
|
||||||
private $roomService;
|
private $roomService;
|
||||||
|
private $circleHelper;
|
||||||
private $userManager;
|
private $userManager;
|
||||||
private $controller;
|
private $controller;
|
||||||
|
|
||||||
|
@ -28,6 +30,7 @@ class RoomShareControllerTest extends TestCase {
|
||||||
$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->roomService = $this->createMock(RoomService::class);
|
$this->roomService = $this->createMock(RoomService::class);
|
||||||
|
$this->circleHelper = $this->createMock(CircleHelper::class);
|
||||||
|
|
||||||
$this->controller = new RoomShareController(
|
$this->controller = new RoomShareController(
|
||||||
'bbb',
|
'bbb',
|
||||||
|
@ -35,6 +38,7 @@ class RoomShareControllerTest extends TestCase {
|
||||||
$this->service,
|
$this->service,
|
||||||
$this->userManager,
|
$this->userManager,
|
||||||
$this->roomService,
|
$this->roomService,
|
||||||
|
$this->circleHelper,
|
||||||
$this->userId
|
$this->userId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use OCA\BigBlueButton\Permission;
|
||||||
use OCA\BigBlueButton\Service\RoomService;
|
use OCA\BigBlueButton\Service\RoomService;
|
||||||
use OCA\BigBlueButton\Service\RoomShareService;
|
use OCA\BigBlueButton\Service\RoomShareService;
|
||||||
use OCA\BigBlueButton\Service\RestrictionService;
|
use OCA\BigBlueButton\Service\RestrictionService;
|
||||||
|
use OCA\BigBlueButton\CircleHelper;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
|
@ -34,6 +35,9 @@ class PermissionTest extends TestCase {
|
||||||
/** @var RestrictionService|MockObject */
|
/** @var RestrictionService|MockObject */
|
||||||
private $restrictionService;
|
private $restrictionService;
|
||||||
|
|
||||||
|
/** @var CircleHelper|MockObject */
|
||||||
|
private $circleHelper;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -52,12 +56,16 @@ class PermissionTest extends TestCase {
|
||||||
/** @var RoomShareService|MockObject */
|
/** @var RoomShareService|MockObject */
|
||||||
$this->roomShareService = $this->createMock(RoomShareService::class);
|
$this->roomShareService = $this->createMock(RoomShareService::class);
|
||||||
|
|
||||||
|
/** @var CircleHelper|MockObject */
|
||||||
|
$this->circleHelper = $this->createMock(CircleHelper::class);
|
||||||
|
|
||||||
$this->permission = new Permission(
|
$this->permission = new Permission(
|
||||||
$this->userManager,
|
$this->userManager,
|
||||||
$this->groupManager,
|
$this->groupManager,
|
||||||
$this->roomService,
|
$this->roomService,
|
||||||
$this->restrictionService,
|
$this->restrictionService,
|
||||||
$this->roomShareService
|
$this->roomShareService,
|
||||||
|
$this->circleHelper
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,12 +104,13 @@ class PermissionTest extends TestCase {
|
||||||
$room = $this->createRoom(1, 'foo');
|
$room = $this->createRoom(1, 'foo');
|
||||||
|
|
||||||
$this->roomShareService
|
$this->roomShareService
|
||||||
->expects($this->exactly(4))
|
->expects($this->exactly(5))
|
||||||
->method('findAll')
|
->method('findAll')
|
||||||
->will($this->returnValueMap([
|
->will($this->returnValueMap([
|
||||||
[1, [
|
[1, [
|
||||||
$this->createRoomShare(RoomShare::SHARE_TYPE_USER, 'user', RoomShare::PERMISSION_ADMIN),
|
$this->createRoomShare(RoomShare::SHARE_TYPE_USER, 'user', RoomShare::PERMISSION_ADMIN),
|
||||||
$this->createRoomShare(RoomShare::SHARE_TYPE_GROUP, 'group', RoomShare::PERMISSION_MODERATOR),
|
$this->createRoomShare(RoomShare::SHARE_TYPE_GROUP, 'group', RoomShare::PERMISSION_MODERATOR),
|
||||||
|
$this->createRoomShare(RoomShare::SHARE_TYPE_CIRCLE, 'circle', RoomShare::PERMISSION_USER),
|
||||||
]],
|
]],
|
||||||
[2, []],
|
[2, []],
|
||||||
]));
|
]));
|
||||||
|
@ -113,6 +122,13 @@ class PermissionTest extends TestCase {
|
||||||
['group_user', 'group', true],
|
['group_user', 'group', true],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
|
$this->circleHelper
|
||||||
|
->method('isInCircle')
|
||||||
|
->will($this->returnValueMap([
|
||||||
|
['bar', 'circle', false],
|
||||||
|
['circle_user', 'circle', true],
|
||||||
|
]));
|
||||||
|
|
||||||
$this->assertFalse($this->permission->isUser($room, null), 'Test guest user');
|
$this->assertFalse($this->permission->isUser($room, null), 'Test guest user');
|
||||||
$this->assertFalse($this->permission->isUser($room, 'bar'), 'Test no matching share');
|
$this->assertFalse($this->permission->isUser($room, 'bar'), 'Test no matching share');
|
||||||
$this->assertFalse($this->permission->isUser($this->createRoom(2, 'foo'), 'bar'), 'Test empty shares');
|
$this->assertFalse($this->permission->isUser($this->createRoom(2, 'foo'), 'bar'), 'Test empty shares');
|
||||||
|
@ -120,6 +136,7 @@ class PermissionTest extends TestCase {
|
||||||
$this->assertTrue($this->permission->isUser($room, 'foo'), 'Test room owner');
|
$this->assertTrue($this->permission->isUser($room, 'foo'), 'Test room owner');
|
||||||
$this->assertTrue($this->permission->isUser($room, 'user'));
|
$this->assertTrue($this->permission->isUser($room, 'user'));
|
||||||
$this->assertTrue($this->permission->isUser($room, 'group_user'));
|
$this->assertTrue($this->permission->isUser($room, 'group_user'));
|
||||||
|
$this->assertTrue($this->permission->isUser($room, 'circle_user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createRoom(int $id, string $userId): Room {
|
private function createRoom(int $id, string $userId): Room {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import axios from '@nextcloud/axios';
|
import axios from '@nextcloud/axios';
|
||||||
|
|
||||||
export enum ShareType { User, Group };
|
export enum ShareType {
|
||||||
|
User = OC.Share.SHARE_TYPE_USER,
|
||||||
|
Group = OC.Share.SHARE_TYPE_GROUP,
|
||||||
|
Circle = OC.Share.SHARE_TYPE_CIRCLE
|
||||||
|
};
|
||||||
|
|
||||||
export enum Permission { Admin, Moderator, User };
|
export enum Permission { Admin, Moderator, User };
|
||||||
|
|
||||||
|
@ -67,6 +71,7 @@ export interface ShareWithOption {
|
||||||
export interface ShareWith {
|
export interface ShareWith {
|
||||||
users: ShareWithOption[];
|
users: ShareWithOption[];
|
||||||
groups: ShareWithOption[];
|
groups: ShareWithOption[];
|
||||||
|
circles: ShareWithOption[];
|
||||||
}
|
}
|
||||||
|
|
||||||
class Api {
|
class Api {
|
||||||
|
@ -228,6 +233,7 @@ class Api {
|
||||||
return {
|
return {
|
||||||
users: response.data.ocs.data.exact.users,
|
users: response.data.ocs.data.exact.users,
|
||||||
groups: response.data.ocs.data.exact.groups,
|
groups: response.data.ocs.data.exact.groups,
|
||||||
|
circles: response.data.ocs.data.exact.circles || [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +254,7 @@ class Api {
|
||||||
return {
|
return {
|
||||||
users: [...data.users, ...data.exact.users],
|
users: [...data.users, ...data.exact.users],
|
||||||
groups: [...data.groups, ...data.exact.groups],
|
groups: [...data.groups, ...data.exact.groups],
|
||||||
|
circles: [...(data.circles || []), ...(data.exact.circles || [])],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ type Props = {
|
||||||
excluded?: {
|
excluded?: {
|
||||||
groupIds?: string[];
|
groupIds?: string[];
|
||||||
userIds?: string[];
|
userIds?: string[];
|
||||||
|
circleIds?: string[];
|
||||||
};
|
};
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +24,7 @@ const ShareSelection: React.FC<Props> = (props) => {
|
||||||
const excluded = {
|
const excluded = {
|
||||||
userIds: props.excluded?.userIds || [],
|
userIds: props.excluded?.userIds || [],
|
||||||
groupIds: props.excluded?.groupIds || [],
|
groupIds: props.excluded?.groupIds || [],
|
||||||
|
circleIds: props.excluded?.circleIds || [],
|
||||||
};
|
};
|
||||||
const placeholder = props.placeholder || t('bbb', 'Name, group, ...');
|
const placeholder = props.placeholder || t('bbb', 'Name, group, ...');
|
||||||
|
|
||||||
|
@ -59,6 +61,7 @@ const ShareSelection: React.FC<Props> = (props) => {
|
||||||
const results = options ? [
|
const results = options ? [
|
||||||
...options.users.filter(user => !excluded.userIds.includes(user.value.shareWith)),
|
...options.users.filter(user => !excluded.userIds.includes(user.value.shareWith)),
|
||||||
...options.groups.filter(group => !excluded.groupIds.includes(group.value.shareWith)),
|
...options.groups.filter(group => !excluded.groupIds.includes(group.value.shareWith)),
|
||||||
|
...options.circles.filter(circle => !excluded.circleIds.includes(circle.value.shareWith)),
|
||||||
] : [];
|
] : [];
|
||||||
|
|
||||||
const renderOption = (option: ShareWithOption) => {
|
const renderOption = (option: ShareWithOption) => {
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
.icon-circle-white {
|
||||||
|
background-size: 50%;
|
||||||
|
background-image: url('../../img/circles.svg');
|
||||||
|
}
|
||||||
|
|
||||||
.bbb-shareWith {
|
.bbb-shareWith {
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
|
|
||||||
|
@ -15,7 +20,8 @@
|
||||||
width: 32px;
|
width: 32px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.icon-group-white {
|
.icon-group-white,
|
||||||
|
.icon-circle-white {
|
||||||
display: block;
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -18,6 +18,7 @@ const ShareWith: React.FC<Props> = ({ room, permission, shares: allShares, setSh
|
||||||
|
|
||||||
const sharedUserIds = shares ? shares.filter(share => share.shareType === ShareType.User).map(share => share.shareWith) : [];
|
const sharedUserIds = shares ? shares.filter(share => share.shareType === ShareType.User).map(share => share.shareWith) : [];
|
||||||
const sharedGroupIds = shares ? shares.filter(share => share.shareType === ShareType.Group).map(share => share.shareWith) : [];
|
const sharedGroupIds = shares ? shares.filter(share => share.shareType === ShareType.Group).map(share => share.shareWith) : [];
|
||||||
|
const sharedCircleIds = shares ? shares.filter(share => share.shareType === ShareType.Circle).map(share => share.shareWith) : [];
|
||||||
|
|
||||||
async function addRoomShare(shareWith: string, shareType: number, displayName: string, permission: Permission) {
|
async function addRoomShare(shareWith: string, shareType: number, displayName: string, permission: Permission) {
|
||||||
const roomShare = await api.createRoomShare(room.id, shareType, shareWith, permission);
|
const roomShare = await api.createRoomShare(room.id, shareType, shareWith, permission);
|
||||||
|
@ -80,6 +81,7 @@ const ShareWith: React.FC<Props> = ({ room, permission, shares: allShares, setSh
|
||||||
<div className="avatardiv">
|
<div className="avatardiv">
|
||||||
{avatarUrl && <img src={avatarUrl} alt={`Avatar from ${displayName}`} />}
|
{avatarUrl && <img src={avatarUrl} alt={`Avatar from ${displayName}`} />}
|
||||||
{share.shareType === ShareType.Group && <span className="icon-group-white"></span>}
|
{share.shareType === ShareType.Group && <span className="icon-group-white"></span>}
|
||||||
|
{share.shareType === ShareType.Circle && <span className="icon-circle-white"></span>}
|
||||||
</div>
|
</div>
|
||||||
<div className="bbb-shareWith__item__label">
|
<div className="bbb-shareWith__item__label">
|
||||||
<h5>{displayName}
|
<h5>{displayName}
|
||||||
|
@ -115,7 +117,8 @@ const ShareWith: React.FC<Props> = ({ room, permission, shares: allShares, setSh
|
||||||
{isOwner ?
|
{isOwner ?
|
||||||
<ShareSelection
|
<ShareSelection
|
||||||
selectShare={(shareOption) => addRoomShare(shareOption.value.shareWith, shareOption.value.shareType, shareOption.label, permission)}
|
selectShare={(shareOption) => addRoomShare(shareOption.value.shareWith, shareOption.value.shareType, shareOption.label, permission)}
|
||||||
excluded={{userIds: sharedUserIds, groupIds: sharedGroupIds}}/> :
|
excluded={{userIds: sharedUserIds, groupIds: sharedGroupIds, circleIds: sharedCircleIds}}
|
||||||
|
shareType={[ShareType.User, ShareType.Group, ShareType.Circle]}/> :
|
||||||
<em>
|
<em>
|
||||||
<span className="icon icon-details icon-visible"></span> {t('bbb', 'You are not allowed to change this option, because this room is shared with you.')}
|
<span className="icon icon-details icon-visible"></span> {t('bbb', 'You are not allowed to change this option, because this room is shared with you.')}
|
||||||
</em>
|
</em>
|
||||||
|
|
|
@ -27,6 +27,7 @@ declare namespace OC {
|
||||||
const SHARE_TYPE_USER = 0;
|
const SHARE_TYPE_USER = 0;
|
||||||
const SHARE_TYPE_GROUP = 1;
|
const SHARE_TYPE_GROUP = 1;
|
||||||
const SHARE_TYPE_LINK = 3;
|
const SHARE_TYPE_LINK = 3;
|
||||||
|
const SHARE_TYPE_CIRCLE = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Plugin<T> {
|
interface Plugin<T> {
|
||||||
|
|
Loading…
Reference in New Issue