Browse Source

Don't error when a user is already a member

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/4810/head
Joas Schilling 5 years ago
parent
commit
0253a69f87
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 17
      lib/Listener/GroupMembershipListener.php
  2. 2
      lib/Service/ParticipantService.php

17
lib/Listener/GroupMembershipListener.php

@ -23,8 +23,10 @@ declare(strict_types=1);
namespace OCA\Talk\Listener;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCA\Talk\Service\ParticipantService;
use OCP\EventDispatcher\Event;
@ -65,10 +67,17 @@ class GroupMembershipListener implements IEventListener {
$rooms = $this->manager->getRoomsForActor(Attendee::ACTOR_GROUPS, $group->getGID());
foreach ($rooms as $room) {
$this->participantService->addUsers($room, [[
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $user->getUID(),
]]);
try {
$participant = $room->getParticipant($user->getUID());
if ($participant->getAttendee()->getParticipantType() === Participant::USER_SELF_JOINED) {
$this->participantService->updateParticipantType($room, $participant, Participant::USER);
}
} catch (ParticipantNotFoundException $e) {
$this->participantService->addUsers($room, [[
'actorType' => Attendee::ACTOR_USERS,
'actorId' => $user->getUID(),
]]);
}
}
}

2
lib/Service/ParticipantService.php

@ -316,7 +316,7 @@ class ParticipantService {
$usersInGroup = $group->getUsers();
if (empty($existingParticipants)) {
$participants = $this->getParticipantsForRoom($room);
$existingParticipants = $this->getParticipantsForRoom($room);
}
$participantsByUserId = [];

Loading…
Cancel
Save