Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-02-12 00:13:06 +0300
committerJoas Schilling <coding@schilljs.com>2021-02-12 12:46:35 +0300
commitc39f2c7ce93ffc0b6de2c72fc84094eff738d0f8 (patch)
tree49a3667aca4727f77ff243447c51375e0aa3dbd6
parent3606f14153d956d5513c2646d45a172bc0517376 (diff)
Don't recalculate the actorId of guest attendees
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Controller/ChatController.php18
-rw-r--r--tests/php/Controller/ChatControllerTest.php23
2 files changed, 12 insertions, 29 deletions
diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php
index 49257cbca..4be98b359 100644
--- a/lib/Controller/ChatController.php
+++ b/lib/Controller/ChatController.php
@@ -37,7 +37,6 @@ use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Service\SessionService;
-use OCA\Talk\TalkSession;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -65,9 +64,6 @@ class ChatController extends AEnvironmentAwareController {
/** @var IUserManager */
private $userManager;
- /** @var TalkSession */
- private $session;
-
/** @var IAppManager */
private $appManager;
@@ -120,7 +116,6 @@ class ChatController extends AEnvironmentAwareController {
?string $UserId,
IRequest $request,
IUserManager $userManager,
- TalkSession $session,
IAppManager $appManager,
ChatManager $chatManager,
ParticipantService $participantService,
@@ -140,7 +135,6 @@ class ChatController extends AEnvironmentAwareController {
$this->userId = $UserId;
$this->userManager = $userManager;
- $this->session = $session;
$this->appManager = $appManager;
$this->chatManager = $chatManager;
$this->participantService = $participantService;
@@ -161,15 +155,9 @@ class ChatController extends AEnvironmentAwareController {
protected function getActorInfo(string $actorDisplayName = ''): array {
if ($this->userId === null) {
$actorType = Attendee::ACTOR_GUESTS;
- $sessionId = $this->session->getSessionForRoom($this->room->getToken());
- // The character limit for actorId is 64, but the spreed-session is
- // 256 characters long, so it has to be hashed to get an ID that
- // fits (except if there is no session, as the actorId should be
- // empty in that case but sha1('') would generate a hash too
- // instead of returning an empty string).
- $actorId = $sessionId ? sha1($sessionId) : 'failed-to-get-session';
-
- if ($sessionId && $actorDisplayName) {
+ $actorId = $this->participant->getAttendee()->getActorId();
+
+ if ($actorDisplayName) {
$this->guestManager->updateName($this->room, $this->participant, $actorDisplayName);
}
} else {
diff --git a/tests/php/Controller/ChatControllerTest.php b/tests/php/Controller/ChatControllerTest.php
index eb3f0f029..449b430e3 100644
--- a/tests/php/Controller/ChatControllerTest.php
+++ b/tests/php/Controller/ChatControllerTest.php
@@ -29,12 +29,12 @@ use OCA\Talk\Chat\MessageParser;
use OCA\Talk\Controller\ChatController;
use OCA\Talk\GuestManager;
use OCA\Talk\MatterbridgeManager;
+use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\Message;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Service\SessionService;
-use OCA\Talk\TalkSession;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -59,8 +59,6 @@ class ChatControllerTest extends TestCase {
private $userId;
/** @var IUserManager|MockObject */
protected $userManager;
- /** @var TalkSession|MockObject */
- private $session;
/** @var IAppManager|MockObject */
private $appManager;
/** @var ChatManager|MockObject */
@@ -106,7 +104,6 @@ class ChatControllerTest extends TestCase {
$this->userId = 'testUser';
$this->userManager = $this->createMock(IUserManager::class);
- $this->session = $this->createMock(TalkSession::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->chatManager = $this->createMock(ChatManager::class);
$this->participantService = $this->createMock(ParticipantService::class);
@@ -141,7 +138,6 @@ class ChatControllerTest extends TestCase {
$this->userId,
$this->createMock(IRequest::class),
$this->userManager,
- $this->session,
$this->appManager,
$this->chatManager,
$this->participantService,
@@ -542,15 +538,14 @@ class ChatControllerTest extends TestCase {
$this->userId = null;
$this->recreateChatController();
- $this->session->expects($this->once())
- ->method('getSessionForRoom')
- ->with('testToken')
- ->willReturn('testSpreedSession');
-
+ $attendee = Attendee::fromRow([
+ 'actor_type' => 'guests',
+ 'actor_id' => 'actorId',
+ 'participant_type' => Participant::GUEST,
+ ]);
$participant = $this->createMock(Participant::class);
- $this->room->expects($this->once())
- ->method('getToken')
- ->willReturn('testToken');
+ $participant->method('getAttendee')
+ ->willReturn($attendee);
$date = new \DateTime();
$this->timeFactory->expects($this->once())
@@ -563,7 +558,7 @@ class ChatControllerTest extends TestCase {
->with($this->room,
$participant,
'guests',
- sha1('testSpreedSession'),
+ 'actorId',
'testMessage',
$this->newMessageDateTimeConstraint
)