Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use $group->getDisplayName() instead of just the GID for the display … #1297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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
22 changes: 18 additions & 4 deletions lib/Service/MembersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use OCA\Circles\Tools\Traits\TNCRequest;
use OCA\Circles\Tools\Traits\TArrayTools;
use Exception;
use OC;
use OC\User\NoUserException;
use OCA\Circles\Circles\FileSharingBroadcaster;
use OCA\Circles\Db\AccountsRequest;
Expand All @@ -56,6 +55,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 +78,9 @@ class MembersService {
/** @var IUserManager */
private $userManager;

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

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

Expand Down Expand Up @@ -113,6 +117,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 +130,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 +140,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 +427,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 +656,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