Skip to content

Commit

Permalink
Merge pull request #11363 from nextcloud/backport/11360/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(avatar): Fix avatars without PHP intl module
  • Loading branch information
nickvergessen committed Jan 10, 2024
2 parents 78283ff + 294a293 commit db5ea53
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Service/AvatarService.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function getAvatar(Room $room, ?IUser $user, bool $darkTheme = false): IS
}
}
}
if ($this->emojiHelper->isValidSingleEmoji(mb_substr($room->getName(), 0, 1))) {
if ($this->emojiHelper->doesPlatformSupportEmoji() && $this->emojiHelper->isValidSingleEmoji(mb_substr($room->getName(), 0, 1))) {
return new InMemoryFile(
$token,
$this->getEmojiAvatar(
Expand Down Expand Up @@ -271,7 +271,7 @@ protected function getEmojiAvatar(string $emoji, string $fillColor): string {
* @return string
*/
protected function getFirstCombinedEmoji(string $roomName, int $length = 0): string {
if (mb_strlen($roomName) === $length) {
if (!$this->emojiHelper->doesPlatformSupportEmoji() || mb_strlen($roomName) === $length) {
return '';
}

Expand Down Expand Up @@ -344,7 +344,7 @@ public function getAvatarVersion(Room $room): string {
[$version] = explode('.', $avatarVersion);
return $version;
}
if ($this->emojiHelper->isValidSingleEmoji(mb_substr($room->getName(), 0, 1))) {
if ($this->emojiHelper->doesPlatformSupportEmoji() && $this->emojiHelper->isValidSingleEmoji(mb_substr($room->getName(), 0, 1))) {
return substr(md5($this->getEmojiAvatar($this->getFirstCombinedEmoji($room->getName()), self::THEMING_BRIGHT_BACKGROUND)), 0, 8);
}
$avatarPath = $this->getAvatarPath($room);
Expand Down

0 comments on commit db5ea53

Please sign in to comment.