mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Make all classes strict
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
af59422720
commit
fb90a74231
56 changed files with 354 additions and 517 deletions
|
|
@ -47,7 +47,11 @@ class Hooks {
|
|||
/** @var ITimeFactory */
|
||||
protected $timeFactory;
|
||||
|
||||
public function __construct(IManager $activityManager, IUserSession $userSession, ChatManager $chatManager, ILogger $logger, ITimeFactory $timeFactory) {
|
||||
public function __construct(IManager $activityManager,
|
||||
IUserSession $userSession,
|
||||
ChatManager $chatManager,
|
||||
ILogger $logger,
|
||||
ITimeFactory $timeFactory) {
|
||||
$this->activityManager = $activityManager;
|
||||
$this->userSession = $userSession;
|
||||
$this->chatManager = $chatManager;
|
||||
|
|
@ -55,12 +59,7 @@ class Hooks {
|
|||
$this->timeFactory = $timeFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark the user as (in)active for a call
|
||||
*
|
||||
* @param Room $room
|
||||
*/
|
||||
public function setActive(Room $room) {
|
||||
public function setActive(Room $room): void {
|
||||
$room->setActiveSince(new \DateTime(), !$this->userSession->isLoggedIn());
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +132,7 @@ class Hooks {
|
|||
* @param Room $room
|
||||
* @param array[] $participants
|
||||
*/
|
||||
public function generateInvitationActivity(Room $room, array $participants) {
|
||||
public function generateInvitationActivity(Room $room, array $participants): void {
|
||||
$actor = $this->userSession->getUser();
|
||||
if (!$actor instanceof IUser) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ abstract class Base implements IProvider {
|
|||
/** @var string[] */
|
||||
protected $displayNames = [];
|
||||
|
||||
public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, Manager $manager) {
|
||||
public function __construct(IFactory $languageFactory,
|
||||
IURLGenerator $url,
|
||||
IManager $activityManager,
|
||||
IUserManager $userManager,
|
||||
Manager $manager) {
|
||||
$this->languageFactory = $languageFactory;
|
||||
$this->url = $url;
|
||||
$this->activityManager = $activityManager;
|
||||
|
|
@ -86,7 +90,7 @@ abstract class Base implements IProvider {
|
|||
* @param array $parameters
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function setSubjects(IEvent $event, string $subject, array $parameters) {
|
||||
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
|
||||
$placeholders = $replacements = [];
|
||||
foreach ($parameters as $placeholder => $parameter) {
|
||||
$placeholders[] = '{' . $placeholder . '}';
|
||||
|
|
@ -97,11 +101,6 @@ abstract class Base implements IProvider {
|
|||
->setRichSubject($subject, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
* @param Room $room
|
||||
* @return array
|
||||
*/
|
||||
protected function getRoom(IL10N $l, Room $room): array {
|
||||
switch ($room->getType()) {
|
||||
case Room::ONE_TO_ONE_CALL:
|
||||
|
|
@ -124,11 +123,6 @@ abstract class Base implements IProvider {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IL10N $l
|
||||
* @param int $roomId
|
||||
* @return array
|
||||
*/
|
||||
protected function getFormerRoom(IL10N $l, int $roomId): array {
|
||||
return [
|
||||
'type' => 'call',
|
||||
|
|
@ -138,10 +132,6 @@ abstract class Base implements IProvider {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uid
|
||||
* @return array
|
||||
*/
|
||||
protected function getUser(string $uid): array {
|
||||
if (!isset($this->displayNames[$uid])) {
|
||||
$this->displayNames[$uid] = $this->getDisplayName($uid);
|
||||
|
|
@ -154,10 +144,6 @@ abstract class Base implements IProvider {
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uid
|
||||
* @return string
|
||||
*/
|
||||
protected function getDisplayName(string $uid): string {
|
||||
$user = $this->userManager->get($uid);
|
||||
if ($user instanceof IUser) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Call extends Base {
|
|||
* @since 11.0.0
|
||||
*/
|
||||
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
|
||||
$event = parent::preParse($event);
|
||||
$event = $this->preParse($event);
|
||||
|
||||
if ($event->getSubject() === 'call') {
|
||||
$l = $this->languageFactory->get('spreed', $language);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Invitation extends Base {
|
|||
* @since 11.0.0
|
||||
*/
|
||||
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
|
||||
$event = parent::preParse($event);
|
||||
$event = $this->preParse($event);
|
||||
|
||||
if ($event->getSubject() === 'invitation') {
|
||||
$l = $this->languageFactory->get('spreed', $language);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @author Joachim Bauch <mail@joachim-bauch.de>
|
||||
*
|
||||
|
|
@ -37,7 +38,6 @@ use OCA\Spreed\Signaling\Messages;
|
|||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\IServerContainer;
|
||||
use OCP\Security\IContentSecurityPolicyManager;
|
||||
use OCP\Settings\IManager;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
|
@ -48,7 +48,7 @@ class Application extends App {
|
|||
parent::__construct('spreed', $urlParams);
|
||||
}
|
||||
|
||||
public function register() {
|
||||
public function register(): void {
|
||||
$server = $this->getContainer()->getServer();
|
||||
|
||||
$server->getUserManager()->listen('\OC\User', 'postDelete', function ($user) {
|
||||
|
|
@ -119,7 +119,7 @@ class Application extends App {
|
|||
});
|
||||
}
|
||||
|
||||
protected function registerClientLinks(IServerContainer $server) {
|
||||
protected function registerClientLinks(IServerContainer $server): void {
|
||||
if ($server->getAppManager()->isEnabledForUser('firstrunwizard')) {
|
||||
/** @var IManager $settingManager */
|
||||
$settingManager = $server->getSettingsManager();
|
||||
|
|
@ -127,7 +127,7 @@ class Application extends App {
|
|||
}
|
||||
}
|
||||
|
||||
protected function registerInternalSignalingHooks(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerInternalSignalingHooks(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -180,13 +180,12 @@ class Application extends App {
|
|||
$dispatcher->addListener(Room::class . '::postDeleteRoom', $listener);
|
||||
}
|
||||
|
||||
protected function getBackendNotifier() {
|
||||
protected function getBackendNotifier(): BackendNotifier {
|
||||
return $this->getContainer()->query(BackendNotifier::class);
|
||||
}
|
||||
|
||||
protected function registerSignalingBackendHooks(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerSignalingBackendHooks(EventDispatcherInterface $dispatcher): void {
|
||||
$dispatcher->addListener(Room::class . '::postAddUsers', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -194,14 +193,12 @@ class Application extends App {
|
|||
$notifier->roomInvited($room, $participants);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postSetName', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
$notifier->roomModified($room);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postSetParticipantType', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -210,7 +207,6 @@ class Application extends App {
|
|||
$notifier->roomModified($room);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postSetParticipantTypeBySession', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -219,7 +215,6 @@ class Application extends App {
|
|||
$notifier->roomModified($room);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postDeleteRoom', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -227,7 +222,6 @@ class Application extends App {
|
|||
$notifier->roomDeleted($room, $participants);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postRemoveUser', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -235,7 +229,6 @@ class Application extends App {
|
|||
$notifier->roomsDisinvited($room, [$user->getUID()]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postRemoveBySession', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -243,7 +236,6 @@ class Application extends App {
|
|||
$notifier->roomSessionsRemoved($room, [$participant->getSessionId()]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postSessionJoinCall', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -252,7 +244,6 @@ class Application extends App {
|
|||
$notifier->roomInCallChanged($room, $flags, [$sessionId]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postSessionLeaveCall', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -260,7 +251,6 @@ class Application extends App {
|
|||
$notifier->roomInCallChanged($room, Participant::FLAG_DISCONNECTED, [$sessionId]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postRemoveBySession', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -268,7 +258,6 @@ class Application extends App {
|
|||
$notifier->participantsModified($room, [$participant->getSessionId()]);
|
||||
});
|
||||
$dispatcher->addListener(Room::class . '::postCleanGuests', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -278,7 +267,6 @@ class Application extends App {
|
|||
$notifier->participantsModified($room, $sessionIds);
|
||||
});
|
||||
$dispatcher->addListener(GuestManager::class . '::updateName', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -286,7 +274,6 @@ class Application extends App {
|
|||
$notifier->participantsModified($room, [$sessionId]);
|
||||
});
|
||||
$dispatcher->addListener(ChatManager::class . '::sendMessage', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -299,7 +286,6 @@ class Application extends App {
|
|||
$notifier->sendRoomMessage($room, $message);
|
||||
});
|
||||
$dispatcher->addListener(ChatManager::class . '::sendSystemMessage', function(GenericEvent $event) {
|
||||
/** @var BackendNotifier $notifier */
|
||||
$notifier = $this->getBackendNotifier();
|
||||
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -313,7 +299,7 @@ class Application extends App {
|
|||
});
|
||||
}
|
||||
|
||||
protected function registerCallActivityHooks(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerCallActivityHooks(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -337,7 +323,7 @@ class Application extends App {
|
|||
$dispatcher->addListener(Room::class . '::postSessionLeaveCall', $listener);
|
||||
}
|
||||
|
||||
protected function registerRoomActivityHooks(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerRoomActivityHooks(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -348,7 +334,7 @@ class Application extends App {
|
|||
$dispatcher->addListener(ChatManager::class . '::sendSystemMessage', $listener);
|
||||
}
|
||||
|
||||
protected function registerRoomInvitationHook(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerRoomInvitationHook(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -374,7 +360,7 @@ class Application extends App {
|
|||
$dispatcher->addListener(Room::class . '::postJoinRoom', $listener);
|
||||
}
|
||||
|
||||
protected function registerCallNotificationHook(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerCallNotificationHook(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -396,7 +382,7 @@ class Application extends App {
|
|||
$dispatcher->addListener(Room::class . '::postSessionJoinCall', $listener);
|
||||
}
|
||||
|
||||
protected function registerChatHooks(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerChatHooks(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -408,7 +394,7 @@ class Application extends App {
|
|||
$dispatcher->addListener(Room::class . '::postDeleteRoom', $listener);
|
||||
}
|
||||
|
||||
protected function registerRoomHooks(EventDispatcherInterface $dispatcher) {
|
||||
protected function registerRoomHooks(EventDispatcherInterface $dispatcher): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -442,7 +428,7 @@ class Application extends App {
|
|||
$dispatcher->addListener(Room::class . '::postDeleteRoom', $listener);
|
||||
}
|
||||
|
||||
protected function extendDefaultContentSecurityPolicy(Config $config) {
|
||||
protected function extendDefaultContentSecurityPolicy(Config $config): void {
|
||||
$csp = new ContentSecurityPolicy();
|
||||
foreach ($config->getAllServerUrlsForCSP() as $server) {
|
||||
$csp->addAllowedConnectDomain($server);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -34,9 +35,6 @@ class ExpireSignalingMessage extends TimedJob {
|
|||
/** @var Messages */
|
||||
protected $messages;
|
||||
|
||||
/**
|
||||
* @param Messages $messages
|
||||
*/
|
||||
public function __construct(Messages $messages) {
|
||||
// Every 5 minutes
|
||||
$this->setInterval(60 * 5);
|
||||
|
|
@ -44,7 +42,7 @@ class ExpireSignalingMessage extends TimedJob {
|
|||
$this->messages = $messages;
|
||||
}
|
||||
|
||||
protected function run($argument) {
|
||||
protected function run($argument): void {
|
||||
$this->messages->expireOlderThan(5 * 60);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -41,7 +42,8 @@ class RemoveEmptyRooms extends TimedJob {
|
|||
|
||||
protected $numDeletedRooms = 0;
|
||||
|
||||
public function __construct(Manager $manager, ILogger $logger) {
|
||||
public function __construct(Manager $manager,
|
||||
ILogger $logger) {
|
||||
// Every 5 minutes
|
||||
$this->setInterval(60 * 5);
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ class RemoveEmptyRooms extends TimedJob {
|
|||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
protected function run($argument) {
|
||||
protected function run($argument): void {
|
||||
$this->manager->forAllRooms([$this, 'callback']);
|
||||
|
||||
if ($this->numDeletedRooms) {
|
||||
|
|
@ -60,7 +62,7 @@ class RemoveEmptyRooms extends TimedJob {
|
|||
}
|
||||
}
|
||||
|
||||
public function callback(Room $room) {
|
||||
public function callback(Room $room): void {
|
||||
if ($room->getType() === Room::ONE_TO_ONE_CALL && $room->getNumberOfParticipants(false) <= 1) {
|
||||
$room->deleteRoom();
|
||||
$this->numDeletedRooms++;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -37,19 +38,21 @@ class SearchPlugin implements ISearchPlugin {
|
|||
/** @var Util */
|
||||
protected $util;
|
||||
|
||||
/** @var string */
|
||||
/** @var string|null */
|
||||
protected $userId;
|
||||
|
||||
/** @var Room */
|
||||
protected $room;
|
||||
|
||||
public function __construct(IUserManager $userManager, Util $util, $userId) {
|
||||
public function __construct(IUserManager $userManager,
|
||||
Util $util,
|
||||
?string $userId) {
|
||||
$this->userManager = $userManager;
|
||||
$this->util = $util;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function setContext(array $context) {
|
||||
public function setContext(array $context): void {
|
||||
$this->room = $context['room'];
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +79,7 @@ class SearchPlugin implements ISearchPlugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function searchUsers($search, array $userIds, ISearchResult $searchResult) {
|
||||
protected function searchUsers(string $search, array $userIds, ISearchResult $searchResult): void {
|
||||
$search = strtolower($search);
|
||||
|
||||
$matches = $exactMatches = [];
|
||||
|
|
@ -96,7 +99,7 @@ class SearchPlugin implements ISearchPlugin {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (strpos(strtolower($userId), $search) !== false) {
|
||||
if (stripos($userId, $search) !== false) {
|
||||
$matches[] = $this->createResult('user', $userId, '');
|
||||
continue;
|
||||
}
|
||||
|
|
@ -111,7 +114,7 @@ class SearchPlugin implements ISearchPlugin {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (strpos(strtolower($user->getDisplayName()), $search) !== false) {
|
||||
if (stripos($user->getDisplayName(), $search) !== false) {
|
||||
$matches[] = $this->createResult('user', $user->getUID(), $user->getDisplayName());
|
||||
continue;
|
||||
}
|
||||
|
|
@ -121,13 +124,7 @@ class SearchPlugin implements ISearchPlugin {
|
|||
$searchResult->addResultSet($type, $matches, $exactMatches);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @param string $uid
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
protected function createResult($type, $uid, $name) {
|
||||
protected function createResult(string $type, string $uid, string $name): array {
|
||||
if ($type === 'user' && $name === '') {
|
||||
$user = $this->userManager->get($uid);
|
||||
if ($user instanceof IUser) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -49,7 +50,7 @@ class Sorter implements ISorter {
|
|||
* @param array $context carries key 'itemType' and 'itemId' of the source object (e.g. a file)
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function sort(array &$sortArray, array $context) {
|
||||
public function sort(array &$sortArray, array $context): void {
|
||||
foreach ($sortArray as $type => &$byType) {
|
||||
if ($type !== 'users') {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -50,11 +50,6 @@ class ChatManager {
|
|||
/** @var Notifier */
|
||||
private $notifier;
|
||||
|
||||
/**
|
||||
* @param CommentsManager $commentsManager
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param Notifier $notifier
|
||||
*/
|
||||
public function __construct(CommentsManager $commentsManager,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
Notifier $notifier) {
|
||||
|
|
@ -74,7 +69,7 @@ class ChatManager {
|
|||
* @param bool $sendNotifications
|
||||
* @return IComment
|
||||
*/
|
||||
public function addSystemMessage(Room $chat, $actorType, $actorId, $message, \DateTime $creationDateTime, bool $sendNotifications): IComment {
|
||||
public function addSystemMessage(Room $chat, string $actorType, string $actorId, string $message, \DateTime $creationDateTime, bool $sendNotifications): IComment {
|
||||
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
|
||||
$comment->setMessage($message);
|
||||
$comment->setCreationDateTime($creationDateTime);
|
||||
|
|
@ -108,7 +103,7 @@ class ChatManager {
|
|||
* @param \DateTime $creationDateTime
|
||||
* @return IComment
|
||||
*/
|
||||
public function sendMessage(Room $chat, $actorType, $actorId, $message, \DateTime $creationDateTime): IComment {
|
||||
public function sendMessage(Room $chat, string $actorType, string $actorId, string $message, \DateTime $creationDateTime): IComment {
|
||||
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
|
||||
$comment->setMessage($message);
|
||||
$comment->setCreationDateTime($creationDateTime);
|
||||
|
|
@ -184,7 +179,7 @@ class ChatManager {
|
|||
* creation date and message are relevant), or an empty array if the
|
||||
* timeout expired.
|
||||
*/
|
||||
public function waitForNewMessages(Room $chat, $offset, $limit, $timeout, $user): array {
|
||||
public function waitForNewMessages(Room $chat, int $offset, int $limit, int $timeout, ?IUser $user): array {
|
||||
if ($user instanceof IUser) {
|
||||
$this->notifier->markMentionNotificationsRead($chat, $user->getUID());
|
||||
}
|
||||
|
|
@ -211,7 +206,7 @@ class ChatManager {
|
|||
*
|
||||
* @param Room $chat
|
||||
*/
|
||||
public function deleteMessages(Room $chat) {
|
||||
public function deleteMessages(Room $chat): void {
|
||||
$this->commentsManager->deleteCommentsAtObject('chat', (string) $chat->getId());
|
||||
|
||||
$this->notifier->removePendingNotificationsForRoom($chat);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -46,12 +47,12 @@ class CommentsManager extends Manager {
|
|||
* @return array
|
||||
*/
|
||||
public function getLastCommentDateByActor(
|
||||
$objectType,
|
||||
$objectId,
|
||||
$verb,
|
||||
$actorType,
|
||||
string $objectType,
|
||||
string $objectId,
|
||||
string $verb,
|
||||
string $actorType,
|
||||
array $actors
|
||||
) {
|
||||
): array {
|
||||
$lastComments = [];
|
||||
|
||||
$query = $this->dbConn->getQueryBuilder();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -35,7 +36,7 @@ class Listener {
|
|||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function register() {
|
||||
public function register(): void {
|
||||
$this->dispatcher->addListener(MessageParser::class . '::parseMessage', function(GenericEvent $event) {
|
||||
/** @var IComment $chatMessage */
|
||||
$chatMessage = $event->getSubject();
|
||||
|
|
@ -46,7 +47,7 @@ class Listener {
|
|||
|
||||
/** @var UserMention $parser */
|
||||
$parser = \OC::$server->query(UserMention::class);
|
||||
list($message, $parameters) = $parser->parseMessage($chatMessage);
|
||||
[$message, $parameters] = $parser->parseMessage($chatMessage);
|
||||
|
||||
$event->setArguments([
|
||||
'message' => $message,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class MessageParser {
|
|||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function parseMessage(Room $room, IComment $chatMessage, IL10N $l, IUser $user = null): array {
|
||||
public function parseMessage(Room $room, IComment $chatMessage, IL10N $l, ?IUser $user): array {
|
||||
$event = new GenericEvent($chatMessage, [
|
||||
'room' => $room,
|
||||
'user' => $user,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -108,7 +108,7 @@ class Notifier {
|
|||
* @param IComment $comment
|
||||
* @param string[] $mentionedUsers
|
||||
*/
|
||||
public function notifyOtherParticipant(Room $chat, IComment $comment, array $mentionedUsers) {
|
||||
public function notifyOtherParticipant(Room $chat, IComment $comment, array $mentionedUsers): void {
|
||||
$participants = $chat->getParticipantsByNotificationLevel(Participant::NOTIFY_ALWAYS);
|
||||
|
||||
$notification = $this->createNotification($chat, $comment, 'chat');
|
||||
|
|
@ -168,7 +168,7 @@ class Notifier {
|
|||
*
|
||||
* @param Room $chat
|
||||
*/
|
||||
public function removePendingNotificationsForRoom(Room $chat) {
|
||||
public function removePendingNotificationsForRoom(Room $chat): void {
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
|
||||
// @todo this should be in the Notifications\Hooks
|
||||
|
|
@ -190,7 +190,7 @@ class Notifier {
|
|||
* @param Room $chat
|
||||
* @param string $userId
|
||||
*/
|
||||
public function markMentionNotificationsRead(Room $chat, $userId) {
|
||||
public function markMentionNotificationsRead(Room $chat, ?string $userId): void {
|
||||
|
||||
if ($userId === null || $userId === '') {
|
||||
return;
|
||||
|
|
@ -212,7 +212,7 @@ class Notifier {
|
|||
* @param IComment $comment
|
||||
* @return string[] the mentioned user IDs
|
||||
*/
|
||||
private function getMentionedUserIds(IComment $comment) {
|
||||
private function getMentionedUserIds(IComment $comment): array {
|
||||
$mentions = $comment->getMentions();
|
||||
|
||||
if (empty($mentions)) {
|
||||
|
|
@ -267,9 +267,9 @@ class Notifier {
|
|||
* @param IComment $comment
|
||||
* @return bool
|
||||
*/
|
||||
private function shouldUserBeNotified($userId, IComment $comment) {
|
||||
private function shouldUserBeNotified($userId, IComment $comment): bool {
|
||||
if ($userId === $comment->getActorId()) {
|
||||
// Do not notify the user if they mentioned themself
|
||||
// Do not notify the user if they mentioned themselves
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -78,13 +79,13 @@ class SystemMessage {
|
|||
$this->recipient = $this->userSession->getUser();
|
||||
}
|
||||
|
||||
public function setUserInfo(IL10N $l, IUser $user = null) {
|
||||
public function setUserInfo(IL10N $l, ?IUser $user): void {
|
||||
$this->l = $l;
|
||||
$this->recipient = $user;
|
||||
$this->sessionId = null;
|
||||
}
|
||||
|
||||
public function setGuestInfo(IL10N $l, string $sessionId = null) {
|
||||
public function setGuestInfo(IL10N $l, ?string $sessionId): void {
|
||||
$this->l = $l;
|
||||
$this->recipient = null;
|
||||
$this->sessionId = $sessionId;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ class UserMention {
|
|||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
public function __construct(ICommentsManager $commentsManager, IUserManager $userManager) {
|
||||
public function __construct(ICommentsManager $commentsManager,
|
||||
IUserManager $userManager) {
|
||||
$this->commentsManager = $commentsManager;
|
||||
$this->userManager = $userManager;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -51,7 +52,11 @@ class Listener {
|
|||
/** @var IUserSession */
|
||||
protected $userSession;
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher, ChatManager $chatManager, Manager $roomManager, TalkSession $talkSession, IUserSession $userSession) {
|
||||
public function __construct(EventDispatcherInterface $dispatcher,
|
||||
ChatManager $chatManager,
|
||||
Manager $roomManager,
|
||||
TalkSession $talkSession,
|
||||
IUserSession $userSession) {
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->chatManager = $chatManager;
|
||||
$this->roomManager = $roomManager;
|
||||
|
|
@ -59,7 +64,7 @@ class Listener {
|
|||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
public function register() {
|
||||
public function register(): void {
|
||||
$this->dispatcher->addListener(Room::class . '::preSessionJoinCall', function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -188,7 +193,7 @@ class Listener {
|
|||
}
|
||||
|
||||
try {
|
||||
list($message, $parameters) = $parser->parseMessage($chatMessage);
|
||||
[$message, $parameters] = $parser->parseMessage($chatMessage);
|
||||
|
||||
$event->setArguments([
|
||||
'message' => $message,
|
||||
|
|
@ -201,7 +206,7 @@ class Listener {
|
|||
});
|
||||
}
|
||||
|
||||
protected function sendSystemMessage(Room $room, string $message, array $parameters = []) {
|
||||
protected function sendSystemMessage(Room $room, string $message, array $parameters = []): void {
|
||||
$user = $this->userSession->getUser();
|
||||
if (!$user instanceof IUser) {
|
||||
$actorType = 'guests';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -40,11 +39,8 @@ class RoomPlugin implements ISearchPlugin {
|
|||
/** @var IUserSession */
|
||||
private $userSession;
|
||||
|
||||
/**
|
||||
* @param Manager manager
|
||||
* @param IUserSession userSession
|
||||
*/
|
||||
public function __construct(Manager $manager, IUserSession $userSession) {
|
||||
public function __construct(Manager $manager,
|
||||
IUserSession $userSession) {
|
||||
$this->manager = $manager;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
|
@ -52,7 +48,7 @@ class RoomPlugin implements ISearchPlugin {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function search($search, $limit, $offset, ISearchResult $searchResult) {
|
||||
public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
|
||||
if (empty($search)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,12 @@ class Add extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:signaling:add')
|
||||
->setDescription('Add an external signaling server.')
|
||||
|
|
@ -63,7 +61,7 @@ class Add extends Base {
|
|||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$server = $input->getArgument('server');
|
||||
$secret = $input->getArgument('secret');
|
||||
$verify = $input->getOption('verify');
|
||||
|
|
@ -97,5 +95,6 @@ class Add extends Base {
|
|||
|
||||
$this->config->setAppValue('spreed', 'signaling_servers', json_encode($signaling));
|
||||
$output->writeln('<info>Added signaling server ' . $server . '.</info>');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class Delete extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:signaling:delete')
|
||||
->setDescription('Remove an existing signaling server.')
|
||||
|
|
@ -53,7 +51,7 @@ class Delete extends Base {
|
|||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$server = $input->getArgument('server');
|
||||
|
||||
$config = $this->config->getAppValue('spreed', 'signaling_servers');
|
||||
|
|
@ -77,6 +75,6 @@ class Delete extends Base {
|
|||
} else {
|
||||
$output->writeln('<info>There is nothing to delete.</info>');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class ListCommand extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
|
|
@ -50,7 +48,7 @@ class ListCommand extends Base {
|
|||
->setDescription('List external signaling servers.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$config = $this->config->getAppValue('spreed', 'signaling_servers');
|
||||
$signaling = json_decode($config, true);
|
||||
if (!is_array($signaling)) {
|
||||
|
|
@ -58,5 +56,6 @@ class ListCommand extends Base {
|
|||
}
|
||||
|
||||
$this->writeMixedInOutputFormat($input, $output, $signaling);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class Add extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:stun:add')
|
||||
->setDescription('Add a new STUN server.')
|
||||
|
|
@ -53,7 +51,7 @@ class Add extends Base {
|
|||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$server = $input->getArgument('server');
|
||||
// check input, similar to stun-server.js
|
||||
$host = parse_url($server, PHP_URL_HOST);
|
||||
|
|
@ -74,5 +72,6 @@ class Add extends Base {
|
|||
|
||||
$this->config->setAppValue('spreed', 'stun_servers', json_encode($servers));
|
||||
$output->writeln('<info>Added ' . $server . '.</info>');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class Delete extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:stun:delete')
|
||||
->setDescription('Remove an existing STUN server.')
|
||||
|
|
@ -53,7 +51,7 @@ class Delete extends Base {
|
|||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$server = $input->getArgument('server');
|
||||
|
||||
$config = $this->config->getAppValue('spreed', 'stun_servers');
|
||||
|
|
@ -80,5 +78,6 @@ class Delete extends Base {
|
|||
$output->writeln('<info>There is nothing to delete.</info>');
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class ListCommand extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
|
|
@ -50,7 +48,7 @@ class ListCommand extends Base {
|
|||
->setDescription('List STUN servers.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$config = $this->config->getAppValue('spreed', 'stun_servers');
|
||||
$servers = json_decode($config);
|
||||
if (!is_array($servers)) {
|
||||
|
|
@ -58,5 +56,6 @@ class ListCommand extends Base {
|
|||
}
|
||||
|
||||
$this->writeArrayInOutputFormat($input, $output, $servers);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,12 @@ class Add extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:turn:add')
|
||||
->setDescription('Add a TURN server.')
|
||||
|
|
@ -68,7 +66,7 @@ class Add extends Base {
|
|||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$server = $input->getArgument('server');
|
||||
$protocols = $input->getArgument('protocols');
|
||||
$secret = $input->getOption('secret');
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class Delete extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('talk:turn:delete')
|
||||
->setDescription('Remove an existing TURN server.')
|
||||
|
|
@ -57,7 +55,7 @@ class Delete extends Base {
|
|||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$server = $input->getArgument('server');
|
||||
$protocols = $input->getArgument('protocols');
|
||||
|
||||
|
|
@ -81,5 +79,6 @@ class Delete extends Base {
|
|||
} else {
|
||||
$output->writeln('<info>There is nothing to delete.</info>');
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ class ListCommand extends Base {
|
|||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
protected function configure(): void {
|
||||
parent::configure();
|
||||
|
||||
$this
|
||||
|
|
@ -50,7 +48,7 @@ class ListCommand extends Base {
|
|||
->setDescription('List TURN servers.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
protected function execute(InputInterface $input, OutputInterface $output): ?int {
|
||||
$config = $this->config->getAppValue('spreed', 'turn_servers');
|
||||
$servers = json_decode($config, true);
|
||||
if (!is_array($servers)) {
|
||||
|
|
@ -58,5 +56,6 @@ class ListCommand extends Base {
|
|||
}
|
||||
|
||||
$this->writeMixedInOutputFormat($input, $output, $servers);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @author Joachim Bauch <mail@joachim-bauch.de>
|
||||
*
|
||||
|
|
@ -23,7 +24,6 @@ namespace OCA\Spreed;
|
|||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUser;
|
||||
use OCP\Security\ISecureRandom;
|
||||
|
||||
class Config {
|
||||
|
|
@ -37,13 +37,6 @@ class Config {
|
|||
/** @var ISecureRandom */
|
||||
private $secureRandom;
|
||||
|
||||
/**
|
||||
* Config constructor.
|
||||
*
|
||||
* @param IConfig $config
|
||||
* @param ISecureRandom $secureRandom
|
||||
* @param ITimeFactory $timeFactory
|
||||
*/
|
||||
public function __construct(IConfig $config,
|
||||
ISecureRandom $secureRandom,
|
||||
ITimeFactory $timeFactory) {
|
||||
|
|
@ -52,7 +45,7 @@ class Config {
|
|||
$this->timeFactory = $timeFactory;
|
||||
}
|
||||
|
||||
public function getSettings($userId) {
|
||||
public function getSettings(?string $userId): array {
|
||||
$stun = [];
|
||||
$stunServer = $this->getStunServer();
|
||||
if ($stunServer) {
|
||||
|
|
@ -233,7 +226,7 @@ class Config {
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSignalingSecret() {
|
||||
public function getSignalingSecret(): string {
|
||||
$config = $this->config->getAppValue('spreed', 'signaling_servers');
|
||||
$signaling = json_decode($config, true);
|
||||
|
||||
|
|
@ -248,7 +241,7 @@ class Config {
|
|||
* @param string $userId
|
||||
* @return string
|
||||
*/
|
||||
public function getSignalingTicket($userId) {
|
||||
public function getSignalingTicket(?string $userId): string {
|
||||
if (empty($userId)) {
|
||||
$secret = $this->config->getAppValue('spreed', 'signaling_ticket_secret');
|
||||
} else {
|
||||
|
|
@ -279,7 +272,7 @@ class Config {
|
|||
* @param string $ticket
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSignalingTicket($userId, $ticket) {
|
||||
public function validateSignalingTicket(?string $userId, string $ticket): bool {
|
||||
if (empty($userId)) {
|
||||
$secret = $this->config->getAppValue('spreed', 'signaling_ticket_secret');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright 2017 Ivan Sein <ivan@nextcloud.com>
|
||||
*
|
||||
|
|
@ -46,23 +46,17 @@ class CallProvider implements IProvider {
|
|||
/** @var IL10N */
|
||||
private $l10n;
|
||||
|
||||
/**
|
||||
* @param IActionFactory $actionFactory
|
||||
* @param IURLGenerator $urlGenerator
|
||||
* @param IUserManager $userManager
|
||||
* @param IL10N $l10n
|
||||
*/
|
||||
public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator, IL10N $l10n, IUserManager $userManager) {
|
||||
public function __construct(IActionFactory $actionFactory,
|
||||
IURLGenerator $urlGenerator,
|
||||
IL10N $l10n,
|
||||
IUserManager $userManager) {
|
||||
$this->actionFactory = $actionFactory;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->userManager = $userManager;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IEntry $entry
|
||||
*/
|
||||
public function process(IEntry $entry) {
|
||||
public function process(IEntry $entry): void {
|
||||
$uid = $entry->getProperty('UID');
|
||||
|
||||
if ($uid === null) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -56,7 +55,7 @@ class Listener {
|
|||
$this->util = $util;
|
||||
}
|
||||
|
||||
public function register() {
|
||||
public function register(): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -94,7 +93,7 @@ class Listener {
|
|||
* @param string $userId
|
||||
* @throws UnauthorizedException
|
||||
*/
|
||||
public function preventUsersWithoutDirectAccessToTheFileFromJoining(Room $room, string $userId) {
|
||||
public function preventUsersWithoutDirectAccessToTheFileFromJoining(Room $room, string $userId): void {
|
||||
if ($room->getObjectType() !== 'file') {
|
||||
return;
|
||||
}
|
||||
|
|
@ -113,7 +112,7 @@ class Listener {
|
|||
* @param Room $room
|
||||
* @throws UnauthorizedException
|
||||
*/
|
||||
public function preventGuestsFromJoining(Room $room) {
|
||||
public function preventGuestsFromJoining(Room $room): void {
|
||||
if ($room->getObjectType() !== 'file') {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -26,7 +25,6 @@ namespace OCA\Spreed\Files;
|
|||
|
||||
use OCP\Util;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
/**
|
||||
* Helper class to add the Talk UI to the sidebar of the Files app.
|
||||
|
|
@ -40,11 +38,8 @@ class TemplateLoader {
|
|||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function register() {
|
||||
$listener = function() {
|
||||
$this->loadTalkSidebarForFilesApp();
|
||||
};
|
||||
$this->dispatcher->addListener('OCA\Files::loadAdditionalScripts', $listener);
|
||||
public function register(): void {
|
||||
$this->dispatcher->addListener('OCA\Files::loadAdditionalScripts', [$this, 'loadTalkSidebarForFilesApp']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -53,7 +48,7 @@ class TemplateLoader {
|
|||
* This method should be called when loading additional scripts for the
|
||||
* Files app.
|
||||
*/
|
||||
public function loadTalkSidebarForFilesApp() {
|
||||
public static function loadTalkSidebarForFilesApp(): void {
|
||||
Util::addStyle('spreed', 'merged-files');
|
||||
Util::addScript('spreed', 'merged-files');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -39,14 +38,8 @@ class Util {
|
|||
/** @var array[] */
|
||||
private $accessLists = [];
|
||||
|
||||
/**
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param IShareManager $shareManager
|
||||
*/
|
||||
public function __construct(
|
||||
IRootFolder $rootFolder,
|
||||
IShareManager $shareManager
|
||||
) {
|
||||
public function __construct(IRootFolder $rootFolder,
|
||||
IShareManager $shareManager) {
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->shareManager = $shareManager;
|
||||
}
|
||||
|
|
@ -87,7 +80,7 @@ class Util {
|
|||
* @param string $userId
|
||||
* @return IShare|null
|
||||
*/
|
||||
public function getAnyDirectShareOfFileAccessibleByUser(string $fileId, string $userId) {
|
||||
public function getAnyDirectShareOfFileAccessibleByUser(string $fileId, string $userId): ?IShare {
|
||||
$userFolder = $this->rootFolder->getUserFolder($userId);
|
||||
$nodes = $userFolder->getById($fileId);
|
||||
if (empty($nodes)) {
|
||||
|
|
@ -122,7 +115,7 @@ class Util {
|
|||
* @param string $userId
|
||||
* @return IShare|null
|
||||
*/
|
||||
private function getAnyDirectShareOfNodeAccessibleByUser(Node $node, string $userId) {
|
||||
private function getAnyDirectShareOfNodeAccessibleByUser(Node $node, string $userId): ?IShare {
|
||||
$reshares = false;
|
||||
$limit = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class GuestManager {
|
|||
* @param string $displayName
|
||||
* @throws \Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public function updateName(Room $room, string $sessionId, string $displayName) {
|
||||
public function updateName(Room $room, string $sessionId, string $displayName): void {
|
||||
$sessionHash = sha1($sessionId);
|
||||
$dispatchEvent = true;
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ class GuestManager {
|
|||
return $map;
|
||||
}
|
||||
|
||||
public function inviteByEmail(Room $room, string $email) {
|
||||
public function inviteByEmail(Room $room, string $email): void {
|
||||
$this->dispatcher->dispatch(self::class . '::preInviteByEmail', new GenericEvent($room, [
|
||||
'email' => $email,
|
||||
]));
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class HookListener {
|
|||
/**
|
||||
* @param IUser $user
|
||||
*/
|
||||
public function deleteUser(IUser $user) {
|
||||
public function deleteUser(IUser $user): void {
|
||||
$rooms = $this->manager->getRoomsForParticipant($user->getUID());
|
||||
|
||||
foreach ($rooms as $room) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -47,17 +48,12 @@ class Manager {
|
|||
/** @var IHasher */
|
||||
private $hasher;
|
||||
|
||||
/**
|
||||
* Manager constructor.
|
||||
*
|
||||
* @param IDBConnection $db
|
||||
* @param IConfig $config
|
||||
* @param ISecureRandom $secureRandom
|
||||
* @param CommentsManager $commentsManager
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param IHasher $hasher
|
||||
*/
|
||||
public function __construct(IDBConnection $db, IConfig $config, ISecureRandom $secureRandom, CommentsManager $commentsManager, EventDispatcherInterface $dispatcher, IHasher $hasher) {
|
||||
public function __construct(IDBConnection $db,
|
||||
IConfig $config,
|
||||
ISecureRandom $secureRandom,
|
||||
CommentsManager $commentsManager,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
IHasher $hasher) {
|
||||
$this->db = $db;
|
||||
$this->config = $config;
|
||||
$this->secureRandom = $secureRandom;
|
||||
|
|
@ -66,7 +62,7 @@ class Manager {
|
|||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
public function forAllRooms(callable $callback) {
|
||||
public function forAllRooms(callable $callback): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_rooms');
|
||||
|
|
@ -83,7 +79,7 @@ class Manager {
|
|||
* @param array $row
|
||||
* @return Room
|
||||
*/
|
||||
public function createRoomObject(array $row) {
|
||||
public function createRoomObject(array $row): Room {
|
||||
$activeSince = null;
|
||||
if (!empty($row['active_since'])) {
|
||||
$activeSince = new \DateTime($row['active_since']);
|
||||
|
|
@ -115,7 +111,7 @@ class Manager {
|
|||
* @param array $row
|
||||
* @return Participant
|
||||
*/
|
||||
public function createParticipantObject(Room $room, array $row) {
|
||||
public function createParticipantObject(Room $room, array $row): Participant {
|
||||
$lastMention = null;
|
||||
if (!empty($row['last_mention'])) {
|
||||
$lastMention = new \DateTime($row['last_mention']);
|
||||
|
|
@ -129,7 +125,7 @@ class Manager {
|
|||
* @param bool $includeLastMessage
|
||||
* @return Room[]
|
||||
*/
|
||||
public function getRoomsForParticipant($participant, $includeLastMessage = false) {
|
||||
public function getRoomsForParticipant(string $participant, bool $includeLastMessage = false): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('r.*')->addSelect('p.*')
|
||||
->from('talk_rooms', 'r')
|
||||
|
|
@ -165,7 +161,7 @@ class Manager {
|
|||
* @return Room
|
||||
* @throws RoomNotFoundException
|
||||
*/
|
||||
public function getRoomForParticipant($roomId, $participant) {
|
||||
public function getRoomForParticipant(int $roomId, ?string $participant): Room {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_rooms', 'r')
|
||||
|
|
@ -210,7 +206,7 @@ class Manager {
|
|||
* @return Room
|
||||
* @throws RoomNotFoundException
|
||||
*/
|
||||
public function getRoomForParticipantByToken($token, $participant, $includeLastMessage = false) {
|
||||
public function getRoomForParticipantByToken(string $token, ?string $participant, bool $includeLastMessage = false): Room {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('r.*')
|
||||
->from('talk_rooms', 'r')
|
||||
|
|
@ -259,7 +255,7 @@ class Manager {
|
|||
* @return Room
|
||||
* @throws RoomNotFoundException
|
||||
*/
|
||||
public function getRoomById($roomId) {
|
||||
public function getRoomById(int $roomId): Room {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_rooms')
|
||||
|
|
@ -281,7 +277,7 @@ class Manager {
|
|||
* @return Room
|
||||
* @throws RoomNotFoundException
|
||||
*/
|
||||
public function getRoomByToken($token) {
|
||||
public function getRoomByToken(string $token): Room {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_rooms')
|
||||
|
|
@ -328,8 +324,8 @@ class Manager {
|
|||
* @return Room
|
||||
* @throws RoomNotFoundException
|
||||
*/
|
||||
public function getRoomForSession($userId, $sessionId) {
|
||||
if ((string) $sessionId === '' || $sessionId === '0') {
|
||||
public function getRoomForSession(?string $userId, string $sessionId): Room {
|
||||
if ($sessionId === '' || $sessionId === '0') {
|
||||
throw new RoomNotFoundException();
|
||||
}
|
||||
|
||||
|
|
@ -369,7 +365,7 @@ class Manager {
|
|||
* @return Room
|
||||
* @throws RoomNotFoundException
|
||||
*/
|
||||
public function getOne2OneRoom($participant1, $participant2) {
|
||||
public function getOne2OneRoom(string $participant1, string $participant2): Room {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_rooms', 'r1')
|
||||
|
|
@ -401,7 +397,7 @@ class Manager {
|
|||
* @param string $objectId
|
||||
* @return Room
|
||||
*/
|
||||
public function createOne2OneRoom($objectType = '', $objectId = '') {
|
||||
public function createOne2OneRoom(string $objectType = '', string $objectId = ''): Room {
|
||||
return $this->createRoom(Room::ONE_TO_ONE_CALL, '', $objectType, $objectId);
|
||||
}
|
||||
|
||||
|
|
@ -411,7 +407,7 @@ class Manager {
|
|||
* @param string $objectId
|
||||
* @return Room
|
||||
*/
|
||||
public function createGroupRoom($name = '', $objectType = '', $objectId = '') {
|
||||
public function createGroupRoom(string $name = '', string $objectType = '', string $objectId = ''): Room {
|
||||
return $this->createRoom(Room::GROUP_CALL, $name, $objectType, $objectId);
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +417,7 @@ class Manager {
|
|||
* @param string $objectId
|
||||
* @return Room
|
||||
*/
|
||||
public function createPublicRoom($name = '', $objectType = '', $objectId = '') {
|
||||
public function createPublicRoom(string $name = '', string $objectType = '', string $objectId = ''): Room {
|
||||
return $this->createRoom(Room::PUBLIC_CALL, $name, $objectType, $objectId);
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +428,7 @@ class Manager {
|
|||
* @param string $objectId
|
||||
* @return Room
|
||||
*/
|
||||
private function createRoom($type, $name = '', $objectType = '', $objectId = '') {
|
||||
private function createRoom(int $type, string $name = '', string $objectType = '', string $objectId = ''): Room {
|
||||
$token = $this->getNewToken();
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
|
|
@ -461,10 +457,10 @@ class Manager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $userId
|
||||
* @return string
|
||||
* @param string|null $userId
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCurrentSessionId($userId) {
|
||||
public function getCurrentSessionId(?string $userId): ?string {
|
||||
if (empty($userId)) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -491,7 +487,7 @@ class Manager {
|
|||
* @param string $userId
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSessionIdsForUser($userId) {
|
||||
public function getSessionIdsForUser(?string $userId): array {
|
||||
if (!is_string($userId) || $userId === '') {
|
||||
// No deleting messages for guests
|
||||
return [];
|
||||
|
|
@ -518,7 +514,7 @@ class Manager {
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getNewToken() {
|
||||
protected function getNewToken(): string {
|
||||
$chars = str_replace(['l', '0', '1'], '', ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
|
||||
$entropy = (int) $this->config->getAppValue('spreed', 'token_entropy', 8);
|
||||
$entropy = min(8, $entropy); // For update cases
|
||||
|
|
@ -557,7 +553,7 @@ class Manager {
|
|||
* @return string
|
||||
* @throws \OutOfBoundsException
|
||||
*/
|
||||
protected function generateNewToken(IQueryBuilder $query, $entropy, $chars) {
|
||||
protected function generateNewToken(IQueryBuilder $query, int $entropy, string $chars): string {
|
||||
$event = new GenericEvent(null, [
|
||||
'entropy' => $entropy,
|
||||
'chars' => $chars,
|
||||
|
|
@ -585,7 +581,7 @@ class Manager {
|
|||
return $token;
|
||||
}
|
||||
|
||||
protected function loadLastMessageInfo(IQueryBuilder $query) {
|
||||
protected function loadLastMessageInfo(IQueryBuilder $query): void {
|
||||
$query->leftJoin('r','comments', 'c', $query->expr()->eq('r.last_message', 'c.id'));
|
||||
$query->selectAlias('c.id', 'comment_id');
|
||||
$query->addSelect('c.actor_id', 'c.actor_type', 'c.message', 'c.creation_timestamp', 'c.verb');
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ class Hooks {
|
|||
/** @var ILogger */
|
||||
protected $logger;
|
||||
|
||||
public function __construct(IManager $notificationManager, IUserSession $userSession, ILogger $logger) {
|
||||
public function __construct(IManager $notificationManager,
|
||||
IUserSession $userSession,
|
||||
ILogger $logger) {
|
||||
$this->notificationManager = $notificationManager;
|
||||
$this->userSession = $userSession;
|
||||
$this->logger = $logger;
|
||||
|
|
@ -51,7 +53,7 @@ class Hooks {
|
|||
* @param Room $room
|
||||
* @param array[] $participants
|
||||
*/
|
||||
public function generateInvitation(Room $room, array $participants) {
|
||||
public function generateInvitation(Room $room, array $participants): void {
|
||||
$actor = $this->userSession->getUser();
|
||||
if (!$actor instanceof IUser) {
|
||||
return;
|
||||
|
|
@ -92,7 +94,7 @@ class Hooks {
|
|||
*
|
||||
* @param Room $room
|
||||
*/
|
||||
public function markInvitationRead(Room $room) {
|
||||
public function markInvitationRead(Room $room): void {
|
||||
$currentUser = $this->userSession->getUser();
|
||||
if (!$currentUser instanceof IUser) {
|
||||
return;
|
||||
|
|
@ -116,7 +118,7 @@ class Hooks {
|
|||
*
|
||||
* @param Room $room
|
||||
*/
|
||||
public function generateCallNotifications(Room $room) {
|
||||
public function generateCallNotifications(Room $room): void {
|
||||
if ($room->getActiveSince() instanceof \DateTime) {
|
||||
// Call already active => No new notifications
|
||||
return;
|
||||
|
|
@ -169,7 +171,7 @@ class Hooks {
|
|||
*
|
||||
* @param Room $room
|
||||
*/
|
||||
public function markCallNotificationsRead(Room $room) {
|
||||
public function markCallNotificationsRead(Room $room): void {
|
||||
$currentUser = $this->userSession->getUser();
|
||||
if (!$currentUser instanceof IUser) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class Notifier implements INotifier {
|
|||
}
|
||||
|
||||
$recipient = $this->userManager->get($notification->getUser());
|
||||
list($richMessage, $richMessageParameters) = $this->messageParser->parseMessage($room, $comment, $l, $recipient);
|
||||
[$richMessage, $richMessageParameters] = $this->messageParser->parseMessage($room, $comment, $l, $recipient);
|
||||
|
||||
$placeholders = $replacements = [];
|
||||
foreach ($richMessageParameters as $placeholder => $parameter) {
|
||||
|
|
@ -267,7 +267,7 @@ class Notifier implements INotifier {
|
|||
* @return string
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function getRoomType(Room $room) {
|
||||
protected function getRoomType(Room $room): string {
|
||||
switch ($room->getType()) {
|
||||
case Room::ONE_TO_ONE_CALL:
|
||||
return 'one2one';
|
||||
|
|
|
|||
|
|
@ -28,22 +28,22 @@ use OCP\DB\QueryBuilder\IQueryBuilder;
|
|||
use OCP\IDBConnection;
|
||||
|
||||
class Participant {
|
||||
const OWNER = 1;
|
||||
const MODERATOR = 2;
|
||||
const USER = 3;
|
||||
const GUEST = 4;
|
||||
const USER_SELF_JOINED = 5;
|
||||
const GUEST_MODERATOR = 6;
|
||||
public const OWNER = 1;
|
||||
public const MODERATOR = 2;
|
||||
public const USER = 3;
|
||||
public const GUEST = 4;
|
||||
public const USER_SELF_JOINED = 5;
|
||||
public const GUEST_MODERATOR = 6;
|
||||
|
||||
const FLAG_DISCONNECTED = 0;
|
||||
const FLAG_IN_CALL = 1;
|
||||
const FLAG_WITH_AUDIO = 2;
|
||||
const FLAG_WITH_VIDEO = 4;
|
||||
public const FLAG_DISCONNECTED = 0;
|
||||
public const FLAG_IN_CALL = 1;
|
||||
public const FLAG_WITH_AUDIO = 2;
|
||||
public const FLAG_WITH_VIDEO = 4;
|
||||
|
||||
const NOTIFY_DEFAULT = 0;
|
||||
const NOTIFY_ALWAYS = 1;
|
||||
const NOTIFY_MENTION = 2;
|
||||
const NOTIFY_NEVER = 3;
|
||||
public const NOTIFY_DEFAULT = 0;
|
||||
public const NOTIFY_ALWAYS = 1;
|
||||
public const NOTIFY_MENTION = 2;
|
||||
public const NOTIFY_NEVER = 3;
|
||||
|
||||
/** @var IDBConnection */
|
||||
protected $db;
|
||||
|
|
@ -66,7 +66,16 @@ class Participant {
|
|||
/** @var \DateTime|null */
|
||||
private $lastMention;
|
||||
|
||||
public function __construct(IDBConnection $db, Room $room, string $user, int $participantType, int $lastPing, string $sessionId, int $inCall, int $notificationLevel, bool $isFavorite, \DateTime $lastMention = null) {
|
||||
public function __construct(IDBConnection $db,
|
||||
Room $room,
|
||||
string $user,
|
||||
int $participantType,
|
||||
int $lastPing,
|
||||
string $sessionId,
|
||||
int $inCall,
|
||||
int $notificationLevel,
|
||||
bool $isFavorite,
|
||||
\DateTime $lastMention = null) {
|
||||
$this->db = $db;
|
||||
$this->room = $room;
|
||||
$this->user = $user;
|
||||
|
|
@ -114,7 +123,7 @@ class Participant {
|
|||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getLastMention() {
|
||||
public function getLastMention(): ?\DateTime {
|
||||
return $this->lastMention;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -52,7 +51,7 @@ class Listener {
|
|||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function register() {
|
||||
public function register(): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var Room $room */
|
||||
$room = $event->getSubject();
|
||||
|
|
@ -88,7 +87,7 @@ class Listener {
|
|||
* @param string $userId
|
||||
* @throws \OverflowException
|
||||
*/
|
||||
public function preventExtraUsersFromJoining(Room $room, string $userId) {
|
||||
public function preventExtraUsersFromJoining(Room $room, string $userId): void {
|
||||
if ($room->getObjectType() !== 'share:password') {
|
||||
return;
|
||||
}
|
||||
|
|
@ -115,7 +114,7 @@ class Listener {
|
|||
* @param Room $room
|
||||
* @throws \OverflowException
|
||||
*/
|
||||
public function preventExtraGuestsFromJoining(Room $room) {
|
||||
public function preventExtraGuestsFromJoining(Room $room): void {
|
||||
if ($room->getObjectType() !== 'share:password') {
|
||||
return;
|
||||
}
|
||||
|
|
@ -135,7 +134,7 @@ class Listener {
|
|||
*
|
||||
* @param Room $room
|
||||
*/
|
||||
public function destroyRoomOnParticipantLeave(Room $room) {
|
||||
public function destroyRoomOnParticipantLeave(Room $room): void {
|
||||
if ($room->getObjectType() !== 'share:password') {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -45,7 +44,7 @@ class TemplateLoader {
|
|||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
public function register() {
|
||||
public function register(): void {
|
||||
$listener = function(GenericEvent $event) {
|
||||
/** @var IShare $share */
|
||||
$share = $event->getArgument('share');
|
||||
|
|
@ -66,7 +65,7 @@ class TemplateLoader {
|
|||
*
|
||||
* @param IShare $share
|
||||
*/
|
||||
public function loadRequestPasswordByTalkUi(IShare $share) {
|
||||
public function loadRequestPasswordByTalkUi(IShare $share): void {
|
||||
if (!$share->getSendPasswordByTalk()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
171
lib/Room.php
171
lib/Room.php
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
||||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
||||
|
|
@ -38,10 +39,10 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
class Room {
|
||||
const UNKNOWN_CALL = -1;
|
||||
const ONE_TO_ONE_CALL = 1;
|
||||
const GROUP_CALL = 2;
|
||||
const PUBLIC_CALL = 3;
|
||||
public const UNKNOWN_CALL = -1;
|
||||
public const ONE_TO_ONE_CALL = 1;
|
||||
public const GROUP_CALL = 2;
|
||||
public const PUBLIC_CALL = 3;
|
||||
|
||||
/** @var Manager */
|
||||
private $manager;
|
||||
|
|
@ -82,27 +83,22 @@ class Room {
|
|||
/** @var Participant */
|
||||
protected $participant;
|
||||
|
||||
/**
|
||||
* Room constructor.
|
||||
*
|
||||
* @param Manager $manager
|
||||
* @param IDBConnection $db
|
||||
* @param ISecureRandom $secureRandom
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param IHasher $hasher
|
||||
* @param int $id
|
||||
* @param int $type
|
||||
* @param string $token
|
||||
* @param string $name
|
||||
* @param string $password
|
||||
* @param int $activeGuests
|
||||
* @param \DateTime|null $activeSince
|
||||
* @param \DateTime|null $lastActivity
|
||||
* @param IComment|null $lastMessage
|
||||
* @param string $objectType
|
||||
* @param string $objectId
|
||||
*/
|
||||
public function __construct(Manager $manager, IDBConnection $db, ISecureRandom $secureRandom, EventDispatcherInterface $dispatcher, IHasher $hasher, $id, $type, $token, $name, $password, $activeGuests, \DateTime $activeSince = null, \DateTime $lastActivity = null, IComment $lastMessage = null, $objectType = '', $objectId = '') {
|
||||
public function __construct(Manager $manager,
|
||||
IDBConnection $db,
|
||||
ISecureRandom $secureRandom,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
IHasher $hasher,
|
||||
int $id,
|
||||
int $type,
|
||||
string $token,
|
||||
string $name,
|
||||
string $password,
|
||||
int $activeGuests,
|
||||
\DateTime $activeSince = null,
|
||||
\DateTime $lastActivity = null,
|
||||
IComment $lastMessage = null,
|
||||
string $objectType = '',
|
||||
string $objectId = '') {
|
||||
$this->manager = $manager;
|
||||
$this->db = $db;
|
||||
$this->secureRandom = $secureRandom;
|
||||
|
|
@ -121,80 +117,47 @@ class Room {
|
|||
$this->objectId = $objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId() {
|
||||
public function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getType() {
|
||||
public function getType(): int {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToken() {
|
||||
public function getToken(): string {
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getActiveGuests() {
|
||||
public function getActiveGuests(): int {
|
||||
return $this->activeGuests;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getActiveSince() {
|
||||
public function getActiveSince(): ?\DateTime {
|
||||
return $this->activeSince;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getLastActivity() {
|
||||
public function getLastActivity(): ?\DateTime {
|
||||
return $this->lastActivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IComment|null
|
||||
*/
|
||||
public function getLastMessage() {
|
||||
public function getLastMessage(): ?IComment {
|
||||
return $this->lastMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getObjectType() {
|
||||
public function getObjectType(): string {
|
||||
return $this->objectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getObjectId() {
|
||||
public function getObjectId(): string {
|
||||
return $this->objectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasPassword() {
|
||||
public function hasPassword(): bool {
|
||||
return $this->password !== '';
|
||||
}
|
||||
|
||||
|
|
@ -202,11 +165,7 @@ class Room {
|
|||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $userId
|
||||
* @param Participant $participant
|
||||
*/
|
||||
public function setParticipant($userId, Participant $participant) {
|
||||
public function setParticipant(?string $userId, Participant $participant): void {
|
||||
$this->currentUser = $userId;
|
||||
$this->participant = $participant;
|
||||
}
|
||||
|
|
@ -216,7 +175,7 @@ class Room {
|
|||
* @return Participant
|
||||
* @throws ParticipantNotFoundException When the user is not a participant
|
||||
*/
|
||||
public function getParticipant($userId) {
|
||||
public function getParticipant(?string $userId): Participant {
|
||||
if (!is_string($userId) || $userId === '') {
|
||||
throw new ParticipantNotFoundException('Not a user');
|
||||
}
|
||||
|
|
@ -251,7 +210,7 @@ class Room {
|
|||
* @return Participant
|
||||
* @throws ParticipantNotFoundException When the user is not a participant
|
||||
*/
|
||||
public function getParticipantBySession($sessionId) {
|
||||
public function getParticipantBySession(string $sessionId): Participant {
|
||||
if (!is_string($sessionId) || $sessionId === '' || $sessionId === '0') {
|
||||
throw new ParticipantNotFoundException('Not a user');
|
||||
}
|
||||
|
|
@ -272,7 +231,7 @@ class Room {
|
|||
return $this->manager->createParticipantObject($this, $row);
|
||||
}
|
||||
|
||||
public function deleteRoom() {
|
||||
public function deleteRoom(): void {
|
||||
$participants = $this->getParticipantsLegacy();
|
||||
$this->dispatcher->dispatch(self::class . '::preDeleteRoom', new GenericEvent($this, [
|
||||
'participants' => $participants,
|
||||
|
|
@ -298,7 +257,7 @@ class Room {
|
|||
* @param string $newName Currently it is only allowed to rename: self::GROUP_CALL, self::PUBLIC_CALL
|
||||
* @return bool True when the change was valid, false otherwise
|
||||
*/
|
||||
public function setName($newName) {
|
||||
public function setName(string $newName): bool {
|
||||
$oldName = $this->getName();
|
||||
if ($newName === $oldName) {
|
||||
return true;
|
||||
|
|
@ -334,7 +293,7 @@ class Room {
|
|||
* @param string $password Currently it is only allowed to have a password for Room::PUBLIC_CALL
|
||||
* @return bool True when the change was valid, false otherwise
|
||||
*/
|
||||
public function setPassword($password) {
|
||||
public function setPassword(string $password): bool {
|
||||
if ($this->getType() !== self::PUBLIC_CALL) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -363,7 +322,7 @@ class Room {
|
|||
* @param \DateTime $now
|
||||
* @return bool
|
||||
*/
|
||||
public function setLastActivity(\DateTime $now) {
|
||||
public function setLastActivity(\DateTime $now): bool {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->update('talk_rooms')
|
||||
->set('last_activity', $query->createNamedParameter($now, 'datetime'))
|
||||
|
|
@ -380,7 +339,7 @@ class Room {
|
|||
* @param bool $isGuest
|
||||
* @return bool
|
||||
*/
|
||||
public function setActiveSince(\DateTime $since, $isGuest) {
|
||||
public function setActiveSince(\DateTime $since, bool $isGuest): bool {
|
||||
|
||||
if ($isGuest && $this->getType() === self::PUBLIC_CALL) {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
|
|
@ -408,7 +367,7 @@ class Room {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function setLastMessage(IComment $message) {
|
||||
public function setLastMessage(IComment $message): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->update('talk_rooms')
|
||||
->set('last_message', $query->createNamedParameter((int) $message->getId()))
|
||||
|
|
@ -416,7 +375,7 @@ class Room {
|
|||
$query->execute();
|
||||
}
|
||||
|
||||
public function resetActiveSince() {
|
||||
public function resetActiveSince(): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->update('talk_rooms')
|
||||
->set('active_guests', $query->createNamedParameter(0))
|
||||
|
|
@ -429,7 +388,7 @@ class Room {
|
|||
* @param int $newType Currently it is only allowed to change to: self::GROUP_CALL, self::PUBLIC_CALL
|
||||
* @return bool True when the change was valid, false otherwise
|
||||
*/
|
||||
public function changeType($newType) {
|
||||
public function changeType(int $newType): bool {
|
||||
$newType = (int) $newType;
|
||||
if ($newType === $this->getType()) {
|
||||
return true;
|
||||
|
|
@ -474,7 +433,7 @@ class Room {
|
|||
/**
|
||||
* @param array[] ...$participants
|
||||
*/
|
||||
public function addUsers(array ...$participants) {
|
||||
public function addUsers(array ...$participants): void {
|
||||
$this->dispatcher->dispatch(self::class . '::preAddUsers', new GenericEvent($this, [
|
||||
'users' => $participants,
|
||||
]));
|
||||
|
|
@ -493,8 +452,8 @@ class Room {
|
|||
|
||||
foreach ($participants as $participant) {
|
||||
$query->setParameter('user_id', $participant['userId'])
|
||||
->setParameter('session_id', isset($participant['sessionId']) ? $participant['sessionId'] : '0')
|
||||
->setParameter('participant_type', isset($participant['participantType']) ? $participant['participantType'] : Participant::USER, IQueryBuilder::PARAM_INT);
|
||||
->setParameter('session_id', $participant['sessionId'] ?? '0')
|
||||
->setParameter('participant_type', $participant['participantType'] ?? Participant::USER, IQueryBuilder::PARAM_INT);
|
||||
|
||||
$query->execute();
|
||||
}
|
||||
|
|
@ -508,7 +467,7 @@ class Room {
|
|||
* @param string $participant
|
||||
* @param int $participantType
|
||||
*/
|
||||
public function setParticipantType($participant, $participantType) {
|
||||
public function setParticipantType(string $participant, int $participantType): void {
|
||||
$this->dispatcher->dispatch(self::class . '::preSetParticipantType', new GenericEvent($this, [
|
||||
'user' => $participant,
|
||||
'newType' => $participantType,
|
||||
|
|
@ -531,7 +490,7 @@ class Room {
|
|||
* @param Participant $participant
|
||||
* @param int $participantType
|
||||
*/
|
||||
public function setParticipantTypeBySession(Participant $participant, int $participantType) {
|
||||
public function setParticipantTypeBySession(Participant $participant, int $participantType): void {
|
||||
$this->dispatcher->dispatch(self::class . '::preSetParticipantTypeBySession', new GenericEvent($this, [
|
||||
'participant' => $participant,
|
||||
'newType' => $participantType,
|
||||
|
|
@ -553,7 +512,7 @@ class Room {
|
|||
/**
|
||||
* @param IUser $user
|
||||
*/
|
||||
public function removeUser(IUser $user) {
|
||||
public function removeUser(IUser $user): void {
|
||||
try {
|
||||
$participant = $this->getParticipant($user->getUID());
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
|
|
@ -580,7 +539,7 @@ class Room {
|
|||
/**
|
||||
* @param Participant $participant
|
||||
*/
|
||||
public function removeParticipantBySession(Participant $participant) {
|
||||
public function removeParticipantBySession(Participant $participant): void {
|
||||
$this->dispatcher->dispatch(self::class . '::preRemoveBySession', new GenericEvent($this, [
|
||||
'participant' => $participant,
|
||||
]));
|
||||
|
|
@ -604,7 +563,7 @@ class Room {
|
|||
* @throws InvalidPasswordException
|
||||
* @throws UnauthorizedException
|
||||
*/
|
||||
public function joinRoom(IUser $user, $password, $passedPasswordProtection = false) {
|
||||
public function joinRoom(IUser $user, string $password, bool $passedPasswordProtection = false): string {
|
||||
$event = new GenericEvent($this, [
|
||||
'userId' => $user->getUID(),
|
||||
'password' => $password,
|
||||
|
|
@ -658,7 +617,7 @@ class Room {
|
|||
/**
|
||||
* @param string $userId
|
||||
*/
|
||||
public function leaveRoom($userId) {
|
||||
public function leaveRoom(string $userId): void {
|
||||
try {
|
||||
$participant = $this->getParticipant($userId);
|
||||
} catch (ParticipantNotFoundException $e) {
|
||||
|
|
@ -702,7 +661,7 @@ class Room {
|
|||
* @throws InvalidPasswordException
|
||||
* @throws UnauthorizedException
|
||||
*/
|
||||
public function joinRoomGuest($password, $passedPasswordProtection = false) {
|
||||
public function joinRoomGuest(string $password, bool $passedPasswordProtection = false): string {
|
||||
$event = new GenericEvent($this);
|
||||
$this->dispatcher->dispatch(self::class . '::preJoinRoomGuest', $event);
|
||||
|
||||
|
|
@ -731,7 +690,7 @@ class Room {
|
|||
}
|
||||
|
||||
|
||||
public function changeInCall(string $sessionId, int $flags) {
|
||||
public function changeInCall(string $sessionId, int $flags): void {
|
||||
if ($flags !== Participant::FLAG_DISCONNECTED) {
|
||||
$this->dispatcher->dispatch(self::class . '::preSessionJoinCall', new GenericEvent($this, [
|
||||
'sessionId' => $sessionId,
|
||||
|
|
@ -766,7 +725,7 @@ class Room {
|
|||
* @param string $password
|
||||
* @return array
|
||||
*/
|
||||
public function verifyPassword($password) {
|
||||
public function verifyPassword(string $password): array {
|
||||
$event = new GenericEvent($this, [
|
||||
'password' => $password
|
||||
]);
|
||||
|
|
@ -790,7 +749,7 @@ class Room {
|
|||
* @param string $sessionId
|
||||
* @return bool
|
||||
*/
|
||||
protected function isSessionUnique($sessionId) {
|
||||
protected function isSessionUnique(string $sessionId): bool {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->selectAlias($query->createFunction('COUNT(*)'), 'num_sessions')
|
||||
->from('talk_participants')
|
||||
|
|
@ -802,7 +761,7 @@ class Room {
|
|||
return $numSessions === 1;
|
||||
}
|
||||
|
||||
public function cleanGuestParticipants() {
|
||||
public function cleanGuestParticipants(): void {
|
||||
$this->dispatcher->dispatch(self::class . '::preCleanGuests', new GenericEvent($this));
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
|
|
@ -819,7 +778,7 @@ class Room {
|
|||
* @param int $lastPing When the last ping is older than the given timestamp, the user is ignored
|
||||
* @return Participant[]
|
||||
*/
|
||||
public function getParticipants($lastPing = 0): array {
|
||||
public function getParticipants(int $lastPing = 0): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_participants')
|
||||
|
|
@ -845,7 +804,7 @@ class Room {
|
|||
* @return array[] Array of users with [users => [userId => [lastPing, sessionId]], guests => [[lastPing, sessionId]]]
|
||||
* @deprecated Use self::getParticipants() instead
|
||||
*/
|
||||
public function getParticipantsLegacy($lastPing = 0): array {
|
||||
public function getParticipantsLegacy(int $lastPing = 0): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('*')
|
||||
->from('talk_participants')
|
||||
|
|
@ -933,7 +892,7 @@ class Room {
|
|||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getActiveSessions() {
|
||||
public function getActiveSessions(): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('session_id')
|
||||
->from('talk_participants')
|
||||
|
|
@ -954,7 +913,7 @@ class Room {
|
|||
* Get all user ids which are participants in a room but currently not in the call
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNotInCallUserIds() {
|
||||
public function getNotInCallUserIds(): array {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('user_id')
|
||||
->from('talk_participants')
|
||||
|
|
@ -975,7 +934,7 @@ class Room {
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasSessionsInCall() {
|
||||
public function hasSessionsInCall(): bool {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select('session_id')
|
||||
->from('talk_participants')
|
||||
|
|
@ -994,7 +953,7 @@ class Room {
|
|||
* @param int $lastPing When the last ping is older than the given timestamp, the user is ignored
|
||||
* @return int
|
||||
*/
|
||||
public function getNumberOfParticipants($ignoreGuests = true, $lastPing = 0) {
|
||||
public function getNumberOfParticipants(bool $ignoreGuests = true, int $lastPing = 0): int {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->selectAlias($query->createFunction('COUNT(*)'), 'num_participants')
|
||||
->from('talk_participants')
|
||||
|
|
@ -1018,7 +977,7 @@ class Room {
|
|||
return isset($row['num_participants']) ? (int) $row['num_participants'] : 0;
|
||||
}
|
||||
|
||||
public function markUsersAsMentioned(array $userIds, \DateTime $time) {
|
||||
public function markUsersAsMentioned(array $userIds, \DateTime $time): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->update('talk_participants')
|
||||
->set('last_mention', $query->createNamedParameter($time, 'datetime'))
|
||||
|
|
@ -1032,7 +991,7 @@ class Room {
|
|||
* @param string $sessionId
|
||||
* @param int $timestamp
|
||||
*/
|
||||
public function ping($userId, $sessionId, $timestamp) {
|
||||
public function ping(string $userId, string $sessionId, int $timestamp): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->update('talk_participants')
|
||||
->set('last_ping', $query->createNamedParameter($timestamp, IQueryBuilder::PARAM_INT))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -34,10 +35,6 @@ class Section implements IIconSection {
|
|||
/** @var IURLGenerator */
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @param IURLGenerator $url
|
||||
* @param IL10N $l
|
||||
*/
|
||||
public function __construct(IURLGenerator $url, IL10N $l) {
|
||||
$this->url = $url;
|
||||
$this->l = $l;
|
||||
|
|
@ -50,7 +47,7 @@ class Section implements IIconSection {
|
|||
* @returns string
|
||||
* @since 12
|
||||
*/
|
||||
public function getIcon() {
|
||||
public function getIcon(): string {
|
||||
return $this->url->imagePath('spreed', 'app-dark.svg');
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +58,7 @@ class Section implements IIconSection {
|
|||
* @returns string
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getID() {
|
||||
public function getID(): string {
|
||||
return 'talk';
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +69,7 @@ class Section implements IIconSection {
|
|||
* @return string
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getName() {
|
||||
public function getName(): string {
|
||||
return $this->l->t('Talk');
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +81,7 @@ class Section implements IIconSection {
|
|||
* E.g.: 70
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getPriority() {
|
||||
public function getPriority(): int {
|
||||
return 70;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @author Joachim Bauch <mail@joachim-bauch.de>
|
||||
*
|
||||
|
|
@ -38,7 +39,7 @@ class SignalingServer implements ISettings {
|
|||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm() {
|
||||
public function getForm(): TemplateResponse {
|
||||
$parameters = [
|
||||
'signalingServers' => $this->config->getAppValue('spreed', 'signaling_servers'),
|
||||
];
|
||||
|
|
@ -49,7 +50,7 @@ class SignalingServer implements ISettings {
|
|||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection() {
|
||||
public function getSection(): string {
|
||||
return 'talk';
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ class SignalingServer implements ISettings {
|
|||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority() {
|
||||
public function getPriority(): int {
|
||||
return 75;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -41,7 +42,7 @@ class StunServer implements ISettings {
|
|||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm() {
|
||||
public function getForm(): TemplateResponse {
|
||||
$parameters = [
|
||||
'stunServer' => $this->config->getAppValue('spreed', 'stun_servers', json_encode(['stun.nextcloud.com:443'])),
|
||||
];
|
||||
|
|
@ -52,7 +53,7 @@ class StunServer implements ISettings {
|
|||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection() {
|
||||
public function getSection(): string {
|
||||
return 'talk';
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +64,7 @@ class StunServer implements ISettings {
|
|||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority() {
|
||||
public function getPriority(): int {
|
||||
return 65;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @author Joachim Bauch <mail@joachim-bauch.de>
|
||||
*
|
||||
|
|
@ -38,7 +39,7 @@ class TurnServer implements ISettings {
|
|||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm() {
|
||||
public function getForm(): TemplateResponse {
|
||||
$parameters = [
|
||||
'turnServer' => $this->config->getAppValue('spreed', 'turn_servers'),
|
||||
];
|
||||
|
|
@ -49,7 +50,7 @@ class TurnServer implements ISettings {
|
|||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
*/
|
||||
public function getSection() {
|
||||
public function getSection(): string {
|
||||
return 'talk';
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ class TurnServer implements ISettings {
|
|||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority() {
|
||||
public function getPriority(): int {
|
||||
return 70;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
|
|
@ -32,19 +33,16 @@ class Personal implements ISettings {
|
|||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
/** @var \OC_Defaults */
|
||||
private $defaults;
|
||||
|
||||
public function __construct(IConfig $config, \OC_Defaults $defaults) {
|
||||
public function __construct(IConfig $config) {
|
||||
$this->config = $config;
|
||||
$this->defaults = $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getForm() {
|
||||
public function getForm(): TemplateResponse {
|
||||
$parameters = [ 'clients' => $this->getClientLinks() ];
|
||||
return new TemplateResponse('spreed', 'settings/personal/clients', $parameters);
|
||||
}
|
||||
|
|
@ -53,7 +51,7 @@ class Personal implements ISettings {
|
|||
* @return string the section ID, e.g. 'sharing'
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getSection() {
|
||||
public function getSection(): string {
|
||||
return 'sync-clients';
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +63,7 @@ class Personal implements ISettings {
|
|||
* E.g.: 70
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getPriority() {
|
||||
public function getPriority(): int {
|
||||
return 30;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +72,7 @@ class Personal implements ISettings {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getClientLinks() {
|
||||
private function getClientLinks(): array {
|
||||
$clients = [
|
||||
'android' => $this->config->getSystemValue('talk_customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.talk2'),
|
||||
'ios' => $this->config->getSystemValue('talk_customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud-talk/id1296825574')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -49,13 +48,6 @@ class DeletedShareAPIController {
|
|||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* DeletedShareAPIController constructor.
|
||||
*
|
||||
* @param string $UserId
|
||||
* @param IUserManager $userManager
|
||||
* @param Manager $manager
|
||||
*/
|
||||
public function __construct(
|
||||
string $UserId,
|
||||
IUserManager $userManager,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -54,14 +53,6 @@ class ShareAPIController {
|
|||
/** @var IL10N */
|
||||
private $l;
|
||||
|
||||
/**
|
||||
* ShareAPIController constructor.
|
||||
*
|
||||
* @param string $UserId
|
||||
* @param IUserManager $userManager
|
||||
* @param Manager $manager
|
||||
* @param IL10N $l10n
|
||||
*/
|
||||
public function __construct(
|
||||
string $UserId,
|
||||
IUserManager $userManager,
|
||||
|
|
@ -131,8 +122,9 @@ class ShareAPIController {
|
|||
* @param string $shareWith
|
||||
* @param int $permissions
|
||||
* @param string $expireDate
|
||||
* @throws OCSNotFoundException
|
||||
*/
|
||||
public function createShare(IShare $share, string $shareWith, int $permissions, string $expireDate) {
|
||||
public function createShare(IShare $share, string $shareWith, int $permissions, string $expireDate): void {
|
||||
$share->setSharedWith($shareWith);
|
||||
$share->setPermissions($permissions);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
*
|
||||
* @copyright Copyright (c) 2018, Daniel Calviño Sánchez (danxuliu@gmail.com)
|
||||
|
|
@ -34,16 +33,15 @@ use OCA\Spreed\Manager;
|
|||
use OCA\Spreed\Room;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\Node;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IL10N;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use OCP\Share\Exceptions\GenericShareException;
|
||||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\Share\IManager as IShareManager;
|
||||
use OCP\Share\IShare;
|
||||
use OCP\Share\IShareHelper;
|
||||
use OCP\Share\IShareProvider;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
|
@ -61,7 +59,7 @@ use Symfony\Component\EventDispatcher\GenericEvent;
|
|||
class RoomShareProvider implements IShareProvider {
|
||||
|
||||
// Special share type for user modified room shares
|
||||
const SHARE_TYPE_USERROOM = 11;
|
||||
public const SHARE_TYPE_USERROOM = 11;
|
||||
|
||||
/** @var IDBConnection */
|
||||
private $dbConnection;
|
||||
|
|
@ -69,15 +67,9 @@ class RoomShareProvider implements IShareProvider {
|
|||
/** @var ISecureRandom */
|
||||
private $secureRandom;
|
||||
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
|
||||
/** @var IShareManager */
|
||||
private $shareManager;
|
||||
|
||||
/** @var IRootFolder */
|
||||
private $rootFolder;
|
||||
|
||||
/** @var EventDispatcherInterface */
|
||||
private $dispatcher;
|
||||
|
||||
|
|
@ -87,33 +79,17 @@ class RoomShareProvider implements IShareProvider {
|
|||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* RoomShareProvider constructor.
|
||||
*
|
||||
* @param IDBConnection $connection
|
||||
* @param ISecureRandom $secureRandom
|
||||
* @param IUserManager $userManager
|
||||
* @param IShareManager $shareManager
|
||||
* @param IRootFolder $rootFolder
|
||||
* @param EventDispatcherInterface $dispatcher
|
||||
* @param IL10N $l10n
|
||||
* @param Manager $manager
|
||||
*/
|
||||
public function __construct(
|
||||
IDBConnection $connection,
|
||||
ISecureRandom $secureRandom,
|
||||
IUserManager $userManager,
|
||||
IShareManager $shareManager,
|
||||
IRootFolder $rootFolder,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
IL10N $l,
|
||||
Manager $manager
|
||||
) {
|
||||
$this->dbConnection = $connection;
|
||||
$this->secureRandom = $secureRandom;
|
||||
$this->userManager = $userManager;
|
||||
$this->shareManager = $shareManager;
|
||||
$this->rootFolder = $rootFolder;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->l = $l;
|
||||
$this->manager = $manager;
|
||||
|
|
@ -124,7 +100,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
*
|
||||
* @return string Containing only [a-zA-Z0-9]
|
||||
*/
|
||||
public function identifier() {
|
||||
public function identifier(): string {
|
||||
return 'ocRoomShare';
|
||||
}
|
||||
|
||||
|
|
@ -135,11 +111,11 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @return IShare The share object
|
||||
* @throws GenericShareException
|
||||
*/
|
||||
public function create(IShare $share) {
|
||||
public function create(IShare $share): IShare {
|
||||
try {
|
||||
$room = $this->manager->getRoomByToken($share->getSharedWith());
|
||||
} catch (RoomNotFoundException $e) {
|
||||
throw new GenericShareException("Room not found", $this->l->t('Conversation not found'), 404);
|
||||
throw new GenericShareException('Room not found', $this->l->t('Conversation not found'), 404);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -147,14 +123,14 @@ class RoomShareProvider implements IShareProvider {
|
|||
} catch (ParticipantNotFoundException $e) {
|
||||
// If the sharer is not a participant of the room even if the room
|
||||
// exists the error is still "Room not found".
|
||||
throw new GenericShareException("Room not found", $this->l->t('Conversation not found'), 404);
|
||||
throw new GenericShareException('Room not found', $this->l->t('Conversation not found'), 404);
|
||||
}
|
||||
|
||||
$existingShares = $this->getSharesByPath($share->getNode());
|
||||
foreach ($existingShares as $existingShare) {
|
||||
if ($existingShare->getSharedWith() === $share->getSharedWith()) {
|
||||
$this->dispatcher->dispatch(self::class . '::' . 'share_file_again', new GenericEvent($existingShare));
|
||||
throw new GenericShareException("Already shared", $this->l->t('Path is already shared with this room'), 403);
|
||||
throw new GenericShareException('Already shared', $this->l->t('Path is already shared with this room'), 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +181,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
string $target,
|
||||
int $permissions,
|
||||
string $token,
|
||||
\DateTime $expirationDate = null
|
||||
?\DateTime $expirationDate
|
||||
): int {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->insert('share')
|
||||
|
|
@ -228,7 +204,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
$qb->execute();
|
||||
$id = $qb->getLastInsertId();
|
||||
|
||||
return (int)$id;
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -238,7 +214,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @return array
|
||||
* @throws ShareNotFound
|
||||
*/
|
||||
private function getRawShare(int $id) {
|
||||
private function getRawShare(int $id): array {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('share')
|
||||
|
|
@ -261,7 +237,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param array $data
|
||||
* @return IShare
|
||||
*/
|
||||
private function createShareObject($data) {
|
||||
private function createShareObject(array $data): IShare {
|
||||
$share = $this->shareManager->newShare();
|
||||
$share->setId((int)$data['id'])
|
||||
->setShareType((int)$data['share_type'])
|
||||
|
|
@ -298,7 +274,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param IShare $share
|
||||
* @return IShare The share object
|
||||
*/
|
||||
public function update(IShare $share) {
|
||||
public function update(IShare $share): IShare {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->update('share')
|
||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
|
||||
|
|
@ -341,7 +317,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
*
|
||||
* @param IShare $share
|
||||
*/
|
||||
public function delete(IShare $share) {
|
||||
public function delete(IShare $share): void {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->delete('share')
|
||||
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())));
|
||||
|
|
@ -360,7 +336,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param IShare $share
|
||||
* @param string $recipient UserId of the recipient
|
||||
*/
|
||||
public function deleteFromSelf(IShare $share, $recipient) {
|
||||
public function deleteFromSelf(IShare $share, $recipient): void {
|
||||
// Check if there is a userroom share
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$stmt = $qb->select(['id', 'permissions'])
|
||||
|
|
@ -452,7 +428,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param string $recipient userId of recipient
|
||||
* @return IShare
|
||||
*/
|
||||
public function move(IShare $share, $recipient) {
|
||||
public function move(IShare $share, $recipient): IShare {
|
||||
// Check if there is a userroom share
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$stmt = $qb->select('id')
|
||||
|
|
@ -507,7 +483,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator
|
||||
* @return IShare[]
|
||||
*/
|
||||
public function getSharesInFolder($userId, Folder $node, $reshares) {
|
||||
public function getSharesInFolder($userId, Folder $node, $reshares): array {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('share', 's')
|
||||
|
|
@ -559,7 +535,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param int $offset
|
||||
* @return IShare[]
|
||||
*/
|
||||
public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
|
||||
public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset): array {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('share');
|
||||
|
|
@ -609,7 +585,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @return IShare
|
||||
* @throws ShareNotFound
|
||||
*/
|
||||
public function getShareById($id, $recipientId = null) {
|
||||
public function getShareById($id, $recipientId = null): IShare {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->select('s.*',
|
||||
'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash',
|
||||
|
|
@ -711,7 +687,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param Node $path
|
||||
* @return IShare[]
|
||||
*/
|
||||
public function getSharesByPath(Node $path) {
|
||||
public function getSharesByPath(Node $path): array {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
|
||||
$cursor = $qb->select('*')
|
||||
|
|
@ -739,7 +715,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param int $offset
|
||||
* @return IShare[]
|
||||
*/
|
||||
public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
|
||||
public function getSharedWith($userId, $shareType, $node, $limit, $offset): array {
|
||||
$allRooms = $this->manager->getRoomsForParticipant($userId);
|
||||
|
||||
/** @var IShare[] $shares */
|
||||
|
|
@ -808,7 +784,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
return $shares;
|
||||
}
|
||||
|
||||
private function isAccessibleResult($data) {
|
||||
private function isAccessibleResult(array $data): bool {
|
||||
// exclude shares leading to deleted file entries
|
||||
if ($data['fileid'] === null) {
|
||||
return false;
|
||||
|
|
@ -833,7 +809,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @return IShare
|
||||
* @throws ShareNotFound
|
||||
*/
|
||||
public function getShareByToken($token) {
|
||||
public function getShareByToken($token): IShare {
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
|
||||
$cursor = $qb->select('*')
|
||||
|
|
@ -869,7 +845,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param string $uid
|
||||
* @param int $shareType
|
||||
*/
|
||||
public function userDeleted($uid, $shareType) {
|
||||
public function userDeleted($uid, $shareType): void {
|
||||
// A deleted user is handled automatically by the room hooks due to the
|
||||
// user being removed from the room.
|
||||
}
|
||||
|
|
@ -881,7 +857,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
*
|
||||
* @param string $gid
|
||||
*/
|
||||
public function groupDeleted($gid) {
|
||||
public function groupDeleted($gid): void {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -892,7 +868,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param string $uid
|
||||
* @param string $gid
|
||||
*/
|
||||
public function userDeletedFromGroup($uid, $gid) {
|
||||
public function userDeletedFromGroup($uid, $gid): void {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -966,7 +942,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param array $shares
|
||||
* @return array
|
||||
*/
|
||||
protected function filterSharesOfUser(array $shares) {
|
||||
protected function filterSharesOfUser(array $shares): array {
|
||||
// Room shares when the user has a share exception
|
||||
foreach ($shares as $id => $share) {
|
||||
$type = (int) $share['share_type'];
|
||||
|
|
@ -1005,7 +981,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param IShare $parent
|
||||
* @return IShare[]
|
||||
*/
|
||||
public function getChildren(IShare $parent) {
|
||||
public function getChildren(IShare $parent): array {
|
||||
$children = [];
|
||||
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
|
|
@ -1036,7 +1012,7 @@ class RoomShareProvider implements IShareProvider {
|
|||
* @param string $roomToken
|
||||
* @param string|null $user
|
||||
*/
|
||||
public function deleteInRoom(string $roomToken, string $user = null) {
|
||||
public function deleteInRoom(string $roomToken, string $user = null): void {
|
||||
//First delete all custom room shares for the original shares to be removed
|
||||
$qb = $this->dbConnection->getQueryBuilder();
|
||||
$qb->select('id')
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ use OCP\Http\Client\IClientService;
|
|||
use OCP\ILogger;
|
||||
use OCP\Security\ISecureRandom;
|
||||
|
||||
class BackendNotifier{
|
||||
class BackendNotifier {
|
||||
/** @var Config */
|
||||
private $config;
|
||||
/** @var ILogger */
|
||||
|
|
@ -41,12 +41,6 @@ class BackendNotifier{
|
|||
/** @var ISecureRandom */
|
||||
private $secureRandom;
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param ILogger $logger
|
||||
* @param IClientService $clientService
|
||||
* @param ISecureRandom $secureRandom
|
||||
*/
|
||||
public function __construct(Config $config,
|
||||
ILogger $logger,
|
||||
IClientService $clientService,
|
||||
|
|
@ -65,7 +59,7 @@ class BackendNotifier{
|
|||
* @param array $params
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function doRequest(string $url, array $params) {
|
||||
protected function doRequest(string $url, array $params): void {
|
||||
if (defined('PHPUNIT_RUN')) {
|
||||
// Don't perform network requests when running tests.
|
||||
return;
|
||||
|
|
@ -82,7 +76,7 @@ class BackendNotifier{
|
|||
* @param array $data
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function backendRequest(string $url, array $data) {
|
||||
private function backendRequest(string $url, array $data): void {
|
||||
$servers = $this->config->getSignalingServers();
|
||||
if (empty($servers)) {
|
||||
return;
|
||||
|
|
@ -124,7 +118,7 @@ class BackendNotifier{
|
|||
* @param array[] $users
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomInvited(Room $room, array $users) {
|
||||
public function roomInvited(Room $room, array $users): void {
|
||||
$this->logger->info('Now invited to ' . $room->getToken() . ': ' . print_r($users, true), ['app' => 'spreed']);
|
||||
$userIds = [];
|
||||
foreach ($users as $user) {
|
||||
|
|
@ -152,7 +146,7 @@ class BackendNotifier{
|
|||
* @param string[] $userIds
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomsDisinvited(Room $room, array $userIds) {
|
||||
public function roomsDisinvited(Room $room, array $userIds): void {
|
||||
$this->logger->info('No longer invited to ' . $room->getToken() . ': ' . print_r($userIds, true), ['app' => 'spreed']);
|
||||
$this->backendRequest('/api/v1/room/' . $room->getToken(), [
|
||||
'type' => 'disinvite',
|
||||
|
|
@ -176,7 +170,7 @@ class BackendNotifier{
|
|||
* @param string[] $sessionIds
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomSessionsRemoved(Room $room, array $sessionIds) {
|
||||
public function roomSessionsRemoved(Room $room, array $sessionIds): void {
|
||||
$this->logger->info('Removed from ' . $room->getToken() . ': ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
||||
$this->backendRequest('/api/v1/room/' . $room->getToken(), [
|
||||
'type' => 'disinvite',
|
||||
|
|
@ -199,7 +193,7 @@ class BackendNotifier{
|
|||
* @param Room $room
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomModified(Room $room) {
|
||||
public function roomModified(Room $room): void {
|
||||
$this->logger->info('Room modified: ' . $room->getToken(), ['app' => 'spreed']);
|
||||
$this->backendRequest('/api/v1/room/' . $room->getToken(), [
|
||||
'type' => 'update',
|
||||
|
|
@ -220,7 +214,7 @@ class BackendNotifier{
|
|||
* @param array $participants
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomDeleted(Room $room, array $participants) {
|
||||
public function roomDeleted(Room $room, array $participants): void {
|
||||
$this->logger->info('Room deleted: ' . $room->getToken(), ['app' => 'spreed']);
|
||||
$userIds = array_keys($participants['users']);
|
||||
$this->backendRequest('/api/v1/room/' . $room->getToken(), [
|
||||
|
|
@ -238,7 +232,7 @@ class BackendNotifier{
|
|||
* @param string[] $sessionIds
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function participantsModified(Room $room, array $sessionIds) {
|
||||
public function participantsModified(Room $room, array $sessionIds): void {
|
||||
$this->logger->info('Room participants modified: ' . $room->getToken() . ' ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
||||
$changed = [];
|
||||
$users = [];
|
||||
|
|
@ -276,7 +270,7 @@ class BackendNotifier{
|
|||
* @param string[] $sessionIds
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function roomInCallChanged(Room $room, int $flags, array $sessionIds) {
|
||||
public function roomInCallChanged(Room $room, int $flags, array $sessionIds): void {
|
||||
$this->logger->info('Room in-call status changed: ' . $room->getToken() . ' ' . $flags . ' ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
||||
$changed = [];
|
||||
$users = [];
|
||||
|
|
@ -320,7 +314,7 @@ class BackendNotifier{
|
|||
* @param array $message
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sendRoomMessage(Room $room, array $message) {
|
||||
public function sendRoomMessage(Room $room, array $message): void {
|
||||
$this->backendRequest('/api/v1/room/' . $room->getToken(), [
|
||||
'type' => 'message',
|
||||
'message' => [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
|
|
@ -35,11 +36,8 @@ class Messages {
|
|||
/** @var ITimeFactory */
|
||||
protected $time;
|
||||
|
||||
/**
|
||||
* @param IDBConnection $db
|
||||
* @param ITimeFactory $time
|
||||
*/
|
||||
public function __construct(IDBConnection $db, ITimeFactory $time) {
|
||||
public function __construct(IDBConnection $db,
|
||||
ITimeFactory $time) {
|
||||
$this->db = $db;
|
||||
$this->time = $time;
|
||||
}
|
||||
|
|
@ -47,7 +45,7 @@ class Messages {
|
|||
/**
|
||||
* @param string[] $sessionIds
|
||||
*/
|
||||
public function deleteMessages(array $sessionIds) {
|
||||
public function deleteMessages(array $sessionIds): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->delete('talk_signaling')
|
||||
->where($query->expr()->in('recipient', $query->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY)))
|
||||
|
|
@ -60,7 +58,7 @@ class Messages {
|
|||
* @param string $recipientSessionId
|
||||
* @param string $message
|
||||
*/
|
||||
public function addMessage($senderSessionId, $recipientSessionId, $message) {
|
||||
public function addMessage(string $senderSessionId, string $recipientSessionId, string $message): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->insert('talk_signaling')
|
||||
->values(
|
||||
|
|
@ -78,7 +76,7 @@ class Messages {
|
|||
* @param Room $room
|
||||
* @param string $message
|
||||
*/
|
||||
public function addMessageForAllParticipants(Room $room, $message) {
|
||||
public function addMessageForAllParticipants(Room $room, string $message): void {
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->insert('talk_signaling')
|
||||
->values(
|
||||
|
|
@ -108,7 +106,7 @@ class Messages {
|
|||
* @param string $sessionId
|
||||
* @return array
|
||||
*/
|
||||
public function getAndDeleteMessages($sessionId) {
|
||||
public function getAndDeleteMessages(string $sessionId): array {
|
||||
$messages = [];
|
||||
$time = $this->time->getTime() - 1;
|
||||
|
||||
|
|
@ -138,7 +136,7 @@ class Messages {
|
|||
*
|
||||
* @param int $olderThan
|
||||
*/
|
||||
public function expireOlderThan($olderThan) {
|
||||
public function expireOlderThan(int $olderThan): void {
|
||||
$time = $this->time->getTime() - $olderThan;
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
|
|
|
|||
|
|
@ -34,44 +34,31 @@ class TalkSession {
|
|||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSessionForRoom(string $token) {
|
||||
public function getSessionForRoom(string $token): ?string {
|
||||
return $this->getValue('spreed-session', $token);
|
||||
}
|
||||
|
||||
public function setSessionForRoom(string $token, string $sessionId) {
|
||||
public function setSessionForRoom(string $token, string $sessionId): void {
|
||||
$this->setValue('spreed-session', $token, $sessionId);
|
||||
}
|
||||
|
||||
public function removeSessionForRoom(string $token) {
|
||||
public function removeSessionForRoom(string $token): void {
|
||||
$this->removeValue('spreed-session', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPasswordForRoom(string $token) {
|
||||
public function getPasswordForRoom(string $token): ?string {
|
||||
return $this->getValue('spreed-password', $token);
|
||||
}
|
||||
|
||||
public function setPasswordForRoom(string $token, string $password) {
|
||||
public function setPasswordForRoom(string $token, string $password): void {
|
||||
$this->setValue('spreed-password', $token, $password);
|
||||
}
|
||||
|
||||
public function removePasswordForRoom(string $token) {
|
||||
public function removePasswordForRoom(string $token): void {
|
||||
$this->removeValue('spreed-password', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string $token
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getValue(string $key, string $token) {
|
||||
protected function getValue(string $key, string $token): ?string {
|
||||
$values = $this->session->get($key);
|
||||
if ($values === null) {
|
||||
return null;
|
||||
|
|
@ -88,7 +75,7 @@ class TalkSession {
|
|||
return $values[$token];
|
||||
}
|
||||
|
||||
protected function setValue(string $key, string $token, string $value) {
|
||||
protected function setValue(string $key, string $token, string $value): void {
|
||||
$values = $this->session->get($key);
|
||||
if ($values === null) {
|
||||
$values = [];
|
||||
|
|
@ -104,7 +91,7 @@ class TalkSession {
|
|||
$this->session->set($key, json_encode($values));
|
||||
}
|
||||
|
||||
protected function removeValue(string $key, string $token) {
|
||||
protected function removeValue(string $key, string $token): void {
|
||||
$values = $this->session->get($key);
|
||||
if ($values === null) {
|
||||
$values = [];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue