Browse Source

Some minor fixes

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/8333/head
Joas Schilling 3 years ago
parent
commit
26751b47ce
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 1
      lib/Activity/Listener.php
  2. 12
      lib/Activity/Provider/Base.php
  3. 3
      lib/Chat/ChatManager.php
  4. 11
      lib/Search/ConversationSearch.php
  5. 5
      lib/Service/AvatarService.php
  6. 10
      lib/Service/RoomService.php
  7. 4
      tests/php/Chat/ChatManagerTest.php

1
lib/Activity/Listener.php

@ -175,7 +175,6 @@ class Listener {
->setTimestamp($this->timeFactory->getTime())
->setSubject('call', [
'room' => $room->getId(),
'avatar' => $room->getAvatar(),
'users' => $userIds,
'guests' => $numGuests,
'duration' => $duration,

12
lib/Activity/Provider/Base.php

@ -80,10 +80,14 @@ abstract class Base implements IProvider {
try {
$room = $this->manager->getRoomForUser($event->getObjectId(), $uid);
$event->setIcon($this->avatarService->getAvatarUrl($room, $uid));
$event->setIcon($this->avatarService->getAvatarUrl($room));
} catch (RoomNotFoundException $th) {
// When the roomId wont exists and to prevent an exception
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('spreed', 'app-dark.png')));
// When the room doesn't exist and to prevent an exception
if ($this->activityManager->getRequirePNG()) {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('spreed', 'app-dark.png')));
} else {
$event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('spreed', 'app-dark.svg')));
}
}
return $event;
@ -125,7 +129,7 @@ abstract class Base implements IProvider {
'id' => $room->getId(),
'name' => $room->getDisplayName($userId),
'link' => $this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]),
'iconUrl' => $this->avatarService->getAvatarUrl($room, $userId),
'icon-url' => $this->avatarService->getAvatarUrl($room),
'call-type' => $stringType,
];
}

3
lib/Chat/ChatManager.php

@ -95,7 +95,6 @@ class ChatManager {
private RoomService $roomService;
private PollService $pollService;
private Notifier $notifier;
private AvatarService $avatarService;
protected ITimeFactory $timeFactory;
protected ICache $cache;
protected ICache $unreadCountCache;
@ -112,7 +111,6 @@ class ChatManager {
RoomService $roomService,
PollService $pollService,
Notifier $notifier,
AvatarService $avatarService,
ICacheFactory $cacheFactory,
ITimeFactory $timeFactory,
AttachmentService $attachmentService,
@ -127,7 +125,6 @@ class ChatManager {
$this->roomService = $roomService;
$this->pollService = $pollService;
$this->notifier = $notifier;
$this->avatarService = $avatarService;
$this->cache = $cacheFactory->createDistributed('talk/lastmsgid');
$this->unreadCountCache = $cacheFactory->createDistributed('talk/unreadcount');
$this->timeFactory = $timeFactory;

11
lib/Search/ConversationSearch.php

@ -117,17 +117,8 @@ class ConversationSearch implements IProvider {
}
}
$arguments = [
'token' => $room->getToken(),
'apiVersion' => 'v1',
];
if ($avatar = $room->getAvatar()) {
$arguments['v'] = $avatar;
}
$icon = $this->url->linkToOCSRouteAbsolute('spreed.Avatar.getAvatar', $arguments);
$entry = new SearchResultEntry(
$icon,
$this->avatarService->getAvatarUrl($room),
$room->getDisplayName($user->getUID()),
'',
$this->url->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]),

5
lib/Service/AvatarService.php

@ -124,7 +124,6 @@ class AvatarService {
$avatarFolder = $this->getAvatarFolder($token);
$avatarName = $this->getRandomAvatarName($room);
$avatarFolder->newFile($avatarName, $image->data());
$room->setAvatar($avatarName);
$this->roomService->setAvatar($room, $avatarName);
}
@ -167,7 +166,7 @@ class AvatarService {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
$users = json_decode($room->getName(), true);
foreach ($users as $participantId) {
if ($participantId !== $user->getUID()) {
if ($user instanceof IUser && $participantId !== $user->getUID()) {
$avatar = $this->avatarManager->getAvatar($participantId);
$file = $avatar->getFile(512, $darkTheme);
}
@ -231,6 +230,6 @@ class AvatarService {
if ($avatar = $room->getAvatar()) {
$arguments['v'] = $avatar;
}
return $this->url->linkToRouteAbsolute('ocs.spreed.Avatar.getAvatar', $arguments);
return $this->url->linkToOCSRouteAbsolute('spreed.Avatar.getAvatar', $arguments);
}
}

10
lib/Service/RoomService.php

@ -337,22 +337,22 @@ class RoomService {
return true;
}
public function setAvatar(Room $room, $avatarName): bool {
public function setAvatar(Room $room, ?string $avatar): bool {
if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
return false;
}
$event = new ModifyRoomEvent($room, 'avatar', $avatarName, $room->getAvatar());
$event = new ModifyRoomEvent($room, 'avatar', $avatar, $room->getAvatar());
$this->dispatcher->dispatch(Room::EVENT_BEFORE_AVATAR_SET, $event);
$room->setAvatar($avatarName);
$update = $this->db->getQueryBuilder();
$update->update('talk_rooms')
->set('avatar', $update->createNamedParameter($avatarName))
->set('avatar', $update->createNamedParameter($avatar))
->where($update->expr()->eq('id', $update->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT)));
$update->executeStatement();
$room->setAvatar($avatar);
$this->dispatcher->dispatch(Room::EVENT_AFTER_AVATAR_SET, $event);
return true;
}

4
tests/php/Chat/ChatManagerTest.php

@ -73,8 +73,6 @@ class ChatManagerTest extends TestCase {
protected $pollService;
/** @var Notifier|MockObject */
protected $notifier;
/** @var AvatarService|MockObject */
protected $avatarService;
/** @var ITimeFactory|MockObject */
protected $timeFactory;
/** @var AttachmentService|MockObject */
@ -95,7 +93,6 @@ class ChatManagerTest extends TestCase {
$this->roomService = $this->createMock(RoomService::class);
$this->pollService = $this->createMock(PollService::class);
$this->notifier = $this->createMock(Notifier::class);
$this->avatarService = $this->createMock(AvatarService::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->attachmentService = $this->createMock(AttachmentService::class);
$this->referenceManager = $this->createMock(IReferenceManager::class);
@ -112,7 +109,6 @@ class ChatManagerTest extends TestCase {
$this->roomService,
$this->pollService,
$this->notifier,
$this->avatarService,
$cacheFactory,
$this->timeFactory,
$this->attachmentService,

Loading…
Cancel
Save