diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-16 20:29:17 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-16 21:41:58 +0100 |
commit | 3e80f142693fd0d78ff6f4fcd8fd36dd1651e209 (patch) | |
tree | 88cde3cea3eab333e0db36acea2efe777af710bc /core/avatar/avatarcontroller.php | |
parent | d796c43841f5f22e39af76e2c11d60335e985738 (diff) | |
download | nextcloud-server-3e80f142693fd0d78ff6f4fcd8fd36dd1651e209.tar.gz nextcloud-server-3e80f142693fd0d78ff6f4fcd8fd36dd1651e209.zip |
[Avatar] Make the avatar controller use the avatar node
Diffstat (limited to 'core/avatar/avatarcontroller.php')
-rw-r--r-- | core/avatar/avatarcontroller.php | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/core/avatar/avatarcontroller.php b/core/avatar/avatarcontroller.php index 6c0321e6b5e..e8139aa50ae 100644 --- a/core/avatar/avatarcontroller.php +++ b/core/avatar/avatarcontroller.php @@ -30,6 +30,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataDisplayResponse; +use OCP\Files\NotFoundException; use OCP\IAvatarManager; use OCP\ILogger; use OCP\IL10N; @@ -112,20 +113,23 @@ class AvatarController extends Controller { $size = 64; } - $avatar = $this->avatarManager->getAvatar($userId); - $image = $avatar->get($size); - - if ($image instanceof \OCP\IImage) { - $resp = new DataDisplayResponse($image->data(), + try { + $avatar = $this->avatarManager->getAvatar($userId)->getFile($size); + $resp = new DataDisplayResponse($avatar->getContent(), Http::STATUS_OK, - ['Content-Type' => $image->mimeType()]); - $resp->setETag(crc32($image->data())); - } else { + ['Content-Type' => $avatar->getMimeType()]); + $resp->setETag($avatar->getEtag()); + } catch (NotFoundException $e) { $user = $this->userManager->get($userId); - $userName = $user ? $user->getDisplayName() : ''; $resp = new DataResponse([ 'data' => [ - 'displayname' => $userName, + 'displayname' => $user->getDisplayName(), + ], + ]); + } catch (\Exception $e) { + $resp = new DataResponse([ + 'data' => [ + 'displayname' => '', ], ]); } |