Skip to content

Commit

Permalink
Merge pull request #1018 from arawa/fix/move-added-groups-key-in-backend
Browse files Browse the repository at this point in the history
Move the added_groups key on the backend side
  • Loading branch information
smarinier authored Jun 14, 2024
2 parents 8e73cf5 + 28aa5db commit 1e47921
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,30 @@

namespace OCA\Workspace\Controller;

use OCP\IRequest;
use OCP\IUserManager;
use OCP\IGroupManager;
use OCP\AppFramework\Http;
use OCA\Workspace\Db\Space;
use Psr\Log\LoggerInterface;
use OCP\AppFramework\Controller;
use OCA\Workspace\Db\SpaceMapper;
use OCA\Workspace\Exceptions\BadRequestException;
use OCA\Workspace\Exceptions\CreateGroupException;
use OCA\Workspace\Exceptions\CreateWorkspaceException;
use OCA\Workspace\Exceptions\WorkspaceNameExistException;
use OCA\Workspace\Folder\RootFolder;
use OCA\Workspace\Service\UserService;
use OCA\Workspace\Service\SpaceService;
use OCP\AppFramework\Http\JSONResponse;
use OCA\Workspace\Service\Group\UserGroup;
use OCA\Workspace\Helper\GroupfolderHelper;
use OCA\Workspace\Service\WorkspaceService;
use OCA\Workspace\Service\Group\GroupFormatter;
use OCA\Workspace\Exceptions\BadRequestException;
use OCA\Workspace\Exceptions\CreateGroupException;
use OCA\Workspace\Service\Group\ManagersWorkspace;
use OCA\Workspace\Service\Group\UserGroup;
use OCA\Workspace\Exceptions\CreateWorkspaceException;
use OCA\Workspace\Service\Group\WorkspaceManagerGroup;
use OCA\Workspace\Service\SpaceService;
use OCA\Workspace\Service\UserService;
use OCA\Workspace\Service\Group\ConnectedGroupsService;
use OCA\Workspace\Exceptions\WorkspaceNameExistException;
use OCA\Workspace\Service\Workspace\WorkspaceCheckService;
use OCA\Workspace\Service\WorkspaceService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IGroupManager;
use OCP\IRequest;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;

class WorkspaceController extends Controller {
public function __construct(
Expand All @@ -60,6 +61,7 @@ public function __construct(
private SpaceMapper $spaceMapper,
private SpaceService $spaceService,
private UserService $userService,
private ConnectedGroupsService $connectedGroups,
private WorkspaceCheckService $workspaceCheck,
private WorkspaceService $workspaceService,
private UserGroup $userGroup,
Expand Down Expand Up @@ -197,7 +199,16 @@ public function findAll(): JSONResponse {
$gids = array_keys($space['groups']);
$groups = array_map(fn ($gid) => $this->groupManager->get($gid), $gids);

$addedGroups = [];
foreach(array_keys($workspace['groups']) as $gid) {
$addedToGroup = $this->connectedGroups->getConnectedGroupsToSpaceGroup($gid);
if ($addedToGroup !== null) {
$addedGroups = array_merge($addedGroups, $addedToGroup);
}
}

$space['groups'] = GroupFormatter::formatGroups($groups);
$space['added_groups'] = GroupFormatter::formatGroups($addedGroups);
$space['users'] = $this->workspaceService->addUsersInfo($space);

$spaces[] = $space;
Expand Down

0 comments on commit 1e47921

Please sign in to comment.