summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2023-05-03 09:06:11 -0300
committerVitor Mattos <vitor@php.rio>2023-05-03 09:06:11 -0300
commitc92f66c01d7a1d522e3f4a6ff69ec9955fee7322 (patch)
tree0e7e801a88e715ff160ce76552acd51f640a7ef5 /lib
parentee52c47523ade345991e71b730f437cc3ba5abad (diff)
Cover with integration tests the room avatar with emoji
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/AvatarService.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Service/AvatarService.php b/lib/Service/AvatarService.php
index 0769a1ad0..b6a727dc4 100644
--- a/lib/Service/AvatarService.php
+++ b/lib/Service/AvatarService.php
@@ -180,10 +180,13 @@ class AvatarService {
}
}
}
- return new InMemoryFile($token, $this->getAvatarPath($room, $darkTheme));
+ if ($this->emojiHelper->isValidSingleEmoji(mb_substr($room->getName(), 0, 1))) {
+ return new InMemoryFile($token, $this->getEmojiAvatar($room->getName(), $darkTheme));
+ }
+ return new InMemoryFile($token, file_get_contents($this->getAvatarPath($room, $darkTheme)));
}
- protected function getEmojiAvatar(string $roomName, bool $darkTheme): string {
+ protected function getEmojiAvatar(string $roomName, bool $darkTheme = false): string {
return str_replace([
'{letter}',
'{fill}',
@@ -283,6 +286,9 @@ class AvatarService {
[$version] = explode('.', $avatarVersion);
return $version;
}
+ if ($this->emojiHelper->isValidSingleEmoji(mb_substr($room->getName(), 0, 1))) {
+ return substr(md5($this->getEmojiAvatar($room->getName())), 0, 8);
+ }
$avatarPath = $this->getAvatarPath($room);
return substr(md5($avatarPath), 0, 8);
}