Skip to content

Commit

Permalink
Use $group->getDisplayName() instead of just the GID for the display …
Browse files Browse the repository at this point in the history
…name of "group circles".

Fixes nextcloud#1296.

Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
  • Loading branch information
rotdrop committed May 5, 2023
1 parent f6e9e72 commit de02180
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/Service/FederatedUserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public function setOwnerAsCurrentUser(string $circleId): void {
$probe = new CircleProbe();
$probe->includeSystemCircles()
->includePersonalCircles();

$localCircle = $this->circleRequest->getCircle($circleId, null, $probe);
if ($this->configService->isLocalInstance($localCircle->getInstance())) {
$this->setCurrentUser($localCircle->getOwner());
Expand Down Expand Up @@ -1241,7 +1241,8 @@ public function getGroupCircle(string $groupId): Circle {
$member->setId($this->token(ManagedModel::ID_LENGTH))
->setCircleId($circle->getSingleId())
->setLevel(Member::LEVEL_OWNER)
->setStatus(Member::STATUS_MEMBER);
->setStatus(Member::STATUS_MEMBER)
->setDisplayName($group->getDisplayName());
$circle->setOwner($member)
->setInitiator($member);

Expand All @@ -1250,7 +1251,7 @@ public function getGroupCircle(string $groupId): Circle {
} catch (CircleNotFoundException $e) {
}

$circle->setDisplayName($groupId);
$circle->setDisplayName($group->getDisplayName());

$event = new FederatedEvent(CircleCreate::class);
$event->setCircle($circle);
Expand Down
21 changes: 18 additions & 3 deletions lib/Service/MembersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
use OCA\Circles\Model\GlobalScale\GSEvent;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\IGroupManager;
use OCP\IGroup;

/**
* Class MembersService
Expand All @@ -77,6 +79,9 @@ class MembersService {
/** @var IUserManager */
private $userManager;

/** @var IGroupManager */
private $groupManager;

/** @var ConfigService */
private $configService;

Expand Down Expand Up @@ -113,6 +118,7 @@ class MembersService {
* @param string $userId
* @param IL10N $l10n
* @param IUserManager $userManager
* @param IGroupManager $groupManager
* @param ConfigService $configService
* @param DeprecatedCirclesRequest $circlesRequest
* @param DeprecatedMembersRequest $membersRequest
Expand All @@ -125,7 +131,7 @@ class MembersService {
* @param MiscService $miscService
*/
public function __construct(
$userId, IL10N $l10n, IUserManager $userManager, ConfigService $configService,
$userId, IL10N $l10n, IUserManager $userManager, IGroupManager $groupManager, ConfigService $configService,
DeprecatedCirclesRequest $circlesRequest, DeprecatedMembersRequest $membersRequest,
AccountsRequest $accountsRequest,
FileSharesRequest $fileSharesRequest, TokensRequest $tokensRequest, EventsService $eventsService,
Expand All @@ -135,6 +141,7 @@ public function __construct(
$this->userId = $userId;
$this->l10n = $l10n;
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->configService = $configService;
$this->circlesRequest = $circlesRequest;
$this->membersRequest = $membersRequest;
Expand Down Expand Up @@ -421,8 +428,7 @@ private function verifyIdentContact(&$ident, $type) {
* @throws Exception
*/
private function addGroupMembers(DeprecatedCircle $circle, $groupId): array {
$group = OC::$server->getGroupManager()
->get($groupId);
$group = $this->groupManager->get($groupId);
if ($group === null) {
throw new GroupDoesNotExistException($this->l10n->t('This group does not exist'));
}
Expand Down Expand Up @@ -651,6 +657,15 @@ public function updateCachedName(DeprecatedMember $member, bool $fresh = true) {
$cachedName = $this->getUserDisplayName($member->getUserId(), $fresh);
}

if ($member->getType() === DeprecatedMember::TYPE_GROUP) {
$gid = $member->getUserId();
/** @var IGroup $group */
$group = $this->groupManager->get($gid);
if ($group !== null) {
$cachedName = $group->getDisplayName();
}
}

if ($member->getType() === DeprecatedMember::TYPE_CONTACT) {
$cachedName = $this->miscService->getContactDisplayName($member->getUserId());
}
Expand Down

0 comments on commit de02180

Please sign in to comment.