Skip to content

Commit

Permalink
Merge branch 'stable25' into backport/25/1293-stable25
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl authored Jul 12, 2023
2 parents c64bba3 + e8003ee commit 14a7c57
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 2 additions & 0 deletions lib/CirclesQueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public function limitToInheritedMembers(
[CoreQueryBuilder::HELPER],
[
'getData' => $fullDetails,
'filterPersonalCircles' => true,
'includePersonalCircles' => true,
'minimumLevel' => Member::LEVEL_MEMBER
]
);
Expand Down
4 changes: 2 additions & 2 deletions lib/Command/CirclesMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ protected function configure() {
'clean-shares', '', InputOption::VALUE_NONE, 'remove Circles\' shares'
)
->addOption(
'uninstall', '', InputOption::VALUE_NONE,
'Uninstall the apps and everything related to the app from the database'
'uninstall', '', InputOption::VALUE_NONE,
'Uninstall the apps and everything related to the app from the database'
)
->addOption('force-refresh', '', InputOption::VALUE_NONE, 'enforce some refresh');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/CoreQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ function (string $alias) use ($orXLevelCheck, $minimumLevel) {
$orXLevelCheck->add(
$this->expr()->gte(
$alias . '.level',
$this->createNamedParameter($minimumLevel)
$this->createNamedParameter($minimumLevel, self::PARAM_INT)
)
);
},
Expand Down
32 changes: 19 additions & 13 deletions lib/Service/FederatedUserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,22 @@ public function getFederatedMember(string $userId, int $level = Member::LEVEL_ME
* @throws RequestBuilderException
*/
public function getFederatedUser(string $federatedId, int $type = Member::TYPE_SINGLE): FederatedUser {
// if type=user, we check that handle@domain is not an actual local user
if ($type === Member::TYPE_USER) {
try {
return $this->getLocalFederatedUser($federatedId);
} catch (Exception $e) {
// first testing federatedId string as a whole;
try {
switch ($type) {
case Member::TYPE_USER:
return $this->getLocalFederatedUser($federatedId);
case Member::TYPE_GROUP:
return $this->getFederatedUser_Group($federatedId);
case Member::TYPE_MAIL:
return $this->getFederatedUser_Mail($federatedId);
case Member::TYPE_CONTACT:
return $this->getFederatedUser_Contact($federatedId);
}
} catch (Exception $e) {
}

// then if nothing found, extract remote instance from string
[$singleId, $instance] = $this->extractIdAndInstance($federatedId);

switch ($type) {
Expand All @@ -739,10 +747,6 @@ public function getFederatedUser(string $federatedId, int $type = Member::TYPE_S
return $this->getFederatedUser_User($singleId, $instance);
case Member::TYPE_GROUP:
return $this->getFederatedUser_Group($singleId, $instance);
case Member::TYPE_MAIL:
return $this->getFederatedUser_Mail($federatedId);
case Member::TYPE_CONTACT:
return $this->getFederatedUser_Contact($federatedId);
}

throw new UserTypeNotFoundException();
Expand Down Expand Up @@ -879,14 +883,14 @@ private function getFederatedUser_User(string $userId, string $instance): Federa
* @throws UnknownRemoteException
* @throws RequestBuilderException
*/
public function getFederatedUser_Group(string $groupName, string $instance): FederatedUser {
public function getFederatedUser_Group(string $groupName, string $instance = ''): FederatedUser {
if ($this->configService->isLocalInstance($instance)) {
$circle = $this->getGroupCircle($groupName);
$federatedGroup = new FederatedUser();

return $federatedGroup->importFromCircle($circle);
} else {
// TODO: implement remote groups
throw new FederatedUserNotFoundException('remote group not supported yet. Use singleId');
}
}

Expand Down Expand Up @@ -948,11 +952,13 @@ public function getFederatedUser_Contact(string $contactPath): FederatedUser {
*/
public function extractIdAndInstance(string $federatedId): array {
$federatedId = trim($federatedId, '@');
if (strrpos($federatedId, '@') === false) {
$pos = strrpos($federatedId, '@');
if ($pos === false) {
$userId = $federatedId;
$instance = $this->interfaceService->getLocalInstance();
} else {
[$userId, $instance] = explode('@', $federatedId);
$userId = substr($federatedId, 0, $pos);
$instance = substr($federatedId, $pos + 1);
}

return [$userId, $instance];
Expand Down

0 comments on commit 14a7c57

Please sign in to comment.