From 5112dd06f20b8545787571e7d4fd785171e35d9a Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 3 Oct 2021 07:48:46 -0400 Subject: [PATCH] Add missing Module\Photo route for contact avatar --- src/Module/Photo.php | 5 +++++ static/routes.config.php | 11 ++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 806ad449c5..9a59d967b0 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -97,6 +97,11 @@ class Photo extends BaseModule $uid = intval(pathinfo($parameters['uid_ext'], PATHINFO_FILENAME)); } + // Please refactor this for the love of everything that's good + if (!empty($parameters['contact_id'])) { + $uid = $parameters['contact_id']; + } + $photo = self::getAvatar($uid, $parameters['type'], $customsize ?: Proxy::PIXEL_SMALL); } else { $photoid = pathinfo($parameters['name'], PATHINFO_FILENAME); diff --git a/static/routes.config.php b/static/routes.config.php index 9dbd2a615b..72a71f2c1b 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -371,13 +371,14 @@ return [ '/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]], '/photo' => [ - '/{name}' => [Module\Photo::class, [R::GET]], + '/{name}' => [Module\Photo::class, [R::GET]], // User Id Fallback, to remove after version 2021.12 - '/{type}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]], - '/{type}/{nickname_ext}' => [Module\Photo::class, [R::GET]], + '/{type}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]], + '/{type}/{nickname_ext}' => [Module\Photo::class, [R::GET]], + '/{type}/{customsize}/{contact_id:\d+}' => [Module\Photo::class, [R::GET]], // User Id Fallback, to remove after version 2021.12 - '/{type}/{customsize}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]], - '/{type}/{customsize}/{nickname_ext}' => [Module\Photo::class, [R::GET]], + '/{type}/{customsize}/{uid_ext:\d+\..*}' => [Module\Photo::class, [R::GET]], + '/{type}/{customsize}/{nickname_ext}' => [Module\Photo::class, [R::GET]], ], '/pretheme' => [Module\ThemeDetails::class, [R::GET]],