From a9089e5bc6cd4ce66ffa56f06aca25ced1c5cfb7 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 5 Apr 2024 15:14:10 +0300 Subject: [PATCH] fix: set user avatar as base64 --- controller/editorapicontroller.php | 18 ------------------ controller/editorcontroller.php | 8 +------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 3cb3343d..1e28a15c 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -138,13 +138,6 @@ class EditorApiController extends OCSController { */ private $lockManager; - /** - * Avatar manager - * - * @var IAvatarManager - */ - private $avatarManager; - /** * Mobile regex from https://github.com/ONLYOFFICE/CommunityServer/blob/v9.1.1/web/studio/ASC.Web.Studio/web.appsettings.config#L35 */ @@ -201,7 +194,6 @@ public function __construct( } $this->fileUtility = new FileUtility($AppName, $trans, $logger, $config, $shareManager, $session); - $this->avatarManager = \OC::$server->getAvatarManager(); } /** @@ -439,16 +431,6 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok "id" => $this->buildUserId($userId), "name" => $user->getDisplayName() ]; - $avatar = $this->avatarManager->getAvatar($userId); - if ($avatar->exists() && $avatar->isCustomAvatar()) { - $userAvatarUrl = $this->urlGenerator->getAbsoluteURL( - $this->urlGenerator->linkToRoute("core.avatar.getAvatar", [ - "userId" => $userId, - "size" => 64, - ]) - ); - $params["editorConfig"]["user"]["image"] = $userAvatarUrl; - } } elseif (!empty($guestName)) { $params["editorConfig"]["user"] = [ "name" => $guestName diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 11c54dd7..c9df9c6b 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -459,13 +459,7 @@ public function userInfo($userIds) { ]; $avatar = $this->avatarManager->getAvatar($user->getUID()); if ($avatar->exists() && $avatar->isCustomAvatar()) { - $userAvatarUrl = $this->urlGenerator->getAbsoluteURL( - $this->urlGenerator->linkToRoute("core.avatar.getAvatar", [ - "userId" => $user->getUID(), - "size" => 64, - ]) - ); - $userData["image"] = $userAvatarUrl; + $userData["image"] = "data:image/png;base64," . $avatar->get()->__toString(); } array_push($result, $userData); }