diff options
author | Joas Schilling <coding@schilljs.com> | 2019-12-05 20:06:32 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-12-20 12:52:52 +0300 |
commit | f0293227a9a05290301a71d7a51847943cf2a30c (patch) | |
tree | 23cb3876aaf63ad2d2606b2f7b87b494b287b7e2 /lib | |
parent | 6f19e9ddfd42736d4b918111b79a15052527fe15 (diff) |
Allow to add circles to existing conversations
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/RoomController.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 302b6470a..b676c9432 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -725,6 +725,40 @@ class RoomController extends AEnvironmentAwareController { } \call_user_func_array([$this->room, 'addUsers'], $participantsToAdd); + } else if ($source === 'circles') { + if (!$this->appManager->isEnabledForUser('circles')) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + + /** @var Circles $circlesApi */ + try { + $circle = Circles::detailsCircle($newParticipant); + } catch (\Exception $e) { + return new DataResponse([], Http::STATUS_NOT_FOUND); + } + + $participants = []; + foreach ($circle->getMembers() as $member) { + /** @var Member $member */ + if ($member->getUserId() === '') { + // Not a user? + continue; + } + + if (\in_array($member->getUserId(), $participants, true)) { + continue; + } + + $participantsToAdd[] = [ + 'userId' => $member->getUserId(), + ]; + } + + if (empty($participantsToAdd)) { + return new DataResponse([]); + } + + \call_user_func_array([$this->room, 'addUsers'], $participantsToAdd); } else if ($source === 'emails') { $data = []; if ($this->room->setType(Room::PUBLIC_CALL)) { |