<?php
declare(strict_types=1);
/**
* @author Joachim Bauch <mail@joachim-bauch.de>
*
* @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 OCA\Talk\Events\BeforeTurnServersGetEvent;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Service\RecordingService;
use OCA\Talk\Vendor\Firebase\JWT\JWT;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
class Config {
public const SIGNALING_INTERNAL = 'internal';
public const SIGNALING_EXTERNAL = 'external';
public const SIGNALING_CLUSTER_CONVERSATION = 'conversation_cluster';
public const SIGNALING_TICKET_V1 = 1;
public const SIGNALING_TICKET_V2 = 2;
/**
* Currently limiting to 1k users because the user_status API would yield
* an error on Oracle otherwise. Clients should use a virtual scrolling
* mechanism so the data should not be a problem nowadays
*/
public const USER_STATUS_INTEGRATION_LIMIT = 1000;
/** @var array<string, bool> */
protected array $canEnableSIP = [];
public function __construct(
protected IConfig $config,
private ISecureRandom $secureRandom,
private IGroupManager $groupManager,
private IUserManager $userManager,
private IURLGenerator $urlGenerator,
protected ITimeFactory $timeFactory,
private IEventDispatcher $dispatcher,
) {
}
/**
* @return string[]
*/
public function getAllowedTalkGroupIds(): array {
$groups = $this->config->getAppValue('spreed', 'allowed_groups', '[]');
$groups = json_decode($groups, true);
return \is_array($groups) ? $groups : [];
}
public function getUserReadPrivacy(string $userId): int {
return (int) $this->config->getUserValue(
$userId,
'spreed', 'read_status_privacy',
(string) Participant::PRIVACY_PUBLIC);
}
public function getUserTypingPrivacy(string $userId): int {
return (int) $this->config->getUserValue(
$userId,
'spreed', 'typing_privacy',
(string) Participant::PRIVACY_PUBLIC);
}
/**
* @return string[]
*/
public function getSIPGroups(): array {
$groups = $this->config->getAppValue('spreed', 'sip_bridge_groups', '[]');
$groups = json_decode($groups, true);
return \is_array($groups) ? $groups : [];
}
public function isSIPConfigured(): bool {