mirror of
https://github.com/nextcloud/spreed.git
synced 2025-08-16 15:27:59 +00:00
Move to Psr\Log\LoggerInterface
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
@ -31,9 +31,9 @@ use OCA\Talk\Room;
|
|||||||
use OCP\Activity\IManager;
|
use OCP\Activity\IManager;
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Listener {
|
class Listener {
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class Listener {
|
|||||||
/** @var ChatManager */
|
/** @var ChatManager */
|
||||||
protected $chatManager;
|
protected $chatManager;
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/** @var ITimeFactory */
|
/** @var ITimeFactory */
|
||||||
@ -55,7 +55,7 @@ class Listener {
|
|||||||
public function __construct(IManager $activityManager,
|
public function __construct(IManager $activityManager,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
ChatManager $chatManager,
|
ChatManager $chatManager,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
ITimeFactory $timeFactory) {
|
ITimeFactory $timeFactory) {
|
||||||
$this->activityManager = $activityManager;
|
$this->activityManager = $activityManager;
|
||||||
$this->userSession = $userSession;
|
$this->userSession = $userSession;
|
||||||
@ -151,7 +151,7 @@ class Listener {
|
|||||||
'duration' => $duration,
|
'duration' => $duration,
|
||||||
]);
|
]);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,9 +160,9 @@ class Listener {
|
|||||||
$event->setAffectedUser($userId);
|
$event->setAffectedUser($userId);
|
||||||
$this->activityManager->publish($event);
|
$this->activityManager->publish($event);
|
||||||
} catch (\BadMethodCallException $e) {
|
} catch (\BadMethodCallException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ class Listener {
|
|||||||
'room' => $room->getId(),
|
'room' => $room->getId(),
|
||||||
]);
|
]);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,9 +216,9 @@ class Listener {
|
|||||||
->setAffectedUser($participant['userId']);
|
->setAffectedUser($participant['userId']);
|
||||||
$this->activityManager->publish($event);
|
$this->activityManager->publish($event);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
} catch (\BadMethodCallException $e) {
|
} catch (\BadMethodCallException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ use OCP\AppFramework\Utility\ITimeFactory;
|
|||||||
use OCP\BackgroundJob\TimedJob;
|
use OCP\BackgroundJob\TimedJob;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\Notification\IManager;
|
use OCP\Notification\IManager;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class CheckHostedSignalingServer extends TimedJob {
|
class CheckHostedSignalingServer extends TimedJob {
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ class CheckHostedSignalingServer extends TimedJob {
|
|||||||
private $groupManager;
|
private $groupManager;
|
||||||
/** @var IURLGenerator */
|
/** @var IURLGenerator */
|
||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
public function __construct(ITimeFactory $timeFactory,
|
public function __construct(ITimeFactory $timeFactory,
|
||||||
@ -57,7 +57,7 @@ class CheckHostedSignalingServer extends TimedJob {
|
|||||||
IManager $notificationManager,
|
IManager $notificationManager,
|
||||||
IGroupManager $groupManager,
|
IGroupManager $groupManager,
|
||||||
IURLGenerator $urlGenerator,
|
IURLGenerator $urlGenerator,
|
||||||
ILogger $logger) {
|
LoggerInterface $logger) {
|
||||||
parent::__construct($timeFactory);
|
parent::__construct($timeFactory);
|
||||||
$this->setInterval(3600);
|
$this->setInterval(3600);
|
||||||
$this->hostedSignalingServerService = $hostedSignalingServerService;
|
$this->hostedSignalingServerService = $hostedSignalingServerService;
|
||||||
@ -148,7 +148,7 @@ class CheckHostedSignalingServer extends TimedJob {
|
|||||||
$this->config->setAppValue('spreed', 'hosted-signaling-server-account-last-checked', $this->time->getTime());
|
$this->config->setAppValue('spreed', 'hosted-signaling-server-account-last-checked', $this->time->getTime());
|
||||||
|
|
||||||
if (!is_null($notificationSubject)) {
|
if (!is_null($notificationSubject)) {
|
||||||
$this->logger->info('Hosted signaling server background job caused a notification: ' . $notificationSubject . ' ' . json_encode($notificationParameters), ['app' => 'spreed']);
|
$this->logger->info('Hosted signaling server background job caused a notification: ' . $notificationSubject . ' ' . json_encode($notificationParameters));
|
||||||
|
|
||||||
$notification = $this->notificationManager->createNotification();
|
$notification = $this->notificationManager->createNotification();
|
||||||
$notification
|
$notification
|
||||||
|
@ -26,7 +26,7 @@ namespace OCA\Talk\BackgroundJob;
|
|||||||
use OC\BackgroundJob\TimedJob;
|
use OC\BackgroundJob\TimedJob;
|
||||||
use OCA\Talk\Manager;
|
use OCA\Talk\Manager;
|
||||||
use OCA\Talk\Room;
|
use OCA\Talk\Room;
|
||||||
use OCP\ILogger;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RemoveEmptyRooms
|
* Class RemoveEmptyRooms
|
||||||
@ -38,13 +38,13 @@ class RemoveEmptyRooms extends TimedJob {
|
|||||||
/** @var Manager */
|
/** @var Manager */
|
||||||
protected $manager;
|
protected $manager;
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
protected $numDeletedRooms = 0;
|
protected $numDeletedRooms = 0;
|
||||||
|
|
||||||
public function __construct(Manager $manager,
|
public function __construct(Manager $manager,
|
||||||
ILogger $logger) {
|
LoggerInterface $logger) {
|
||||||
// Every 5 minutes
|
// Every 5 minutes
|
||||||
$this->setInterval(60 * 5);
|
$this->setInterval(60 * 5);
|
||||||
|
|
||||||
@ -58,7 +58,6 @@ class RemoveEmptyRooms extends TimedJob {
|
|||||||
if ($this->numDeletedRooms) {
|
if ($this->numDeletedRooms) {
|
||||||
$this->logger->info('Deleted {numDeletedRooms} rooms because they were empty', [
|
$this->logger->info('Deleted {numDeletedRooms} rooms because they were empty', [
|
||||||
'numDeletedRooms' => $this->numDeletedRooms,
|
'numDeletedRooms' => $this->numDeletedRooms,
|
||||||
'app' => 'spreed',
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
|
|||||||
use OCP\Comments\IComment;
|
use OCP\Comments\IComment;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Executor {
|
class Executor {
|
||||||
public const EVENT_APP_EXECUTE = self::class . '::execApp';
|
public const EVENT_APP_EXECUTE = self::class . '::execApp';
|
||||||
@ -51,7 +51,7 @@ class Executor {
|
|||||||
/** @var CommandService */
|
/** @var CommandService */
|
||||||
protected $commandService;
|
protected $commandService;
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
@ -60,7 +60,7 @@ class Executor {
|
|||||||
public function __construct(IEventDispatcher $dispatcher,
|
public function __construct(IEventDispatcher $dispatcher,
|
||||||
ShellExecutor $shellExecutor,
|
ShellExecutor $shellExecutor,
|
||||||
CommandService $commandService,
|
CommandService $commandService,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
IL10N $l) {
|
IL10N $l) {
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
$this->shellExecutor = $shellExecutor;
|
$this->shellExecutor = $shellExecutor;
|
||||||
@ -190,7 +190,7 @@ class Executor {
|
|||||||
$message->getActorType() === 'users' ? $message->getActorId() : ''
|
$message->getActorType() === 'users' ? $message->getActorId() : ''
|
||||||
);
|
);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
return $this->l->t('An error occurred while running the command. Please ask an administrator to check the logs.');
|
return $this->l->t('An error occurred while running the command. Please ask an administrator to check the logs.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ use OCP\AppFramework\OCSController;
|
|||||||
use OCP\Http\Client\IClientService;
|
use OCP\Http\Client\IClientService;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class HostedSignalingServerController extends OCSController {
|
class HostedSignalingServerController extends OCSController {
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class HostedSignalingServerController extends OCSController {
|
|||||||
protected $l10n;
|
protected $l10n;
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
protected $config;
|
protected $config;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
/** @var HostedSignalingServerService */
|
/** @var HostedSignalingServerService */
|
||||||
private $hostedSignalingServerService;
|
private $hostedSignalingServerService;
|
||||||
@ -57,7 +57,7 @@ class HostedSignalingServerController extends OCSController {
|
|||||||
IClientService $clientService,
|
IClientService $clientService,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
HostedSignalingServerService $hostedSignalingServerService) {
|
HostedSignalingServerService $hostedSignalingServerService) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->clientService = $clientService;
|
$this->clientService = $clientService;
|
||||||
@ -124,7 +124,7 @@ class HostedSignalingServerController extends OCSController {
|
|||||||
$this->config->setAppValue('spreed', 'signaling_mode', 'internal');
|
$this->config->setAppValue('spreed', 'signaling_mode', 'internal');
|
||||||
$this->config->deleteAppValue('spreed', 'signaling_servers');
|
$this->config->deleteAppValue('spreed', 'signaling_servers');
|
||||||
|
|
||||||
$this->logger->info('Deleted hosted signaling server account with ID ' . $accountId, ['app' => 'spreed']);
|
$this->logger->info('Deleted hosted signaling server account with ID ' . $accountId);
|
||||||
} catch (HostedSignalingServerAPIException $e) { // API or connection issues
|
} catch (HostedSignalingServerAPIException $e) { // API or connection issues
|
||||||
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
|
return new DataResponse(['message' => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ use OCP\Files\IRootFolder;
|
|||||||
use OCP\ICacheFactory;
|
use OCP\ICacheFactory;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IInitialStateService;
|
use OCP\IInitialStateService;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use OCP\Notification\IManager as INotificationManager;
|
use OCP\Notification\IManager as INotificationManager;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class PageController extends Controller {
|
class PageController extends Controller {
|
||||||
use TInitialState;
|
use TInitialState;
|
||||||
@ -68,7 +68,7 @@ class PageController extends Controller {
|
|||||||
private $talkSession;
|
private $talkSession;
|
||||||
/** @var IUserSession */
|
/** @var IUserSession */
|
||||||
private $userSession;
|
private $userSession;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
/** @var Manager */
|
/** @var Manager */
|
||||||
private $manager;
|
private $manager;
|
||||||
@ -88,7 +88,7 @@ class PageController extends Controller {
|
|||||||
TalkSession $session,
|
TalkSession $session,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
?string $UserId,
|
?string $UserId,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
Manager $manager,
|
Manager $manager,
|
||||||
IURLGenerator $url,
|
IURLGenerator $url,
|
||||||
INotificationManager $notificationManager,
|
INotificationManager $notificationManager,
|
||||||
@ -196,7 +196,7 @@ class PageController extends Controller {
|
|||||||
$notification->setObject('call', $room->getToken());
|
$notification->setObject('call', $room->getToken());
|
||||||
$this->notificationManager->markProcessed($notification);
|
$this->notificationManager->markProcessed($notification);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($shouldFlush) {
|
if ($shouldFlush) {
|
||||||
|
@ -34,8 +34,8 @@ use OCP\Files\IRootFolder;
|
|||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\Files\NotPermittedException;
|
use OCP\Files\NotPermittedException;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class SettingsController extends OCSController {
|
class SettingsController extends OCSController {
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class SettingsController extends OCSController {
|
|||||||
protected $rootFolder;
|
protected $rootFolder;
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
protected $config;
|
protected $config;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
protected $userId;
|
protected $userId;
|
||||||
@ -52,7 +52,7 @@ class SettingsController extends OCSController {
|
|||||||
IRequest $request,
|
IRequest $request,
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
?string $userId) {
|
?string $userId) {
|
||||||
parent::__construct($appName, $request);
|
parent::__construct($appName, $request);
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
@ -92,7 +92,7 @@ class SettingsController extends OCSController {
|
|||||||
return true;
|
return true;
|
||||||
} catch (NotPermittedException $e) {
|
} catch (NotPermittedException $e) {
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ use OCA\Talk\Room;
|
|||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\Notification\IManager;
|
use OCP\Notification\IManager;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class Listener {
|
class Listener {
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class Listener {
|
|||||||
protected $userSession;
|
protected $userSession;
|
||||||
/** @var ITimeFactory */
|
/** @var ITimeFactory */
|
||||||
protected $timeFactory;
|
protected $timeFactory;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@ -54,7 +54,7 @@ class Listener {
|
|||||||
IEventDispatcher $dispatcher,
|
IEventDispatcher $dispatcher,
|
||||||
IUserSession $userSession,
|
IUserSession $userSession,
|
||||||
ITimeFactory $timeFactory,
|
ITimeFactory $timeFactory,
|
||||||
ILogger $logger) {
|
LoggerInterface $logger) {
|
||||||
$this->notificationManager = $notificationManager;
|
$this->notificationManager = $notificationManager;
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
$this->userSession = $userSession;
|
$this->userSession = $userSession;
|
||||||
@ -129,7 +129,7 @@ class Listener {
|
|||||||
'actorId' => $actor->getUID(),
|
'actorId' => $actor->getUID(),
|
||||||
]);
|
]);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
if ($shouldFlush) {
|
if ($shouldFlush) {
|
||||||
$this->notificationManager->flush();
|
$this->notificationManager->flush();
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ class Listener {
|
|||||||
$notification->setUser($participant['userId']);
|
$notification->setUser($participant['userId']);
|
||||||
$this->notificationManager->notify($notification);
|
$this->notificationManager->notify($notification);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ class Listener {
|
|||||||
->setSubject('invitation');
|
->setSubject('invitation');
|
||||||
$this->notificationManager->markProcessed($notification);
|
$this->notificationManager->markProcessed($notification);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ class Listener {
|
|||||||
])
|
])
|
||||||
->setDateTime($dateTime);
|
->setDateTime($dateTime);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
if ($shouldFlush) {
|
if ($shouldFlush) {
|
||||||
$this->notificationManager->flush();
|
$this->notificationManager->flush();
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ class Listener {
|
|||||||
$notification->setUser($userId);
|
$notification->setUser($userId);
|
||||||
$this->notificationManager->notify($notification);
|
$this->notificationManager->notify($notification);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ class Listener {
|
|||||||
->setSubject('call');
|
->setSubject('call');
|
||||||
$this->notificationManager->markProcessed($notification);
|
$this->notificationManager->markProcessed($notification);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
$this->logger->logException($e, ['app' => 'spreed']);
|
$this->logger->error($e->getMessage(), ['exception' => $e]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ use OCP\AppFramework\Http;
|
|||||||
use OCP\Http\Client\IClientService;
|
use OCP\Http\Client\IClientService;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class HostedSignalingServerService {
|
class HostedSignalingServerService {
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class HostedSignalingServerService {
|
|||||||
private $apiServerUrl;
|
private $apiServerUrl;
|
||||||
/** @var IClientService */
|
/** @var IClientService */
|
||||||
private $clientService;
|
private $clientService;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
/** @var IL10N */
|
/** @var IL10N */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
@ -54,7 +54,7 @@ class HostedSignalingServerService {
|
|||||||
|
|
||||||
public function __construct(IConfig $config,
|
public function __construct(IConfig $config,
|
||||||
IClientService $clientService,
|
IClientService $clientService,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
IL10N $l10n,
|
IL10N $l10n,
|
||||||
SecureRandom $secureRandom) {
|
SecureRandom $secureRandom) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
@ -98,10 +98,7 @@ class HostedSignalingServerService {
|
|||||||
$response = $e->getResponse();
|
$response = $e->getResponse();
|
||||||
|
|
||||||
if ($response === null) {
|
if ($response === null) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Failed to request hosted signaling server trial', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Failed to request hosted signaling server trial',
|
|
||||||
]);
|
|
||||||
$message = $this->l10n->t('Failed to request trial because the trial server is unreachable. Please try again later.');
|
$message = $this->l10n->t('Failed to request trial because the trial server is unreachable. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
@ -110,7 +107,7 @@ class HostedSignalingServerService {
|
|||||||
switch ($status) {
|
switch ($status) {
|
||||||
case Http::STATUS_UNAUTHORIZED:
|
case Http::STATUS_UNAUTHORIZED:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: unauthorized - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: unauthorized - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('There is a problem with the authentication of this instance. Maybe it is not reachable from the outside to verify it\'s URL.');
|
$message = $this->l10n->t('There is a problem with the authentication of this instance. Maybe it is not reachable from the outside to verify it\'s URL.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -119,7 +116,7 @@ class HostedSignalingServerService {
|
|||||||
if ($body) {
|
if ($body) {
|
||||||
$parsedBody = json_decode($body, true);
|
$parsedBody = json_decode($body, true);
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -185,35 +182,31 @@ class HostedSignalingServerService {
|
|||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_TOO_MANY_REQUESTS:
|
case Http::STATUS_TOO_MANY_REQUESTS:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: too many requests - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: too many requests - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Too many requests are send from your servers address. Please try again later.');
|
$message = $this->l10n->t('Too many requests are send from your servers address. Please try again later.');
|
||||||
throw new HostedSignalingServerInputException($message);
|
throw new HostedSignalingServerInputException($message);
|
||||||
case Http::STATUS_CONFLICT:
|
case Http::STATUS_CONFLICT:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: already registered - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: already registered - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('There is already a trial registered for this Nextcloud instance.');
|
$message = $this->l10n->t('There is already a trial registered for this Nextcloud instance.');
|
||||||
throw new HostedSignalingServerInputException($message);
|
throw new HostedSignalingServerInputException($message);
|
||||||
case Http::STATUS_INTERNAL_SERVER_ERROR:
|
case Http::STATUS_INTERNAL_SERVER_ERROR:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: internal server error - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: internal server error - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened. Please try again later.');
|
$message = $this->l10n->t('Something unexpected happened. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
default:
|
default:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to request trial because the trial server behaved wrongly. Please try again later.');
|
$message = $this->l10n->t('Failed to request trial because the trial server behaved wrongly. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Failed to request hosted signaling server trial', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Failed to request hosted signaling server trial',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to request trial because the trial server is unreachable. Please try again later.');
|
$message = $this->l10n->t('Failed to request trial because the trial server is unreachable. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
@ -222,7 +215,7 @@ class HostedSignalingServerService {
|
|||||||
|
|
||||||
if ($status !== Http::STATUS_CREATED) {
|
if ($status !== Http::STATUS_CREATED) {
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -232,14 +225,14 @@ class HostedSignalingServerService {
|
|||||||
$data = json_decode($body, true);
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($data['account_id'])) {
|
if (!isset($data['account_id'])) {
|
||||||
$this->logger->error('Requesting hosted signaling server trial failed: no account ID transfered - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Requesting hosted signaling server trial failed: no account ID transfered - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -275,11 +268,7 @@ class HostedSignalingServerService {
|
|||||||
$response = $e->getResponse();
|
$response = $e->getResponse();
|
||||||
|
|
||||||
if ($response === null) {
|
if ($response === null) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Trial requested but failed to get account information', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Trial requested but failed to get account information',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Trial requested but failed to get account information. Please check back later.');
|
$message = $this->l10n->t('Trial requested but failed to get account information. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
@ -289,7 +278,7 @@ class HostedSignalingServerService {
|
|||||||
switch ($status) {
|
switch ($status) {
|
||||||
case Http::STATUS_UNAUTHORIZED:
|
case Http::STATUS_UNAUTHORIZED:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Getting the account information failed: unauthorized - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: unauthorized - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('There is a problem with the authentication of this request. Maybe it is not reachable from the outside to verify it\'s URL.');
|
$message = $this->l10n->t('There is a problem with the authentication of this request. Maybe it is not reachable from the outside to verify it\'s URL.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -298,7 +287,7 @@ class HostedSignalingServerService {
|
|||||||
if ($body) {
|
if ($body) {
|
||||||
$parsedBody = json_decode($body, true);
|
$parsedBody = json_decode($body, true);
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
$this->logger->error('Getting the account information failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -310,7 +299,7 @@ class HostedSignalingServerService {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Getting the account information failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to fetch account information because the trial server behaved wrongly. Please check back later.');
|
$message = $this->l10n->t('Failed to fetch account information because the trial server behaved wrongly. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -326,35 +315,31 @@ class HostedSignalingServerService {
|
|||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_TOO_MANY_REQUESTS:
|
case Http::STATUS_TOO_MANY_REQUESTS:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Getting the account information failed: too many requests - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: too many requests - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Too many requests are send from your servers address. Please try again later.');
|
$message = $this->l10n->t('Too many requests are send from your servers address. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_NOT_FOUND:
|
case Http::STATUS_NOT_FOUND:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Getting the account information failed: account not found - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: account not found - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('There is no such account registered.');
|
$message = $this->l10n->t('There is no such account registered.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_INTERNAL_SERVER_ERROR:
|
case Http::STATUS_INTERNAL_SERVER_ERROR:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Getting the account information failed: internal server error - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: internal server error - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened. Please try again later.');
|
$message = $this->l10n->t('Something unexpected happened. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
default:
|
default:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Getting the account information failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to fetch account information because the trial server behaved wrongly. Please check back later.');
|
$message = $this->l10n->t('Failed to fetch account information because the trial server behaved wrongly. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Failed to request hosted signaling server trial', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Failed to request hosted signaling server trial',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to fetch account information because the trial server is unreachable. Please check back later.');
|
$message = $this->l10n->t('Failed to fetch account information because the trial server is unreachable. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
@ -363,7 +348,7 @@ class HostedSignalingServerService {
|
|||||||
|
|
||||||
if ($status !== Http::STATUS_OK) {
|
if ($status !== Http::STATUS_OK) {
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$this->logger->error('Getting the account information failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
@ -374,7 +359,7 @@ class HostedSignalingServerService {
|
|||||||
$data = json_decode($body, true);
|
$data = json_decode($body, true);
|
||||||
|
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
$this->logger->error('Getting the account information failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -404,7 +389,7 @@ class HostedSignalingServerService {
|
|||||||
|| (in_array($data['status'], ['error', 'blocked']) && !isset($data['reason']))
|
|| (in_array($data['status'], ['error', 'blocked']) && !isset($data['reason']))
|
||||||
|| !in_array($data['status'], ['error', 'blocked', 'pending', 'active', 'expired'])
|
|| !in_array($data['status'], ['error', 'blocked', 'pending', 'active', 'expired'])
|
||||||
) {
|
) {
|
||||||
$this->logger->error('Getting the account information failed: response is missing mandatory field - data: ' . json_encode($data), ['app' => 'spreed']);
|
$this->logger->error('Getting the account information failed: response is missing mandatory field - data: ' . json_encode($data));
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -437,11 +422,7 @@ class HostedSignalingServerService {
|
|||||||
$response = $e->getResponse();
|
$response = $e->getResponse();
|
||||||
|
|
||||||
if ($response === null) {
|
if ($response === null) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Deleting the hosted signaling server account failed', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Deleting the hosted signaling server account failed',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Deleting the hosted signaling server account failed. Please check back later.');
|
$message = $this->l10n->t('Deleting the hosted signaling server account failed. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
@ -451,7 +432,7 @@ class HostedSignalingServerService {
|
|||||||
switch ($status) {
|
switch ($status) {
|
||||||
case Http::STATUS_UNAUTHORIZED:
|
case Http::STATUS_UNAUTHORIZED:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: unauthorized - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: unauthorized - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('There is a problem with the authentication of this request. Maybe it is not reachable from the outside to verify it\'s URL.');
|
$message = $this->l10n->t('There is a problem with the authentication of this request. Maybe it is not reachable from the outside to verify it\'s URL.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -460,7 +441,7 @@ class HostedSignalingServerService {
|
|||||||
if ($body) {
|
if ($body) {
|
||||||
$parsedBody = json_decode($body, true);
|
$parsedBody = json_decode($body, true);
|
||||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: cannot parse JSON response - JSON error: '. json_last_error() . ' ' . json_last_error_msg() . ' HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -472,7 +453,7 @@ class HostedSignalingServerService {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to delete the account because the trial server behaved wrongly. Please check back later.');
|
$message = $this->l10n->t('Failed to delete the account because the trial server behaved wrongly. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
@ -488,35 +469,31 @@ class HostedSignalingServerService {
|
|||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_TOO_MANY_REQUESTS:
|
case Http::STATUS_TOO_MANY_REQUESTS:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: too many requests - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: too many requests - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Too many requests are send from your servers address. Please try again later.');
|
$message = $this->l10n->t('Too many requests are send from your servers address. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_NOT_FOUND:
|
case Http::STATUS_NOT_FOUND:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: account not found - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: account not found - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('There is no such account registered.');
|
$message = $this->l10n->t('There is no such account registered.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
case Http::STATUS_INTERNAL_SERVER_ERROR:
|
case Http::STATUS_INTERNAL_SERVER_ERROR:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: internal server error - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: internal server error - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened. Please try again later.');
|
$message = $this->l10n->t('Something unexpected happened. Please try again later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
default:
|
default:
|
||||||
$body = $response->getBody()->getContents();
|
$body = $response->getBody()->getContents();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to delete the account because the trial server behaved wrongly. Please check back later.');
|
$message = $this->l10n->t('Failed to delete the account because the trial server behaved wrongly. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Deleting the hosted signaling server account failed', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Deleting the hosted signaling server account failed',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Failed to delete the account because the trial server is unreachable. Please check back later.');
|
$message = $this->l10n->t('Failed to delete the account because the trial server is unreachable. Please check back later.');
|
||||||
throw new HostedSignalingServerAPIException($message);
|
throw new HostedSignalingServerAPIException($message);
|
||||||
}
|
}
|
||||||
@ -525,7 +502,7 @@ class HostedSignalingServerService {
|
|||||||
|
|
||||||
if ($status !== Http::STATUS_NO_CONTENT) {
|
if ($status !== Http::STATUS_NO_CONTENT) {
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
$this->logger->error('Deleting the hosted signaling server account failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body, ['app' => 'spreed']);
|
$this->logger->error('Deleting the hosted signaling server account failed: something else happened - HTTP status: ' . $status . ' Response body: ' . $body);
|
||||||
|
|
||||||
|
|
||||||
$message = $this->l10n->t('Something unexpected happened.');
|
$message = $this->l10n->t('Something unexpected happened.');
|
||||||
|
@ -29,14 +29,14 @@ use OCA\Talk\Config;
|
|||||||
use OCA\Talk\Participant;
|
use OCA\Talk\Participant;
|
||||||
use OCA\Talk\Room;
|
use OCA\Talk\Room;
|
||||||
use OCP\Http\Client\IClientService;
|
use OCP\Http\Client\IClientService;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IUrlGenerator;
|
use OCP\IUrlGenerator;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class BackendNotifier {
|
class BackendNotifier {
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
private $config;
|
private $config;
|
||||||
/** @var ILogger */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
/** @var IClientService */
|
/** @var IClientService */
|
||||||
private $clientService;
|
private $clientService;
|
||||||
@ -48,7 +48,7 @@ class BackendNotifier {
|
|||||||
private $urlGenerator;
|
private $urlGenerator;
|
||||||
|
|
||||||
public function __construct(Config $config,
|
public function __construct(Config $config,
|
||||||
ILogger $logger,
|
LoggerInterface $logger,
|
||||||
IClientService $clientService,
|
IClientService $clientService,
|
||||||
ISecureRandom $secureRandom,
|
ISecureRandom $secureRandom,
|
||||||
Manager $signalingManager,
|
Manager $signalingManager,
|
||||||
@ -79,10 +79,7 @@ class BackendNotifier {
|
|||||||
try {
|
try {
|
||||||
$client->post($url, $params);
|
$client->post($url, $params);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e, [
|
$this->logger->error('Failed to send message to signaling server', ['exception' => $e]);
|
||||||
'app' => 'spreed',
|
|
||||||
'message' => 'Failed to send message to signaling server',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +138,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function roomInvited(Room $room, array $users): void {
|
public function roomInvited(Room $room, array $users): void {
|
||||||
$this->logger->info('Now invited to ' . $room->getToken() . ': ' . print_r($users, true), ['app' => 'spreed']);
|
$this->logger->info('Now invited to ' . $room->getToken() . ': ' . print_r($users, true));
|
||||||
$userIds = [];
|
$userIds = [];
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
$userIds[] = $user['userId'];
|
$userIds[] = $user['userId'];
|
||||||
@ -166,7 +163,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function roomsDisinvited(Room $room, array $userIds): void {
|
public function roomsDisinvited(Room $room, array $userIds): void {
|
||||||
$this->logger->info('No longer invited to ' . $room->getToken() . ': ' . print_r($userIds, true), ['app' => 'spreed']);
|
$this->logger->info('No longer invited to ' . $room->getToken() . ': ' . print_r($userIds, true));
|
||||||
$this->backendRequest($room, [
|
$this->backendRequest($room, [
|
||||||
'type' => 'disinvite',
|
'type' => 'disinvite',
|
||||||
'disinvite' => [
|
'disinvite' => [
|
||||||
@ -187,7 +184,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function roomSessionsRemoved(Room $room, array $sessionIds): void {
|
public function roomSessionsRemoved(Room $room, array $sessionIds): void {
|
||||||
$this->logger->info('Removed from ' . $room->getToken() . ': ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
$this->logger->info('Removed from ' . $room->getToken() . ': ' . print_r($sessionIds, true));
|
||||||
$this->backendRequest($room, [
|
$this->backendRequest($room, [
|
||||||
'type' => 'disinvite',
|
'type' => 'disinvite',
|
||||||
'disinvite' => [
|
'disinvite' => [
|
||||||
@ -207,7 +204,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function roomModified(Room $room): void {
|
public function roomModified(Room $room): void {
|
||||||
$this->logger->info('Room modified: ' . $room->getToken(), ['app' => 'spreed']);
|
$this->logger->info('Room modified: ' . $room->getToken());
|
||||||
$this->backendRequest($room, [
|
$this->backendRequest($room, [
|
||||||
'type' => 'update',
|
'type' => 'update',
|
||||||
'update' => [
|
'update' => [
|
||||||
@ -225,7 +222,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function roomDeleted(Room $room, array $participants): void {
|
public function roomDeleted(Room $room, array $participants): void {
|
||||||
$this->logger->info('Room deleted: ' . $room->getToken(), ['app' => 'spreed']);
|
$this->logger->info('Room deleted: ' . $room->getToken());
|
||||||
$userIds = array_keys($participants['users']);
|
$userIds = array_keys($participants['users']);
|
||||||
$this->backendRequest($room, [
|
$this->backendRequest($room, [
|
||||||
'type' => 'delete',
|
'type' => 'delete',
|
||||||
@ -243,7 +240,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function participantsModified(Room $room, array $sessionIds): void {
|
public function participantsModified(Room $room, array $sessionIds): void {
|
||||||
$this->logger->info('Room participants modified: ' . $room->getToken() . ' ' . print_r($sessionIds, true), ['app' => 'spreed']);
|
$this->logger->info('Room participants modified: ' . $room->getToken() . ' ' . print_r($sessionIds, true));
|
||||||
$changed = [];
|
$changed = [];
|
||||||
$users = [];
|
$users = [];
|
||||||
$participants = $room->getParticipantsLegacy();
|
$participants = $room->getParticipantsLegacy();
|
||||||
@ -287,7 +284,7 @@ class BackendNotifier {
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function roomInCallChanged(Room $room, int $flags, array $sessionIds): void {
|
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']);
|
$this->logger->info('Room in-call status changed: ' . $room->getToken() . ' ' . $flags . ' ' . print_r($sessionIds, true));
|
||||||
$changed = [];
|
$changed = [];
|
||||||
$users = [];
|
$users = [];
|
||||||
$participants = $room->getParticipantsLegacy();
|
$participants = $room->getParticipantsLegacy();
|
||||||
|
@ -31,10 +31,10 @@ use OCP\AppFramework\Utility\ITimeFactory;
|
|||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IGroup;
|
use OCP\IGroup;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\Notification\IManager;
|
use OCP\Notification\IManager;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class CheckHostedSignalingServerTest extends TestCase {
|
class CheckHostedSignalingServerTest extends TestCase {
|
||||||
@ -51,7 +51,7 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||||||
protected $groupManager;
|
protected $groupManager;
|
||||||
/** @var IURLGenerator|MockObject */
|
/** @var IURLGenerator|MockObject */
|
||||||
protected $urlGenerator;
|
protected $urlGenerator;
|
||||||
/** @var ILogger|MockObject */
|
/** @var LoggerInterface|MockObject */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp(): void {
|
||||||
@ -63,7 +63,7 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||||||
$this->notificationManager = $this->createMock(IManager::class);
|
$this->notificationManager = $this->createMock(IManager::class);
|
||||||
$this->groupManager = $this->createMock(IGroupManager::class);
|
$this->groupManager = $this->createMock(IGroupManager::class);
|
||||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||||
$this->logger = $this->createMock(ILogger::class);
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBackgroundJob(): CheckHostedSignalingServer {
|
public function getBackgroundJob(): CheckHostedSignalingServer {
|
||||||
@ -95,7 +95,7 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||||||
|
|
||||||
$this->hostedSignalingServerService->expects($this->once())
|
$this->hostedSignalingServerService->expects($this->once())
|
||||||
->method('fetchAccountInfo')
|
->method('fetchAccountInfo')
|
||||||
->willReturn(["status" => "pending"]);
|
->willReturn(['status' => 'pending']);
|
||||||
|
|
||||||
$this->invokePrivate($backgroundJob, 'run', ['']);
|
$this->invokePrivate($backgroundJob, 'run', ['']);
|
||||||
}
|
}
|
||||||
@ -103,10 +103,10 @@ class CheckHostedSignalingServerTest extends TestCase {
|
|||||||
public function testRunWithPendingToActiveChange() {
|
public function testRunWithPendingToActiveChange() {
|
||||||
$backgroundJob = $this->getBackgroundJob();
|
$backgroundJob = $this->getBackgroundJob();
|
||||||
$newStatus = [
|
$newStatus = [
|
||||||
"status" => "active",
|
'status' => 'active',
|
||||||
"signaling" => [
|
'signaling' => [
|
||||||
"url" => "signaling-url",
|
'url' => 'signaling-url',
|
||||||
"secret" => "signaling-secret",
|
'secret' => 'signaling-secret',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ use OCA\Talk\Service\CommandService;
|
|||||||
use OCP\Comments\IComment;
|
use OCP\Comments\IComment;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
|
||||||
class ExecutorTest extends TestCase {
|
class ExecutorTest extends TestCase {
|
||||||
@ -47,7 +47,7 @@ class ExecutorTest extends TestCase {
|
|||||||
/** @var CommandService|MockObject */
|
/** @var CommandService|MockObject */
|
||||||
protected $commandService;
|
protected $commandService;
|
||||||
|
|
||||||
/** @var ILogger|MockObject */
|
/** @var LoggerInterface|MockObject */
|
||||||
protected $logger;
|
protected $logger;
|
||||||
|
|
||||||
/** @var IL10N|MockObject */
|
/** @var IL10N|MockObject */
|
||||||
@ -62,7 +62,7 @@ class ExecutorTest extends TestCase {
|
|||||||
$this->dispatcher = $this->createMock(IEventDispatcher::class);
|
$this->dispatcher = $this->createMock(IEventDispatcher::class);
|
||||||
$this->shellExecutor = $this->createMock(ShellExecutor::class);
|
$this->shellExecutor = $this->createMock(ShellExecutor::class);
|
||||||
$this->commandService = $this->createMock(CommandService::class);
|
$this->commandService = $this->createMock(CommandService::class);
|
||||||
$this->logger = $this->createMock(ILogger::class);
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
$this->l10n = $this->createMock(IL10N::class);
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
$this->executor = new Executor(
|
$this->executor = new Executor(
|
||||||
$this->dispatcher,
|
$this->dispatcher,
|
||||||
|
@ -37,13 +37,13 @@ use OCP\EventDispatcher\IEventDispatcher;
|
|||||||
use OCP\Http\Client\IClientService;
|
use OCP\Http\Client\IClientService;
|
||||||
use OCP\IGroupManager;
|
use OCP\IGroupManager;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\Security\IHasher;
|
use OCP\Security\IHasher;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class CustomBackendNotifier extends BackendNotifier {
|
class CustomBackendNotifier extends BackendNotifier {
|
||||||
private $requests = [];
|
private $requests = [];
|
||||||
@ -155,7 +155,7 @@ class BackendNotifierTest extends \Test\TestCase {
|
|||||||
private function recreateBackendNotifier() {
|
private function recreateBackendNotifier() {
|
||||||
$this->controller = new CustomBackendNotifier(
|
$this->controller = new CustomBackendNotifier(
|
||||||
$this->config,
|
$this->config,
|
||||||
$this->createMock(ILogger::class),
|
$this->createMock(LoggerInterface::class),
|
||||||
$this->createMock(IClientService::class),
|
$this->createMock(IClientService::class),
|
||||||
$this->secureRandom,
|
$this->secureRandom,
|
||||||
$this->signalingManager,
|
$this->signalingManager,
|
||||||
|
Reference in New Issue
Block a user