[ENTITY][LocalUser] Fix LocalUser::setNicknameSanitizedAndCached so it updates the actor nickname and propagates the exceptions
This commit is contained in:
parent
764a30695d
commit
be197bc82b
@ -29,7 +29,6 @@ use App\Core\Entity;
|
||||
use App\Core\UserRoles;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\NicknameEmptyException;
|
||||
use App\Util\Exception\NicknameException;
|
||||
use App\Util\Exception\NicknameInvalidException;
|
||||
use App\Util\Exception\NicknameNotAllowedException;
|
||||
use App\Util\Exception\NicknameTakenException;
|
||||
@ -351,7 +350,6 @@ class LocalUser extends Entity implements UserInterface, PasswordAuthenticatedUs
|
||||
* Checks if desired nickname is allowed, and in case it is, it sets Actor's nickname cache to newly set nickname
|
||||
*
|
||||
* @param string $nickname Desired new nickname
|
||||
* @param int $actor_id Used to cache Actor nickname
|
||||
*
|
||||
* @throws NicknameEmptyException
|
||||
* @throws NicknameInvalidException
|
||||
@ -361,25 +359,13 @@ class LocalUser extends Entity implements UserInterface, PasswordAuthenticatedUs
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNicknameSanitizedAndCached(string $nickname, int $actor_id): self
|
||||
public function setNicknameSanitizedAndCached(string $nickname): self
|
||||
{
|
||||
try {
|
||||
$nickname = Nickname::normalize($nickname, check_already_used: false, which: Nickname::CHECK_LOCAL_USER, check_is_allowed: true);
|
||||
$this->nickname = $nickname;
|
||||
Cache::set('actor-nickname-id-' . $actor_id, $nickname);
|
||||
} catch (NicknameEmptyException $e) {
|
||||
throw new NicknameEmptyException();
|
||||
} catch (NicknameInvalidException $e) {
|
||||
throw new NicknameInvalidException();
|
||||
} catch (NicknameNotAllowedException $e) {
|
||||
throw new NicknameNotAllowedException();
|
||||
} catch (NicknameTakenException $e) {
|
||||
throw new NicknameTakenException();
|
||||
} catch (NicknameTooLongException $e) {
|
||||
throw new NicknameTooLongException();
|
||||
} catch (NicknameException $e) {
|
||||
}
|
||||
|
||||
$nickname = Nickname::normalize($nickname, check_already_used: false, which: Nickname::CHECK_LOCAL_USER, check_is_allowed: true);
|
||||
$this->setNickname($nickname);
|
||||
$this->getActor()->setNickname($nickname);
|
||||
Cache::delete(self::cacheKeys($this->getId())['nickname']);
|
||||
Cache::delete(Actor::cacheKeys($this->getId())['nickname']);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user