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
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-09-17 14:45:32 +0300
committerJoas Schilling <coding@schilljs.com>2021-09-17 14:50:56 +0300
commit8cc3a13f915ced711c22240017d269fdd1a4b9ab (patch)
tree1c4074cd43c11ae22fe515cb08c7f8a450772ba9 /lib
parent783a46bdebdaf26889c1faac7933aee796280a9e (diff)
Don't error hard when adding users to room
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Service/ParticipantService.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php
index 03d7f927a..c158e45fb 100644
--- a/lib/Service/ParticipantService.php
+++ b/lib/Service/ParticipantService.php
@@ -51,6 +51,7 @@ use OCA\Talk\Webinary;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\IComment;
+use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
@@ -339,15 +340,22 @@ class ParticipantService {
$attendee->setParticipantType($participant['participantType'] ?? Participant::USER);
$attendee->setLastReadMessage($lastMessage);
$attendee->setReadPrivacy($readPrivacy);
- $this->attendeeMapper->insert($attendee);
-
- $attendees[] = $attendee;
+ try {
+ $this->attendeeMapper->insert($attendee);
+ $attendees[] = $attendee;
+ } catch (Exception $e) {
+ if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
+ throw $e;
+ }
+ }
}
- $attendeeEvent = new AttendeesAddedEvent($room, $attendees);
- $this->dispatcher->dispatchTyped($attendeeEvent);
+ if (!empty($attendees)) {
+ $attendeeEvent = new AttendeesAddedEvent($room, $attendees);
+ $this->dispatcher->dispatchTyped($attendeeEvent);
- $this->dispatcher->dispatch(Room::EVENT_AFTER_USERS_ADD, $event);
+ $this->dispatcher->dispatch(Room::EVENT_AFTER_USERS_ADD, $event);
+ }
}
/**