Skip to content

Commit

Permalink
Refactor OC\Server::getAvatarManager in user_ldap app
Browse files Browse the repository at this point in the history
Refactor `OC\Server::getAvatarManager` in user_ldap app (missed one)

Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
  • Loading branch information
summersab authored and skjnldsv committed May 30, 2024
1 parent 31b0a44 commit d62eb33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Jobs/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function setArgument($argument) {
if (isset($argument['avatarManager'])) {
$this->avatarManager = $argument['avatarManager'];
} else {
$this->avatarManager = \OC::$server->getAvatarManager();
$this->avatarManager = \OC::$server->get(IAvatarManager::class);
}

if (isset($argument['dbc'])) {
Expand Down
3 changes: 2 additions & 1 deletion apps/user_ldap/tests/Integration/AbstractIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use OCA\User_LDAP\LDAP;
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\UserPluginManager;
use OCP\IAvatarManager;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -124,7 +125,7 @@ protected function initUserManager() {
\OC::$server->getConfig(),
new FilesystemHelper(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getAvatarManager(),
\OC::$server->get(IAvatarManager::class),
new \OCP\Image(),
\OC::$server->getUserManager(),
\OC::$server->getNotificationManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use OCA\User_LDAP\User\User;
use OCA\User_LDAP\User_LDAP;
use OCA\User_LDAP\UserPluginManager;
use OCP\IAvatarManager;
use OCP\Image;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -78,8 +79,8 @@ private function execFetchTest($dn, $username, $image) {
\OC_Util::setupFS($username);
\OC::$server->getUserFolder($username);
\OC::$server->getConfig()->deleteUserValue($username, 'user_ldap', User::USER_PREFKEY_LASTREFRESH);
if (\OC::$server->getAvatarManager()->getAvatar($username)->exists()) {
\OC::$server->getAvatarManager()->getAvatar($username)->remove();
if (\OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists()) {
\OC::$server->get(IAvatarManager::class)->getAvatar($username)->remove();
}

// finally attempt to get the avatar set
Expand All @@ -99,7 +100,7 @@ protected function case1() {

$this->execFetchTest($dn, $username, $image);

return \OC::$server->getAvatarManager()->getAvatar($username)->exists();
return \OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists();
}

/**
Expand All @@ -116,7 +117,7 @@ protected function case2() {

$this->execFetchTest($dn, $username, $image);

return !\OC::$server->getAvatarManager()->getAvatar($username)->exists();
return !\OC::$server->get(IAvatarManager::class)->getAvatar($username)->exists();
}

/**
Expand All @@ -136,7 +137,7 @@ protected function initUserManager() {
\OC::$server->getConfig(),
new FilesystemHelper(),
\OC::$server->get(LoggerInterface::class),
\OC::$server->getAvatarManager(),
\OC::$server->get(IAvatarManager::class),
new Image(),
\OC::$server->getDatabaseConnection(),
\OC::$server->getUserManager(),
Expand Down

0 comments on commit d62eb33

Please sign in to comment.