mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Move getParticipant()
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
aac298148e
commit
5f060687c8
32 changed files with 205 additions and 99 deletions
|
|
@ -283,7 +283,7 @@ class Notifier {
|
|||
return;
|
||||
}
|
||||
|
||||
$participant = $chat->getParticipant($comment->getActorId(), false);
|
||||
$participant = $this->participantService->getParticipant($chat, $comment->getActorId(), false);
|
||||
$notificationLevel = $participant->getAttendee()->getNotificationLevel();
|
||||
if ($notificationLevel === Participant::NOTIFY_DEFAULT) {
|
||||
if ($chat->getType() === Room::TYPE_ONE_TO_ONE) {
|
||||
|
|
@ -449,7 +449,7 @@ class Notifier {
|
|||
return false;
|
||||
}
|
||||
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
$attendee = $participant->getAttendee();
|
||||
} else {
|
||||
$participant = new Participant($room, $attendee, null);
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class Listener {
|
|||
$userId = $result['value']['shareWith'];
|
||||
|
||||
try {
|
||||
$participant = $this->room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($this->room, $userId, false);
|
||||
if ($participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) {
|
||||
// do list self-joined users so they can be added as permanent participants by moderators
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ use OCA\Talk\Manager;
|
|||
use OCA\Talk\Model\Attendee;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\Collaboration\Collaborators\ISearchPlugin;
|
||||
use OCP\Collaboration\Collaborators\ISearchResult;
|
||||
use OCP\Collaboration\Collaborators\SearchResultType;
|
||||
|
|
@ -35,13 +36,15 @@ use OCP\IUserSession;
|
|||
use OCP\Share\IShare;
|
||||
|
||||
class RoomPlugin implements ISearchPlugin {
|
||||
private Manager $manager;
|
||||
|
||||
private IUserSession $userSession;
|
||||
protected Manager $manager;
|
||||
protected ParticipantService $participantService;
|
||||
protected IUserSession $userSession;
|
||||
|
||||
public function __construct(Manager $manager,
|
||||
ParticipantService $participantService,
|
||||
IUserSession $userSession) {
|
||||
$this->manager = $manager;
|
||||
$this->participantService = $participantService;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +67,7 @@ class RoomPlugin implements ISearchPlugin {
|
|||
continue;
|
||||
}
|
||||
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
if (!$participant instanceof Participant || !($participant->getPermissions() & Attendee::PERMISSIONS_CHAT)) {
|
||||
// No chat permissions is like read-only
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ use OCA\Talk\Manager;
|
|||
use OCA\Talk\Model\Attendee;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\Collaboration\Reference\IReference;
|
||||
use OCP\Collaboration\Reference\IReferenceProvider;
|
||||
use OCP\Collaboration\Reference\Reference;
|
||||
|
|
@ -45,6 +46,7 @@ use OCP\IURLGenerator;
|
|||
class TalkReferenceProvider implements IReferenceProvider {
|
||||
protected IURLGenerator $urlGenerator;
|
||||
protected Manager $roomManager;
|
||||
protected ParticipantService $participantService;
|
||||
protected ChatManager $chatManager;
|
||||
protected MessageParser $messageParser;
|
||||
protected IL10N $l;
|
||||
|
|
@ -52,12 +54,14 @@ class TalkReferenceProvider implements IReferenceProvider {
|
|||
|
||||
public function __construct(IURLGenerator $urlGenerator,
|
||||
Manager $manager,
|
||||
ParticipantService $participantService,
|
||||
ChatManager $chatManager,
|
||||
MessageParser $messageParser,
|
||||
IL10N $l,
|
||||
?string $userId) {
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->roomManager = $manager;
|
||||
$this->participantService = $participantService;
|
||||
$this->chatManager = $chatManager;
|
||||
$this->messageParser = $messageParser;
|
||||
$this->l = $l;
|
||||
|
|
@ -152,7 +156,7 @@ class TalkReferenceProvider implements IReferenceProvider {
|
|||
|
||||
$room = $this->roomManager->getRoomForUserByToken($referenceMatch['token'], $this->userId);
|
||||
try {
|
||||
$participant = $room->getParticipant($this->userId);
|
||||
$participant = $this->participantService->getParticipant($room, $this->userId);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
$participant = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ use OCA\Talk\Exceptions\RoomNotFoundException;
|
|||
use OCA\Talk\Manager;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\Collaboration\Resources\IProvider;
|
||||
use OCP\Collaboration\Resources\IResource;
|
||||
use OCP\Collaboration\Resources\ResourceException;
|
||||
|
|
@ -37,13 +38,16 @@ use OCP\IUserSession;
|
|||
|
||||
class ConversationProvider implements IProvider {
|
||||
protected Manager $manager;
|
||||
protected ParticipantService $participantService;
|
||||
protected IUserSession $userSession;
|
||||
protected IURLGenerator $urlGenerator;
|
||||
|
||||
public function __construct(Manager $manager,
|
||||
ParticipantService $participantService,
|
||||
IUserSession $userSession,
|
||||
IURLGenerator $urlGenerator) {
|
||||
$this->manager = $manager;
|
||||
$this->participantService = $participantService;
|
||||
$this->userSession = $userSession;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
|
@ -89,7 +93,7 @@ class ConversationProvider implements IProvider {
|
|||
|
||||
// Logged in users need to have a regular participant,
|
||||
// before they can do anything with the room.
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
return $participant->getAttendee()->getParticipantType() !== Participant::USER_SELF_JOINED;
|
||||
} catch (RoomNotFoundException $e) {
|
||||
throw new ResourceException('Conversation not found');
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ trait TRoomCommand {
|
|||
*/
|
||||
protected function setRoomOwner(Room $room, string $userId): void {
|
||||
try {
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
throw new InvalidArgumentException(sprintf("User '%s' is no participant.", $userId));
|
||||
}
|
||||
|
|
@ -278,7 +278,7 @@ trait TRoomCommand {
|
|||
}
|
||||
|
||||
try {
|
||||
$room->getParticipant($user->getUID(), false);
|
||||
$this->participantService->getParticipant($room, $user->getUID(), false);
|
||||
|
||||
// nothing to do, user is a participant already
|
||||
continue;
|
||||
|
|
@ -306,7 +306,7 @@ trait TRoomCommand {
|
|||
$users = [];
|
||||
foreach ($userIds as $userId) {
|
||||
try {
|
||||
$room->getParticipant($userId, false);
|
||||
$this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
throw new InvalidArgumentException(sprintf("User '%s' is no participant.", $userId));
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ trait TRoomCommand {
|
|||
}
|
||||
|
||||
try {
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
throw new InvalidArgumentException(sprintf("User '%s' is no participant.", $userId));
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ trait TRoomCommand {
|
|||
$participants = [];
|
||||
foreach ($userIds as $userId) {
|
||||
try {
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
throw new InvalidArgumentException(sprintf("User '%s' is no participant.", $userId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ use OCA\Talk\Config;
|
|||
use OCA\Talk\Manager;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCA\Talk\Service\RoomService;
|
||||
use OCA\Talk\TalkSession;
|
||||
use OCA\Talk\TInitialState;
|
||||
|
|
@ -70,6 +71,7 @@ class PageController extends Controller {
|
|||
private IUserSession $userSession;
|
||||
private LoggerInterface $logger;
|
||||
private Manager $manager;
|
||||
private ParticipantService $participantService;
|
||||
private RoomService $roomService;
|
||||
private IURLGenerator $url;
|
||||
private INotificationManager $notificationManager;
|
||||
|
|
@ -86,6 +88,7 @@ class PageController extends Controller {
|
|||
?string $UserId,
|
||||
LoggerInterface $logger,
|
||||
Manager $manager,
|
||||
ParticipantService $participantService,
|
||||
RoomService $roomService,
|
||||
IURLGenerator $url,
|
||||
INotificationManager $notificationManager,
|
||||
|
|
@ -104,6 +107,7 @@ class PageController extends Controller {
|
|||
$this->userId = $UserId;
|
||||
$this->logger = $logger;
|
||||
$this->manager = $manager;
|
||||
$this->participantService = $participantService;
|
||||
$this->roomService = $roomService;
|
||||
$this->url = $url;
|
||||
$this->notificationManager = $notificationManager;
|
||||
|
|
@ -220,7 +224,7 @@ class PageController extends Controller {
|
|||
if ($room instanceof Room && $room->hasPassword()) {
|
||||
// If the user joined themselves or is not found, they need the password.
|
||||
try {
|
||||
$participant = $room->getParticipant($this->userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $this->userId, false);
|
||||
$requirePassword = $participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED;
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
$requirePassword = true;
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
$return = [];
|
||||
foreach ($rooms as $room) {
|
||||
try {
|
||||
$return[] = $this->formatRoom($room, $room->getParticipant($this->userId), $statuses);
|
||||
$return[] = $this->formatRoom($room, $this->participantService->getParticipant($room, $this->userId), $statuses);
|
||||
} catch (RoomNotFoundException $e) {
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
// for example in case the room was deleted concurrently,
|
||||
|
|
@ -289,7 +289,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
|
||||
$participant = null;
|
||||
try {
|
||||
$participant = $room->getParticipant($this->userId, $sessionId);
|
||||
$participant = $this->participantService->getParticipant($room, $this->userId, $sessionId);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
try {
|
||||
$participant = $this->participantService->getParticipantBySession($room, $sessionId);
|
||||
|
|
@ -695,7 +695,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
$room = $this->manager->getOne2OneRoom($currentUser->getUID(), $targetUser->getUID());
|
||||
$this->participantService->ensureOneToOneRoomIsFilled($room);
|
||||
return new DataResponse(
|
||||
$this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)),
|
||||
$this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)),
|
||||
Http::STATUS_OK
|
||||
);
|
||||
} catch (RoomNotFoundException $e) {
|
||||
|
|
@ -704,7 +704,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
try {
|
||||
$room = $this->roomService->createOneToOneConversation($currentUser, $targetUser);
|
||||
return new DataResponse(
|
||||
$this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)),
|
||||
$this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)),
|
||||
Http::STATUS_CREATED
|
||||
);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
|
|
@ -739,7 +739,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
$room = $this->roomService->createConversation(Room::TYPE_GROUP, $name, $currentUser);
|
||||
$this->participantService->addGroup($room, $targetGroup);
|
||||
|
||||
return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)), Http::STATUS_CREATED);
|
||||
return new DataResponse($this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)), Http::STATUS_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -771,7 +771,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
$room = $this->roomService->createConversation(Room::TYPE_GROUP, $name, $currentUser);
|
||||
$this->participantService->addCircle($room, $circle);
|
||||
|
||||
return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)), Http::STATUS_CREATED);
|
||||
return new DataResponse($this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)), Http::STATUS_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -796,7 +796,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
return new DataResponse([], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
|
||||
return new DataResponse($this->formatRoom($room, $room->getParticipant($currentUser->getUID(), false)), Http::STATUS_CREATED);
|
||||
return new DataResponse($this->formatRoom($room, $this->participantService->getParticipant($room, $currentUser->getUID(), false)), Http::STATUS_CREATED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1364,7 +1364,7 @@ class RoomController extends AEnvironmentAwareController {
|
|||
$previousSession = null;
|
||||
if ($this->userId !== null) {
|
||||
try {
|
||||
$previousParticipant = $room->getParticipant($this->userId, $sessionId);
|
||||
$previousParticipant = $this->participantService->getParticipant($room, $this->userId, $sessionId);
|
||||
$previousSession = $previousParticipant->getSession();
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ class SignalingController extends OCSController {
|
|||
if ($this->userId) {
|
||||
// For logged in users we check if they are still part of the public conversation,
|
||||
// if not they were removed instead of having a conflict.
|
||||
$room->getParticipant($this->userId, false);
|
||||
$this->participantService->getParticipant($room, $this->userId, false);
|
||||
}
|
||||
|
||||
// Session was killed, make the UI redirect to an error
|
||||
|
|
@ -642,7 +642,7 @@ class SignalingController extends OCSController {
|
|||
} elseif (!empty($userId)) {
|
||||
// User trying to join room.
|
||||
try {
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace OCA\Talk\Dashboard;
|
|||
use OCA\Talk\Chat\MessageParser;
|
||||
use OCA\Talk\Manager;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\Dashboard\IAPIWidget;
|
||||
use OCP\Dashboard\IButtonWidget;
|
||||
|
|
@ -41,20 +42,23 @@ use OCP\IURLGenerator;
|
|||
use OCP\Util;
|
||||
|
||||
class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidget {
|
||||
private IURLGenerator $url;
|
||||
private IL10N $l10n;
|
||||
private Manager $manager;
|
||||
private MessageParser $messageParser;
|
||||
protected IURLGenerator $url;
|
||||
protected IL10N $l10n;
|
||||
protected Manager $manager;
|
||||
protected ParticipantService $participantService;
|
||||
protected MessageParser $messageParser;
|
||||
|
||||
public function __construct(
|
||||
IURLGenerator $url,
|
||||
IL10N $l10n,
|
||||
Manager $manager,
|
||||
ParticipantService $participantService,
|
||||
MessageParser $messageParser
|
||||
) {
|
||||
$this->url = $url;
|
||||
$this->l10n = $l10n;
|
||||
$this->manager = $manager;
|
||||
$this->participantService = $participantService;
|
||||
$this->messageParser = $messageParser;
|
||||
}
|
||||
|
||||
|
|
@ -128,8 +132,8 @@ class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidge
|
|||
public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
|
||||
$rooms = $this->manager->getRoomsForUser($userId, [], true);
|
||||
|
||||
$rooms = array_filter($rooms, static function (Room $room) use ($userId) {
|
||||
$participant = $room->getParticipant($userId);
|
||||
$rooms = array_filter($rooms, function (Room $room) use ($userId) {
|
||||
$participant = $this->participantService->getParticipant($room, $userId);
|
||||
$attendee = $participant->getAttendee();
|
||||
return $room->getLastMessage() && $room->getLastMessage()->getId() > $attendee->getLastReadMessage();
|
||||
});
|
||||
|
|
@ -147,7 +151,7 @@ class TalkWidget implements IAPIWidget, IIconWidget, IButtonWidget, IOptionWidge
|
|||
}
|
||||
|
||||
protected function prepareRoom(Room $room, string $userId): WidgetItem {
|
||||
$participant = $room->getParticipant($userId);
|
||||
$participant = $this->participantService->getParticipant($room, $userId);
|
||||
$subtitle = '';
|
||||
|
||||
$lastMessage = $room->getLastMessage();
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class Listener {
|
|||
}
|
||||
|
||||
try {
|
||||
$room->getParticipant($userId, false);
|
||||
$this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
$user = $this->userManager->get($userId);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ use OCA\Talk\Manager as TalkManager;
|
|||
use OCA\Talk\Model\Attendee;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
|
|
@ -53,22 +54,25 @@ class Operation implements IOperation {
|
|||
'ROOM_MENTION' => 3,
|
||||
];
|
||||
|
||||
private IL10N $l;
|
||||
private IURLGenerator $urlGenerator;
|
||||
private TalkManager $talkManager;
|
||||
private IUserSession $session;
|
||||
private ChatManager $chatManager;
|
||||
protected IL10N $l;
|
||||
protected IURLGenerator $urlGenerator;
|
||||
protected TalkManager $talkManager;
|
||||
protected ParticipantService $participantService;
|
||||
protected IUserSession $session;
|
||||
protected ChatManager $chatManager;
|
||||
|
||||
public function __construct(
|
||||
IL10N $l,
|
||||
IURLGenerator $urlGenerator,
|
||||
TalkManager $talkManager,
|
||||
ParticipantService $participantService,
|
||||
IUserSession $session,
|
||||
ChatManager $chatManager
|
||||
) {
|
||||
$this->l = $l;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->talkManager = $talkManager;
|
||||
$this->participantService = $participantService;
|
||||
$this->session = $session;
|
||||
$this->chatManager = $chatManager;
|
||||
}
|
||||
|
|
@ -122,7 +126,7 @@ class Operation implements IOperation {
|
|||
continue;
|
||||
}
|
||||
|
||||
$participant = $this->getParticipant($uid, $room);
|
||||
$participant = $this->participantService->getParticipant($room, $uid, false);
|
||||
if (!($participant->getPermissions() & Attendee::PERMISSIONS_CHAT)) {
|
||||
// Ignore conversation because the user has no permissions
|
||||
continue;
|
||||
|
|
@ -214,7 +218,7 @@ class Operation implements IOperation {
|
|||
|
||||
if ($mode === self::MESSAGE_MODES['ROOM_MENTION']) {
|
||||
try {
|
||||
$participant = $this->getParticipant($uid, $room);
|
||||
$participant = $this->participantService->getParticipant($room, $uid, false);
|
||||
if (!$participant->hasModeratorPermissions(false)) {
|
||||
throw new UnexpectedValueException('Not allowed to mention room');
|
||||
}
|
||||
|
|
@ -241,11 +245,4 @@ class Operation implements IOperation {
|
|||
protected function getRoom(string $token, string $uid): Room {
|
||||
return $this->talkManager->getRoomForUserByToken($token, $uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ParticipantNotFoundException
|
||||
*/
|
||||
protected function getParticipant(string $uid, Room $room): Participant {
|
||||
return $room->getParticipant($uid, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class BeforeUserLoggedOutListener implements IEventListener {
|
|||
foreach ($sessionIds as $sessionId) {
|
||||
try {
|
||||
$room = $this->manager->getRoomForSession($user->getUID(), $sessionId);
|
||||
$participant = $room->getParticipant($user->getUID(), $sessionId);
|
||||
$participant = $this->participantService->getParticipant($room, $user->getUID(), $sessionId);
|
||||
if ($participant->getSession() && $participant->getSession()->getInCall() !== Participant::FLAG_DISCONNECTED) {
|
||||
$this->participantService->changeInCall($room, $participant, Participant::FLAG_DISCONNECTED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class GroupMembershipListener extends AMembershipListener {
|
|||
|
||||
foreach ($rooms as $room) {
|
||||
try {
|
||||
$participant = $room->getParticipant($user->getUID());
|
||||
$participant = $this->participantService->getParticipant($room, $user->getUID());
|
||||
if ($participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) {
|
||||
$this->participantService->updateParticipantType($room, $participant, Participant::USER);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -889,7 +889,7 @@ class Manager {
|
|||
$room = $this->createRoomObject($row);
|
||||
|
||||
try {
|
||||
$room->getParticipant($userId, false);
|
||||
$this->participantService->getParticipant($room, $userId, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
$user = $this->userManager->get($userId);
|
||||
$this->participantService->addUsers($room, [[
|
||||
|
|
@ -1019,7 +1019,7 @@ class Manager {
|
|||
$sessionId = $this->talkSession->getSessionForRoom($room->getToken());
|
||||
$this->participantService->getParticipantBySession($room, $sessionId);
|
||||
} else {
|
||||
$room->getParticipant($userId, false);
|
||||
$this->participantService->getParticipant($room, $userId, false);
|
||||
}
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
// Do not leak the name of rooms the user is not a part of
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ class MatterbridgeManager {
|
|||
|
||||
// check if the bot user is member of the room and add or remove it
|
||||
try {
|
||||
$room->getParticipant(self::BRIDGE_BOT_USERID, false);
|
||||
$this->participantService->getParticipant($room, self::BRIDGE_BOT_USERID, false);
|
||||
if (!$isBridgeEnabled) {
|
||||
$this->participantService->removeUser($room, $botUser, Room::PARTICIPANT_REMOVED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class InjectionMiddleware extends Middleware {
|
|||
$room = $this->manager->getRoomForUserByToken($token, $this->userId, $sessionId);
|
||||
$controller->setRoom($room);
|
||||
|
||||
$participant = $room->getParticipant($this->userId, $sessionId);
|
||||
$participant = $this->participantService->getParticipant($room, $this->userId, $sessionId);
|
||||
$controller->setParticipant($participant);
|
||||
|
||||
if ($moderatorRequired && !$participant->hasModeratorPermissions(false)) {
|
||||
|
|
@ -180,7 +180,7 @@ class InjectionMiddleware extends Middleware {
|
|||
}
|
||||
|
||||
if ($participant === null) {
|
||||
$participant = $room->getParticipant($this->userId);
|
||||
$participant = $this->participantService->getParticipant($room, $this->userId);
|
||||
}
|
||||
|
||||
$controller->setParticipant($participant);
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class Notifier implements INotifier {
|
|||
}
|
||||
|
||||
try {
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $this->participantService->getParticipant($room, $userId, false);
|
||||
$this->participants[$roomId][$userId] = $participant;
|
||||
return $participant;
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
|
|
|
|||
|
|
@ -91,15 +91,15 @@ class Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
$participantService = Server::get(ParticipantService::class);
|
||||
try {
|
||||
$participant = $room->getParticipant($userId, false);
|
||||
$participant = $participantService->getParticipant($room, $userId, false);
|
||||
if ($participant->getAttendee()->getParticipantType() === Participant::OWNER) {
|
||||
return;
|
||||
}
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
}
|
||||
|
||||
$participantService = Server::get(ParticipantService::class);
|
||||
if ($participantService->getNumberOfActors($room) > 1) {
|
||||
throw new RoomNotFoundException('Only the owner and another participant are allowed in rooms to request the password for a share');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -535,6 +535,7 @@ class Room {
|
|||
* null to try loading "any"
|
||||
* @return Participant
|
||||
* @throws ParticipantNotFoundException When the user is not a participant
|
||||
* @deprecated
|
||||
*/
|
||||
public function getParticipant(?string $userId, $sessionId = null): Participant {
|
||||
if (!is_string($userId) || $userId === '') {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class CurrentMessageSearch extends MessageSearch {
|
|||
}
|
||||
|
||||
try {
|
||||
$participant = $room->getParticipant($user->getUID(), false);
|
||||
$participant = $this->participantService->getParticipant($room, $user->getUID(), false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
return SearchResult::complete(
|
||||
$this->l->t('Messages'),
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use OCA\Talk\Exceptions\UnauthorizedException;
|
|||
use OCA\Talk\Manager as RoomManager;
|
||||
use OCA\Talk\Model\Attendee;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCA\Talk\Webinary;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\IL10N;
|
||||
|
|
@ -43,6 +44,7 @@ use OCP\Search\SearchResultEntry;
|
|||
|
||||
class MessageSearch implements IProvider {
|
||||
protected RoomManager $roomManager;
|
||||
protected ParticipantService $participantService;
|
||||
protected ChatManager $chatManager;
|
||||
protected MessageParser $messageParser;
|
||||
protected IURLGenerator $url;
|
||||
|
|
@ -50,12 +52,14 @@ class MessageSearch implements IProvider {
|
|||
|
||||
public function __construct(
|
||||
RoomManager $roomManager,
|
||||
ParticipantService $participantService,
|
||||
ChatManager $chatManager,
|
||||
MessageParser $messageParser,
|
||||
IURLGenerator $url,
|
||||
IL10N $l
|
||||
) {
|
||||
$this->roomManager = $roomManager;
|
||||
$this->participantService = $participantService;
|
||||
$this->chatManager = $chatManager;
|
||||
$this->messageParser = $messageParser;
|
||||
$this->url = $url;
|
||||
|
|
@ -122,7 +126,7 @@ class MessageSearch implements IProvider {
|
|||
}
|
||||
|
||||
if ($room->getLobbyState() !== Webinary::LOBBY_NONE) {
|
||||
$participant = $room->getParticipant($user->getUID(), false);
|
||||
$participant = $this->participantService->getParticipant($room, $user->getUID(), false);
|
||||
if (!($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -165,7 +169,7 @@ class MessageSearch implements IProvider {
|
|||
}
|
||||
|
||||
protected function commentToSearchResultEntry(Room $room, IUser $user, IComment $comment, ISearchQuery $query): SearchResultEntry {
|
||||
$participant = $room->getParticipant($user->getUID(), false);
|
||||
$participant = $this->participantService->getParticipant($room, $user->getUID(), false);
|
||||
|
||||
$id = (int) $comment->getId();
|
||||
$message = $this->messageParser->createMessage($room, $participant, $comment, $this->l);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ class ParticipantService {
|
|||
private ITimeFactory $timeFactory;
|
||||
private ICacheFactory $cacheFactory;
|
||||
|
||||
protected array $userCache;
|
||||
protected array $sessionCache;
|
||||
|
||||
public function __construct(IConfig $serverConfig,
|
||||
Config $talkConfig,
|
||||
AttendeeMapper $attendeeMapper,
|
||||
|
|
@ -775,7 +778,7 @@ class ParticipantService {
|
|||
$attendees = [];
|
||||
foreach ($users as $user) {
|
||||
try {
|
||||
$participant = $room->getParticipant($user->getUID());
|
||||
$participant = $this->getParticipant($room, $user->getUID());
|
||||
$participantType = $participant->getAttendee()->getParticipantType();
|
||||
|
||||
$attendees[] = $participant->getAttendee();
|
||||
|
|
@ -838,7 +841,7 @@ class ParticipantService {
|
|||
$attendees = [];
|
||||
foreach ($users as $user) {
|
||||
try {
|
||||
$participant = $room->getParticipant($user->getUID());
|
||||
$participant = $this->getParticipant($room, $user->getUID());
|
||||
$participantType = $participant->getAttendee()->getParticipantType();
|
||||
|
||||
$attendees[] = $participant->getAttendee();
|
||||
|
|
@ -856,7 +859,7 @@ class ParticipantService {
|
|||
|
||||
public function removeUser(Room $room, IUser $user, string $reason): void {
|
||||
try {
|
||||
$participant = $room->getParticipant($user->getUID(), false);
|
||||
$participant = $this->getParticipant($room, $user->getUID(), false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1495,6 +1498,66 @@ class ParticipantService {
|
|||
return $pin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Room $room
|
||||
* @param string|null $userId
|
||||
* @param string|null|false $sessionId Set to false if you don't want to load a session (and save resources),
|
||||
* string to try loading a specific session
|
||||
* null to try loading "any"
|
||||
* @return Participant
|
||||
* @throws ParticipantNotFoundException When the user is not a participant
|
||||
*/
|
||||
public function getParticipant(Room $room, ?string $userId, $sessionId = null): Participant {
|
||||
if (!is_string($userId) || $userId === '') {
|
||||
throw new ParticipantNotFoundException('Not a user');
|
||||
}
|
||||
|
||||
if (isset($this->userCache[$room->getId()][$userId])) {
|
||||
$participant = $this->userCache[$room->getId()][$userId];
|
||||
if (!$sessionId
|
||||
|| ($participant->getSession() instanceof Session
|
||||
&& $participant->getSession()->getSessionId() === $sessionId)) {
|
||||
return $participant;
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
$helper = new SelectHelper();
|
||||
$helper->selectAttendeesTable($query);
|
||||
$query->from('talk_attendees', 'a')
|
||||
->where($query->expr()->eq('a.actor_type', $query->createNamedParameter(Attendee::ACTOR_USERS)))
|
||||
->andWhere($query->expr()->eq('a.actor_id', $query->createNamedParameter($userId)))
|
||||
->andWhere($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId())))
|
||||
->setMaxResults(1);
|
||||
|
||||
if ($sessionId !== false) {
|
||||
if ($sessionId !== null) {
|
||||
$helper->selectSessionsTable($query);
|
||||
$query->leftJoin('a', 'talk_sessions', 's', $query->expr()->andX(
|
||||
$query->expr()->eq('s.session_id', $query->createNamedParameter($sessionId)),
|
||||
$query->expr()->eq('a.id', 's.attendee_id')
|
||||
));
|
||||
} else {
|
||||
$helper->selectSessionsTable($query); // FIXME PROBLEM
|
||||
$query->leftJoin('a', 'talk_sessions', 's', $query->expr()->eq('a.id', 's.attendee_id'));
|
||||
}
|
||||
}
|
||||
|
||||
$participant = $this->getParticipantFromQuery($query, $room);
|
||||
|
||||
$this->userCache ??= [];
|
||||
$this->userCache[$room->getId()] ??= [];
|
||||
$this->userCache[$room->getId()][$userId] = $participant;
|
||||
if ($participant->getSession()) {
|
||||
$participantSessionId = $participant->getSession()->getSessionId();
|
||||
$this->sessionCache ??= [];
|
||||
$this->sessionCache[$room->getId()] ??= [];
|
||||
$this->sessionCache[$room->getId()][$participantSessionId] = $participant;
|
||||
}
|
||||
|
||||
return $participant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Room $room
|
||||
* @param string|null $sessionId
|
||||
|
|
@ -1564,7 +1627,7 @@ class ParticipantService {
|
|||
*/
|
||||
public function getParticipantByActor(Room $room, string $actorType, string $actorId): Participant {
|
||||
if ($actorType === Attendee::ACTOR_USERS) {
|
||||
return $room->getParticipant($actorId, false);
|
||||
return $this->getParticipant($room, $actorId, false);
|
||||
}
|
||||
|
||||
$query = $this->connection->getQueryBuilder();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ use OCA\Talk\Exceptions\ParticipantNotFoundException;
|
|||
use OCA\Talk\Exceptions\RoomNotFoundException;
|
||||
use OCA\Talk\Manager;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\AppFramework\OCS\OCSNotFoundException;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IL10N;
|
||||
|
|
@ -41,21 +42,24 @@ use OCP\Share\IShare;
|
|||
* actions or checks specific to room shares.
|
||||
*/
|
||||
class ShareAPIController {
|
||||
private string $userId;
|
||||
private Manager $manager;
|
||||
protected string $userId;
|
||||
protected Manager $manager;
|
||||
protected ParticipantService $participantService;
|
||||
protected ITimeFactory $timeFactory;
|
||||
private IL10N $l;
|
||||
private IURLGenerator $urlGenerator;
|
||||
protected IL10N $l;
|
||||
protected IURLGenerator $urlGenerator;
|
||||
|
||||
public function __construct(
|
||||
string $UserId,
|
||||
Manager $manager,
|
||||
ParticipantService $participantService,
|
||||
ITimeFactory $timeFactory,
|
||||
IL10N $l10n,
|
||||
IURLGenerator $urlGenerator
|
||||
) {
|
||||
$this->userId = $UserId;
|
||||
$this->manager = $manager;
|
||||
$this->participantService = $participantService;
|
||||
$this->timeFactory = $timeFactory;
|
||||
$this->l = $l10n;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
|
|
@ -80,7 +84,7 @@ class ShareAPIController {
|
|||
|
||||
$result['share_with_displayname'] = $room->getDisplayName($this->userId);
|
||||
try {
|
||||
$room->getParticipant($this->userId, false);
|
||||
$this->participantService->getParticipant($room, $this->userId, false);
|
||||
$result['share_with_link'] = $this->urlGenerator->linkToRouteAbsolute('spreed.Page.showCall', ['token' => $room->getToken()]);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
// Removing the conversation token from the leaked data if not a participant.
|
||||
|
|
@ -163,7 +167,7 @@ class ShareAPIController {
|
|||
}
|
||||
|
||||
try {
|
||||
$room->getParticipant($user, false);
|
||||
$this->participantService->getParticipant($room, $user, false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
}
|
||||
|
||||
try {
|
||||
$participant = $room->getParticipant($share->getSharedBy(), false);
|
||||
$participant = $this->participantService->getParticipant($room, $share->getSharedBy(), false);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
// If the sharer is not a participant of the room even if the room
|
||||
// exists the error is still "Room not found".
|
||||
|
|
|
|||
|
|
@ -129,9 +129,9 @@ class NotifierTest extends TestCase {
|
|||
/** @var Room|MockObject */
|
||||
$room = $this->createMock(Room::class);
|
||||
|
||||
$room->expects($this->any())
|
||||
$this->participantService->expects($this->any())
|
||||
->method('getParticipant')
|
||||
->willReturnCallback(function (string $actorId) use ($room, $settings): Participant {
|
||||
->willReturnCallback(function (Room $room, string $actorId) use ($settings): Participant {
|
||||
if ($actorId === 'userNotInOneToOneChat') {
|
||||
throw new ParticipantNotFoundException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use OCA\Talk\Manager;
|
|||
use OCA\Talk\Model\Attendee;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\Collaboration\Collaborators\ISearchResult;
|
||||
use OCP\Collaboration\Collaborators\SearchResultType;
|
||||
use OCP\IUser;
|
||||
|
|
@ -39,6 +40,8 @@ use Test\TestCase;
|
|||
|
||||
class RoomPluginTest extends TestCase {
|
||||
protected ?Manager $manager = null;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
|
||||
protected ?IUserSession $userSession = null;
|
||||
|
||||
|
|
@ -52,6 +55,7 @@ class RoomPluginTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->manager = $this->createMock(Manager::class);
|
||||
$this->participantService = $this->createMock(ParticipantService::class);
|
||||
|
||||
$this->user = $this->createMock(IUser::class);
|
||||
$this->user->expects($this->any())
|
||||
|
|
@ -64,7 +68,11 @@ class RoomPluginTest extends TestCase {
|
|||
|
||||
$this->searchResult = $this->createMock(ISearchResult::class);
|
||||
|
||||
$this->plugin = new RoomPlugin($this->manager, $this->userSession);
|
||||
$this->plugin = new RoomPlugin(
|
||||
$this->manager,
|
||||
$this->participantService,
|
||||
$this->userSession
|
||||
);
|
||||
}
|
||||
|
||||
private function newRoom(int $type, string $token, string $name, int $permissions = Attendee::PERMISSIONS_MAX_DEFAULT): Room {
|
||||
|
|
@ -83,7 +91,7 @@ class RoomPluginTest extends TestCase {
|
|||
->method('getDisplayName')
|
||||
->willReturn($name);
|
||||
|
||||
$room->expects($this->any())
|
||||
$this->participantService->expects($this->any())
|
||||
->method('getParticipant')
|
||||
->willReturn($participant);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ use OCA\Talk\Chat\ChatManager;
|
|||
use OCA\Talk\Chat\MessageParser;
|
||||
use OCA\Talk\Collaboration\Reference\TalkReferenceProvider;
|
||||
use OCA\Talk\Manager;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
|
@ -38,6 +39,8 @@ class TalkReferenceProviderTest extends TestCase {
|
|||
protected $urlGenerator;
|
||||
/** @var Manager|MockObject */
|
||||
protected $roomManager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var ChatManager|MockObject */
|
||||
protected $chatManager;
|
||||
/** @var MessageParser|MockObject */
|
||||
|
|
@ -51,6 +54,7 @@ class TalkReferenceProviderTest extends TestCase {
|
|||
|
||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->roomManager = $this->createMock(Manager::class);
|
||||
$this->participantService = $this->createMock(ParticipantService::class);
|
||||
$this->chatManager = $this->createMock(ChatManager::class);
|
||||
$this->messageParser = $this->createMock(MessageParser::class);
|
||||
$this->l = $this->createMock(IL10N::class);
|
||||
|
|
@ -58,6 +62,7 @@ class TalkReferenceProviderTest extends TestCase {
|
|||
$this->provider = new TalkReferenceProvider(
|
||||
$this->urlGenerator,
|
||||
$this->roomManager,
|
||||
$this->participantService,
|
||||
$this->chatManager,
|
||||
$this->messageParser,
|
||||
$this->l,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use OCA\Talk\Manager;
|
|||
use OCA\Talk\Model\Attendee;
|
||||
use OCA\Talk\Participant;
|
||||
use OCA\Talk\Room;
|
||||
use OCA\Talk\Service\ParticipantService;
|
||||
use OCP\Collaboration\Resources\IResource;
|
||||
use OCP\Collaboration\Resources\ResourceException;
|
||||
use OCP\IURLGenerator;
|
||||
|
|
@ -41,6 +42,8 @@ use Test\TestCase;
|
|||
class ConversationProviderTest extends TestCase {
|
||||
/** @var Manager|MockObject */
|
||||
protected $manager;
|
||||
/** @var ParticipantService|MockObject */
|
||||
protected $participantService;
|
||||
/** @var IUserSession|MockObject */
|
||||
protected $userSession;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
|
|
@ -51,11 +54,13 @@ class ConversationProviderTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->manager = $this->createMock(Manager::class);
|
||||
$this->participantService = $this->createMock(ParticipantService::class);
|
||||
$this->userSession = $this->createMock(IUserSession::class);
|
||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
|
||||
$this->provider = new ConversationProvider(
|
||||
$this->manager,
|
||||
$this->participantService,
|
||||
$this->userSession,
|
||||
$this->urlGenerator
|
||||
);
|
||||
|
|
@ -98,9 +103,9 @@ class ConversationProviderTest extends TestCase {
|
|||
->method('getId')
|
||||
->willReturn('token');
|
||||
$room = $this->createMock(Room::class);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with('uid')
|
||||
->with($room, 'uid')
|
||||
->willThrowException(new ParticipantNotFoundException());
|
||||
|
||||
$this->manager->expects($this->once())
|
||||
|
|
@ -132,9 +137,9 @@ class ConversationProviderTest extends TestCase {
|
|||
->method('getAttendee')
|
||||
->willReturn($attendee);
|
||||
$room = $this->createMock(Room::class);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with('uid')
|
||||
->with($room, 'uid')
|
||||
->willReturn($participant);
|
||||
|
||||
$this->manager->expects($this->once())
|
||||
|
|
@ -177,9 +182,9 @@ class ConversationProviderTest extends TestCase {
|
|||
->method('getAttendee')
|
||||
->willReturn($attendee);
|
||||
$room = $this->createMock(Room::class);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with('uid')
|
||||
->with($room, 'uid')
|
||||
->willReturn($participant);
|
||||
|
||||
$this->manager->expects($this->once())
|
||||
|
|
|
|||
|
|
@ -403,9 +403,9 @@ class SignalingControllerTest extends TestCase {
|
|||
$participant->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(Attendee::PERMISSIONS_MAX_CUSTOM);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with($this->userId)
|
||||
->with($room, $this->userId)
|
||||
->willReturn($participant);
|
||||
$room->expects($this->once())
|
||||
->method('getToken')
|
||||
|
|
@ -464,9 +464,9 @@ class SignalingControllerTest extends TestCase {
|
|||
$participant->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(Attendee::PERMISSIONS_MAX_CUSTOM);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with($this->userId)
|
||||
->with($room, $this->userId)
|
||||
->willReturn($participant);
|
||||
$room->expects($this->once())
|
||||
->method('getToken')
|
||||
|
|
@ -529,9 +529,9 @@ class SignalingControllerTest extends TestCase {
|
|||
->method('hasModeratorPermissions')
|
||||
->with(false)
|
||||
->willReturn(true);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with($this->userId)
|
||||
->with($room, $this->userId)
|
||||
->willReturn($participant);
|
||||
$room->expects($this->once())
|
||||
->method('getToken')
|
||||
|
|
@ -734,9 +734,9 @@ class SignalingControllerTest extends TestCase {
|
|||
$participant->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn($permissions);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with($this->userId)
|
||||
->with($room, $this->userId)
|
||||
->willReturn($participant);
|
||||
$room->expects($this->once())
|
||||
->method('getToken')
|
||||
|
|
@ -829,9 +829,9 @@ class SignalingControllerTest extends TestCase {
|
|||
$participant->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(Attendee::PERMISSIONS_MAX_CUSTOM);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with($this->userId)
|
||||
->with($room, $this->userId)
|
||||
->willReturn($participant);
|
||||
$room->expects($this->atLeastOnce())
|
||||
->method('getToken')
|
||||
|
|
@ -1020,7 +1020,7 @@ class SignalingControllerTest extends TestCase {
|
|||
'action' => 'join',
|
||||
],
|
||||
]);
|
||||
$participant = $room->getParticipant($this->userId, $oldSessionId);
|
||||
$participant = $participantService->getParticipant($room, $this->userId, $oldSessionId);
|
||||
$this->assertEquals($oldSessionId, $participant->getSession()->getSessionId());
|
||||
|
||||
// The user is reloading the browser which will join him with another
|
||||
|
|
@ -1038,7 +1038,7 @@ class SignalingControllerTest extends TestCase {
|
|||
]);
|
||||
|
||||
// Now the new session id is stored in the database.
|
||||
$participant = $room->getParticipant($this->userId, $newSessionId);
|
||||
$participant = $participantService->getParticipant($room, $this->userId, $newSessionId);
|
||||
$this->assertEquals($newSessionId, $participant->getSession()->getSessionId());
|
||||
|
||||
// Leaving the old session id...
|
||||
|
|
@ -1053,7 +1053,7 @@ class SignalingControllerTest extends TestCase {
|
|||
]);
|
||||
|
||||
// ...will keep the new session id in the database.
|
||||
$participant = $room->getParticipant($this->userId, $newSessionId);
|
||||
$participant = $participantService->getParticipant($room, $this->userId, $newSessionId);
|
||||
$this->assertEquals($newSessionId, $participant->getSession()->getSessionId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,9 +247,9 @@ class NotifierTest extends TestCase {
|
|||
->willReturn($room);
|
||||
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with('recipient')
|
||||
->with($room, 'recipient')
|
||||
->willReturn($participant);
|
||||
|
||||
$this->lFactory->expects($this->exactly($numNotifications))
|
||||
|
|
@ -868,9 +868,9 @@ class NotifierTest extends TestCase {
|
|||
->willReturn($roomName);
|
||||
|
||||
$participant = $this->createMock(Participant::class);
|
||||
$room->expects($this->once())
|
||||
$this->participantService->expects($this->once())
|
||||
->method('getParticipant')
|
||||
->with('recipient')
|
||||
->with($room, 'recipient')
|
||||
->willReturn($participant);
|
||||
|
||||
if ($roomName !== '') {
|
||||
|
|
|
|||
|
|
@ -985,7 +985,7 @@ class BackendNotifierTest extends TestCase {
|
|||
'actorId' => $notJoinedUserId,
|
||||
]]);
|
||||
|
||||
$notJoinedParticipant = $room->getParticipant($notJoinedUserId);
|
||||
$notJoinedParticipant = $this->participantService->getParticipant($room, $notJoinedUserId);
|
||||
$this->participantService->updateParticipantType($room, $notJoinedParticipant, Participant::MODERATOR);
|
||||
|
||||
$this->assertMessageWasSent($room, [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue