Browse Source

Return conversation avatar in mentions

Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/8333/head
Vitor Mattos 3 years ago
committed by Joas Schilling
parent
commit
20d376669e
No known key found for this signature in database GPG Key ID: 74434EFE0D2E2205
  1. 7
      lib/Chat/ChatManager.php
  2. 5
      tests/integration/features/bootstrap/FeatureContext.php
  3. 9
      tests/integration/features/chat/avatar.feature

7
lib/Chat/ChatManager.php

@ -34,6 +34,7 @@ use OCA\Talk\Model\Poll;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\AttachmentService;
use OCA\Talk\Service\AvatarService;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Service\PollService;
use OCA\Talk\Service\RoomService;
@ -94,6 +95,7 @@ class ChatManager {
private RoomService $roomService;
private PollService $pollService;
private Notifier $notifier;
private AvatarService $avatarService;
protected ITimeFactory $timeFactory;
protected ICache $cache;
protected ICache $unreadCountCache;
@ -110,6 +112,7 @@ class ChatManager {
RoomService $roomService,
PollService $pollService,
Notifier $notifier,
AvatarService $avatarService,
ICacheFactory $cacheFactory,
ITimeFactory $timeFactory,
AttachmentService $attachmentService,
@ -124,6 +127,7 @@ 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;
@ -757,7 +761,8 @@ class ChatManager {
array_unshift($results, [
'id' => 'all',
'label' => $roomDisplayName,
'source' => 'calls'
'source' => 'calls',
'avatar' => $this->avatarService->getAvatarUrl($room),
]);
}
return $results;

5
tests/integration/features/bootstrap/FeatureContext.php

@ -2233,6 +2233,11 @@ class FeatureContext implements Context, SnippetAcceptingContext {
Assert::assertRegExp('/^guest\/[0-9a-f]{40}$/', $mentions[$key]['id']);
$mentions[$key]['id'] = 'GUEST_ID';
}
if (array_key_exists('avatar', $row)) {
Assert::assertRegExp('/' . self::$identifierToToken[$row['avatar']] . '\/avatar/', $mentions[$key]['avatar']);
unset($row['avatar']);
}
unset($mentions[$key]['avatar'], );
Assert::assertEquals($row, $mentions[$key]);
}
}

9
tests/integration/features/chat/avatar.feature

@ -36,3 +36,12 @@ Feature: chat/avatar
| roomType | 1 |
| invite | participant2 |
Then user "participant1" send the file "/img/favicon.png" as avatar of room "room2" with 404
Scenario: get mentions in a group room with no other participant
When user "participant1" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "participant1" send the file "/img/favicon.png" as avatar of room "group room" with 200
Then user "participant1" gets the following candidate mentions in room "group room" for "" with 200
| id | label | source | avatar |
| all | room | calls | group room |
Loading…
Cancel
Save