mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Return avatar of one2one with dark theme when is necessary
Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
parent
dc10d3b7c3
commit
aabd71b11b
3 changed files with 15 additions and 4 deletions
|
|
@ -34,6 +34,8 @@ return [
|
|||
['name' => 'Avatar#uploadAvatar', 'url' => '/api/{apiVersion}/room/{token}/avatar', 'verb' => 'POST', 'requirements' => $requirements],
|
||||
/** @see \OCA\Talk\Controller\AvatarController::getAvatar() */
|
||||
['name' => 'Avatar#getAvatar', 'url' => '/api/{apiVersion}/room/{token}/avatar', 'verb' => 'GET', 'requirements' => $requirements],
|
||||
/** @see \OCA\Talk\Controller\AvatarController::getAvatarDark() */
|
||||
['name' => 'Avatar#getAvatarDark', 'url' => '/api/{apiVersion}/room/{token}/avatar/dark', 'verb' => 'GET', 'requirements' => $requirements],
|
||||
/** @see \OCA\Talk\Controller\AvatarController::deleteAvatar() */
|
||||
['name' => 'Avatar#deleteAvatar', 'url' => '/api/{apiVersion}/room/{token}/avatar', 'verb' => 'DELETE', 'requirements' => $requirements],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ class AvatarController extends AEnvironmentAwareController {
|
|||
* @NoCSRFRequired
|
||||
* @RequireParticipant
|
||||
*/
|
||||
public function getAvatar(): Response {
|
||||
$file = $this->avatarService->getAvatar($this->getRoom(), $this->userSession->getUser());
|
||||
public function getAvatar(bool $darkTheme = false): Response {
|
||||
$file = $this->avatarService->getAvatar($this->getRoom(), $this->userSession->getUser(), $darkTheme);
|
||||
|
||||
$response = new FileDisplayResponse($file);
|
||||
$response->addHeader('Content-Type', $file->getMimeType());
|
||||
|
|
@ -95,6 +95,15 @@ class AvatarController extends AEnvironmentAwareController {
|
|||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
* @RequireParticipant
|
||||
*/
|
||||
public function getAvatarDark(): Response {
|
||||
return $this->getAvatar(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @PublicPage
|
||||
* @RequireModeratorParticipant
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class AvatarService {
|
|||
return $avatarFolder;
|
||||
}
|
||||
|
||||
public function getAvatar(Room $room, ?IUser $user): ISimpleFile {
|
||||
public function getAvatar(Room $room, ?IUser $user, bool $darkTheme = false): ISimpleFile {
|
||||
$token = $room->getToken();
|
||||
$avatar = $room->getAvatar();
|
||||
if ($avatar) {
|
||||
|
|
@ -156,7 +156,7 @@ class AvatarService {
|
|||
foreach ($users as $participantId) {
|
||||
if ($participantId !== $user->getUID()) {
|
||||
$avatar = $this->avatarManager->getAvatar($participantId);
|
||||
$file = $avatar->getFile(512);
|
||||
$file = $avatar->getFile(512, $darkTheme);
|
||||
}
|
||||
}
|
||||
} elseif ($room->getObjectType() === 'file') {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue