Merge pull request #22564 from nextcloud/bugfix/noid/show-avatars-again
The privacy setting is only about syncing to other servers
This commit is contained in:
commit
22ff60e088
|
@ -31,7 +31,6 @@
|
||||||
namespace OC\Core\Controller;
|
namespace OC\Core\Controller;
|
||||||
|
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OC\AppFramework\Utility\TimeFactory;
|
||||||
use OCP\Accounts\IAccountManager;
|
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataDisplayResponse;
|
use OCP\AppFramework\Http\DataDisplayResponse;
|
||||||
|
@ -80,8 +79,6 @@ class AvatarController extends Controller {
|
||||||
|
|
||||||
/** @var TimeFactory */
|
/** @var TimeFactory */
|
||||||
protected $timeFactory;
|
protected $timeFactory;
|
||||||
/** @var IAccountManager */
|
|
||||||
private $accountManager;
|
|
||||||
|
|
||||||
public function __construct($appName,
|
public function __construct($appName,
|
||||||
IRequest $request,
|
IRequest $request,
|
||||||
|
@ -92,8 +89,7 @@ class AvatarController extends Controller {
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder,
|
||||||
ILogger $logger,
|
ILogger $logger,
|
||||||
$userId,
|
$userId,
|
||||||
TimeFactory $timeFactory,
|
TimeFactory $timeFactory) {
|
||||||
IAccountManager $accountManager) {
|
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
|
|
||||||
$this->avatarManager = $avatarManager;
|
$this->avatarManager = $avatarManager;
|
||||||
|
@ -104,7 +100,6 @@ class AvatarController extends Controller {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->timeFactory = $timeFactory;
|
$this->timeFactory = $timeFactory;
|
||||||
$this->accountManager = $accountManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,21 +121,6 @@ class AvatarController extends Controller {
|
||||||
$size = 64;
|
$size = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->userManager->get($userId);
|
|
||||||
if ($user === null) {
|
|
||||||
return new JSONResponse([], Http::STATUS_NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
$account = $this->accountManager->getAccount($user);
|
|
||||||
$scope = $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope();
|
|
||||||
|
|
||||||
if ($scope !== IAccountManager::VISIBILITY_PUBLIC && $this->userId === null) {
|
|
||||||
// Public avatar access is not allowed
|
|
||||||
$response = new JSONResponse([], Http::STATUS_NOT_FOUND);
|
|
||||||
$response->cacheFor(1800);
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$avatar = $this->avatarManager->getAvatar($userId);
|
$avatar = $this->avatarManager->getAvatar($userId);
|
||||||
$avatarFile = $avatar->getFile($size);
|
$avatarFile = $avatar->getFile($size);
|
||||||
|
|
|
@ -33,9 +33,6 @@ namespace Tests\Core\Controller;
|
||||||
|
|
||||||
use OC\AppFramework\Utility\TimeFactory;
|
use OC\AppFramework\Utility\TimeFactory;
|
||||||
use OC\Core\Controller\AvatarController;
|
use OC\Core\Controller\AvatarController;
|
||||||
use OCP\Accounts\IAccount;
|
|
||||||
use OCP\Accounts\IAccountManager;
|
|
||||||
use OCP\Accounts\IAccountProperty;
|
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
|
@ -49,7 +46,6 @@ use OCP\ILogger;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AvatarControllerTest
|
* Class AvatarControllerTest
|
||||||
|
@ -82,8 +78,6 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
private $request;
|
private $request;
|
||||||
/** @var TimeFactory|\PHPUnit\Framework\MockObject\MockObject */
|
/** @var TimeFactory|\PHPUnit\Framework\MockObject\MockObject */
|
||||||
private $timeFactory;
|
private $timeFactory;
|
||||||
/** @var IAccountManager|MockObject */
|
|
||||||
private $accountManager;
|
|
||||||
|
|
||||||
protected function setUp(): void {
|
protected function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -98,7 +92,6 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
|
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')->getMock();
|
||||||
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
|
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
|
||||||
$this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock();
|
$this->timeFactory = $this->getMockBuilder('OC\AppFramework\Utility\TimeFactory')->getMock();
|
||||||
$this->accountManager = $this->createMock(IAccountManager::class);
|
|
||||||
|
|
||||||
$this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock();
|
$this->avatarMock = $this->getMockBuilder('OCP\IAvatar')->getMock();
|
||||||
$this->userMock = $this->getMockBuilder(IUser::class)->getMock();
|
$this->userMock = $this->getMockBuilder(IUser::class)->getMock();
|
||||||
|
@ -113,8 +106,7 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
$this->rootFolder,
|
$this->rootFolder,
|
||||||
$this->logger,
|
$this->logger,
|
||||||
'userid',
|
'userid',
|
||||||
$this->timeFactory,
|
$this->timeFactory
|
||||||
$this->accountManager
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Configure userMock
|
// Configure userMock
|
||||||
|
@ -145,39 +137,6 @@ class AvatarControllerTest extends \Test\TestCase {
|
||||||
$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
|
$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAvatarNotPublic() {
|
|
||||||
$account = $this->createMock(IAccount::class);
|
|
||||||
$this->accountManager->method('getAccount')
|
|
||||||
->with($this->userMock)
|
|
||||||
->willReturn($account);
|
|
||||||
|
|
||||||
$property = $this->createMock(IAccountProperty::class);
|
|
||||||
$account->method('getProperty')
|
|
||||||
->with(IAccountManager::PROPERTY_AVATAR)
|
|
||||||
->willReturn($property);
|
|
||||||
|
|
||||||
$property->method('getScope')
|
|
||||||
->willReturn(IAccountManager::VISIBILITY_PRIVATE);
|
|
||||||
|
|
||||||
$controller = new AvatarController(
|
|
||||||
'core',
|
|
||||||
$this->request,
|
|
||||||
$this->avatarManager,
|
|
||||||
$this->cache,
|
|
||||||
$this->l,
|
|
||||||
$this->userManager,
|
|
||||||
$this->rootFolder,
|
|
||||||
$this->logger,
|
|
||||||
null,
|
|
||||||
$this->timeFactory,
|
|
||||||
$this->accountManager
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = $controller->getAvatar('userId', 128);
|
|
||||||
|
|
||||||
$this->assertEquals(Http::STATUS_NOT_FOUND, $result->getStatus());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the user's avatar
|
* Fetch the user's avatar
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue