Skip to content
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

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from

Conversation

tadhgboyle
Copy link
Member

@tadhgboyle tadhgboyle commented Apr 11, 2023

No description provided.

@tadhgboyle tadhgboyle added this to the 2.2.0 milestone Apr 11, 2023
@tadhgboyle tadhgboyle force-pushed the feat/avatar-revamp branch 2 times, most recently from 9b88f5e to c62eb56 Compare April 15, 2023 00:08
@tadhgboyle tadhgboyle marked this pull request as ready for review May 7, 2023 15:57
@tadhgboyle tadhgboyle requested review from partydragen and a team and removed request for partydragen May 8, 2023 04:33
<table class="table table-borderless table-striped">
<thead>
<tr>
<th>Name</th>
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those should be uncommented?

Copy link
Member

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) {
Copy link
Member

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}")) {
Copy link
Member

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

Copy link
Member

@partydragen partydragen left a 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

@samerton samerton modified the milestones: 2.2.0, 2.3.0 Jul 14, 2024
$cache_key = $user_id . '_' . $source->getSafeName() . '_' . $size . '_' . (int) $full_url;
if ($this->_cache->isCached($cache_key)) {
$avatar = $this->_cache->retrieve($cache_key);
if ($avatar) {
Copy link
Member

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);
Copy link
Member

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?

Comment on lines +120 to +134
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);
}
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants