fix: Fix types for sharingDisabledForUser

and use the non-deprecated version whenever possible

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2025-04-07 17:36:24 +02:00
parent 943bb775d9
commit 59edcdc537
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
5 changed files with 12 additions and 18 deletions

View file

@ -1967,7 +1967,7 @@ class Manager implements IManager {
/**
* Check if sharing is disabled for the current user
*/
public function sharingDisabledForUser(string $userId): bool {
public function sharingDisabledForUser(?string $userId): bool {
return $this->shareDisableChecker->sharingDisabledForUser($userId);
}

View file

@ -25,12 +25,7 @@ class ShareDisableChecker {
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
}
/**
* @param ?string $userId
* @return bool
*/
public function sharingDisabledForUser(?string $userId) {
public function sharingDisabledForUser(?string $userId): bool {
if ($userId === null) {
return false;
}

View file

@ -30,6 +30,7 @@ use OCP\ILogger;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Server;
use OCP\ServerVersion;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\Share\IManager as IShareManager;
@ -161,6 +162,8 @@ class JSConfigHelper {
'enable_non-accessible_features' => $this->config->getSystemValueBool('enable_non-accessible_features', true),
];
$shareManager = Server::get(IShareManager::class);
$array = [
'_oc_debug' => $this->config->getSystemValue('debug', false) ? 'true' : 'false',
'_oc_isadmin' => $uid !== null && $this->groupManager->isAdmin($uid) ? 'true' : 'false',
@ -235,11 +238,11 @@ class JSConfigHelper {
'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
'enforcePasswordForPublicLink' => Util::isPublicLinkPasswordRequired(),
'enableLinkPasswordByDefault' => $enableLinkPasswordByDefault,
'sharingDisabledForUser' => Util::isSharingDisabledForUser(),
'sharingDisabledForUser' => $shareManager->sharingDisabledForUser($uid),
'resharingAllowed' => Share::isResharingAllowed(),
'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
'federatedCloudShareDoc' => $this->urlGenerator->linkToDocs('user-sharing-federated'),
'allowGroupSharing' => \OC::$server->get(IShareManager::class)->allowGroupSharing(),
'allowGroupSharing' => $shareManager->allowGroupSharing(),
'defaultInternalExpireDateEnabled' => $defaultInternalExpireDateEnabled,
'defaultInternalExpireDate' => $defaultInternalExpireDate,
'defaultInternalExpireDateEnforced' => $defaultInternalExpireDateEnforced,

View file

@ -485,10 +485,9 @@ interface IManager {
/**
* Check if sharing is disabled for the given user
*
* @return bool
* @since 9.0.0
*/
public function sharingDisabledForUser(string $userId);
public function sharingDisabledForUser(?string $userId): bool;
/**
* Check if outgoing server2server shares are allowed

View file

@ -78,19 +78,16 @@ class Util {
*
* @return boolean
* @since 7.0.0
* @deprecated 9.1.0 Use \OC::$server->get(\OCP\Share\IManager::class)->sharingDisabledForUser
* @deprecated 9.1.0 Use Server::get(\OCP\Share\IManager::class)->sharingDisabledForUser
*/
public static function isSharingDisabledForUser() {
if (self::$shareManager === null) {
self::$shareManager = \OC::$server->get(IManager::class);
self::$shareManager = Server::get(IManager::class);
}
$user = \OC::$server->getUserSession()->getUser();
if ($user !== null) {
$user = $user->getUID();
}
$user = Server::get(\OCP\IUserSession::class)->getUser();
return self::$shareManager->sharingDisabledForUser($user);
return self::$shareManager->sharingDisabledForUser($user?->getUID());
}
/**