<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Julien Veyssier <eneiluj@posteo.net>
*
* @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Talk;
use OC\Authentication\Token\IProvider as IAuthTokenProvider;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Events\AAttendeeRemovedEvent;
use OCA\Talk\Exceptions\ImpossibleToKillException;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Exceptions\WrongPermissionsException;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Service\ParticipantService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Authentication\Token\IToken;
use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IAvatarManager;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;
/**
* @psalm-import-type TalkMatterbridge from ResponseDefinitions
* @psalm-import-type TalkMatterbridgeProcessState from ResponseDefinitions
*/
class MatterbridgeManager {
public const BRIDGE_BOT_USERID = 'bridge-bot';
public function __construct(
private IDBConnection $db,
private IConfig $config,
private IURLGenerator $urlGenerator,
private IUserManager $userManager,
private Manager $manager,
private ParticipantService $participantService,
private ChatManager $chatManager,
private IAuthTokenProvider $tokenProvider,
private ISecureRandom $random,
private IAvatarManager $avatarManager,
private LoggerInterface $logger,
private ITimeFactory $timeFactory,
) {
}
/**
* Get bridge information for a specific room
*
* @param Room $room the room
* @return TalkMatterbridge
*/
public function getBridgeOfRoom(Room $room): array {
return $this->getBridgeFromDb($room);
}
/**
* Get bridge process information for a specific room
*
* @param Room $room the room
* @return TalkMatterbridgeProcessState process state and log
*/
public function getBridgeProcessState(Room $room): array {
$bridge = $this->getBridgeFromDb($room);
$logContent = $this->getBridgeLog($room);
$pid = $this->checkBridgeProcess($room, $bridge, false);