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;
|
$square_resize = true;
|
||||||
$scale = null;
|
$scale = null;
|
||||||
$stamp = microtime(true);
|
$stamp = microtime(true);
|
||||||
|
// User avatar
|
||||||
|
if (!empty($parameters['type'])) {
|
||||||
if (!empty($parameters['customsize'])) {
|
if (!empty($parameters['customsize'])) {
|
||||||
$customsize = intval($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']);
|
$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);
|
if (!empty($parameters['nickname_ext'])) {
|
||||||
} elseif (!empty($parameters['name'])) {
|
$nickname = pathinfo($parameters['nickname_ext'], PATHINFO_FILENAME);
|
||||||
$photoid = pathinfo($parameters['name'], 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;
|
$scale = 0;
|
||||||
if (substr($photoid, -2, 1) == "-") {
|
if (substr($photoid, -2, 1) == "-") {
|
||||||
$scale = intval(substr($photoid, -1, 1));
|
$scale = intval(substr($photoid, -1, 1));
|
||||||
|
|
|
@ -372,8 +372,12 @@ return [
|
||||||
|
|
||||||
'/photo' => [
|
'/photo' => [
|
||||||
'/{name}' => [Module\Photo::class, [R::GET]],
|
'/{name}' => [Module\Photo::class, [R::GET]],
|
||||||
'/{type}/{name}' => [Module\Photo::class, [R::GET]],
|
// User Id Fallback, to remove after version 2021.12
|
||||||
'/{type}/{customsize}/{name}' => [Module\Photo::class, [R::GET]],
|
'/{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]],
|
'/pretheme' => [Module\ThemeDetails::class, [R::GET]],
|
||||||
|
|
Loading…
Reference in a new issue