-
-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp avatar system, remove MC avatars from core #3313
base: develop
Are you sure you want to change the base?
Conversation
9b88f5e
to
c62eb56
Compare
e1a4285
to
eaa1312
Compare
<table class="table table-borderless table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded text
MinecraftAvatarSource::registerSource(new VisageMinecraftAvatarSource()); | ||
} | ||
|
||
// EventHandler::registerListener(UserIntegrationUnlinkedEvent::class, ResetAvatarCacheHook::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should be uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or wait, this is listeners
public function get(User $user): ?string { | ||
$base_url = ($this->_full_url ? rtrim(URL::getSelfURL(), '/') : '') . ((defined('CONFIG_PATH')) ? CONFIG_PATH . '/' : '/') . 'uploads/avatars'; | ||
|
||
if (Settings::get('custom_user_avatars') && $user->data()->has_avatar) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow custom user avatars? setting on custom avatar source does not save on enabled state
} | ||
|
||
foreach ($exts as $ext) { | ||
if (file_exists(ROOT_PATH . "/uploads/avatars/{$user->data()->id}.{$ext}")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to be a way to remove or unselect default custom avatar
People most likey want Custom avatar to be priority one, and minecraft next but if they have uploaded a custom default image then they are not able to fallback to minecraft avatar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that Minecraft Avatar Source should be default priority, Well below Uploading Image source type
So new sites still using Minecraft avatars by default as its still a CMS designed for Minecraft
$cache_key = $user_id . '_' . $source->getSafeName() . '_' . $size . '_' . (int) $full_url; | ||
if ($this->_cache->isCached($cache_key)) { | ||
$avatar = $this->_cache->retrieve($cache_key); | ||
if ($avatar) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this check a bit redundant? Seeing as you already checked if it's in there?
} | ||
// Fallback to initials avatar | ||
if (!isset($url)) { | ||
$url = $this->_sources[InitialsAvatarSource::class]->getAvatar($user, $size, $full_url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never store this in cache if it fails, which would mean we attempt to re-fetch it from the respective avatar source every page load until it works. Is this intentional?
protected function get(User $user): ?string { | ||
$minecraft_integration = $user->getIntegration('Minecraft'); | ||
if ($minecraft_integration !== null) { | ||
$identifier = $minecraft_integration->data()->identifier; | ||
} else { | ||
$identifier = $user->data()->username; | ||
// Fallback to steve avatar if they have an invalid username | ||
// TODO: what is this regex? | ||
if (preg_match('#[^][_A-Za-z0-9]#', $identifier)) { | ||
$identifier = 'Steve'; | ||
} | ||
} | ||
|
||
return self::getAvatarFromIdentifier($identifier, $this->_size); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably check if the uuid is an offline one and use usernames instead if this is the case. This should fix the fact that when force premium accounts is disabled, people only receive steve skins. Nameless generates an offline uuid when force premium accounts is enabled which would still make this use that offline uuid for retrieving accounts
No description provided.