Switch uid with nickname in user picture URLs
- Keep previous URL scheme fallback as remote contact avatar URLs pointing to local user avatar URLs need to update
This commit is contained in:
parent
7cdd2d1336
commit
8cb0bb5deb
3 changed files with 33 additions and 14 deletions
|
@ -879,7 +879,7 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
return $url . $user['uid'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
|
||||
return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -75,16 +75,31 @@ class Photo extends BaseModule
|
|||
$square_resize = true;
|
||||
$scale = null;
|
||||
$stamp = microtime(true);
|
||||
if (!empty($parameters['customsize'])) {
|
||||
$customsize = intval($parameters['customsize']);
|
||||
$uid = pathinfo($parameters['name'], PATHINFO_FILENAME);
|
||||
$photo = self::getAvatar($uid, $parameters['type'], $customsize);
|
||||
$square_resize = !in_array($parameters['type'], ['media', 'preview']);
|
||||
} elseif (!empty($parameters['type'])) {
|
||||
$uid = pathinfo($parameters['name'], PATHINFO_FILENAME);
|
||||
$photo = self::getAvatar($uid, $parameters['type'], Proxy::PIXEL_SMALL);
|
||||
} elseif (!empty($parameters['name'])) {
|
||||
$photoid = pathinfo($parameters['name'], PATHINFO_FILENAME);
|
||||
// User avatar
|
||||
if (!empty($parameters['type'])) {
|
||||
if (!empty($parameters['customsize'])) {
|
||||
$customsize = intval($parameters['customsize']);
|
||||
$square_resize = !in_array($parameters['type'], ['media', 'preview']);
|
||||
}
|
||||
|
||||
if (!empty($parameters['nickname_ext'])) {
|
||||
$nickname = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME);
|
||||
$user = User::getByNickname($nickname, ['uid']);
|
||||
if (empty($user)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
$uid = $user['uid'];
|
||||
}
|
||||
|
||||
// User Id Fallback, to remove after version 2021.12
|
||||
if (!empty($parameters['uid_ext'])) {
|
||||
$uid = intval(pathinfo($parameters['uid_ext'], PATHINFO_FILENAME));
|
||||
}
|
||||
|
||||
$photo = self::getAvatar($uid, $parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
|
||||
} else {
|
||||
$photoid = MPhoto::stripExtension($parameters['name']);
|
||||
$scale = 0;
|
||||
if (substr($photoid, -2, 1) == "-") {
|
||||
$scale = intval(substr($photoid, -1, 1));
|
||||
|
|
|
@ -371,9 +371,13 @@ return [
|
|||
'/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]],
|
||||
|
||||
'/photo' => [
|
||||
'/{name}' => [Module\Photo::class, [R::GET]],
|
||||
'/{type}/{name}' => [Module\Photo::class, [R::GET]],
|
||||
'/{type}/{customsize}/{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]],
|
||||
// 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]],
|
||||
],
|
||||
|
||||
'/pretheme' => [Module\ThemeDetails::class, [R::GET]],
|
||||
|
|
Loading…
Reference in a new issue