Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/federation/lib/Controller/OCSAuthAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\IRequest;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\ISecureRandom;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -35,7 +35,7 @@
class OCSAuthAPIController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private ISecureRandom $secureRandom,
private IJobList $jobList,
private TrustedServers $trustedServers,
Expand Down
31 changes: 21 additions & 10 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@
use OCP\IConfig;
use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
use OCP\IServerContainer;
use OCP\ITagManager;
use OCP\IUserSession;
use OCP\Share\IManager as IShareManager;
use OCP\Util;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

class Application extends App implements IBootstrap {
Expand All @@ -69,18 +68,24 @@ public function register(IRegistrationContext $context): void {
* Controllers
*/
$context->registerService('APIController', function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
$user = $c->get(IUserSession::class)->getUser();
if (!$user) {
$folder = null;
} else {
$userId = $user->getUID();
$root = $c->get(IRootFolder::class);
$folder = $root->getUserFolder($userId);
}

return new ApiController(
$c->get('AppName'),
$c->get(IRequest::class),
$c->get('appName'),
$c->get(ServerRequestInterface::class),
$c->get(IUserSession::class),
$c->get(TagService::class),
$c->get(IPreview::class),
$c->get(IShareManager::class),
$c->get(IConfig::class),
$server->getUserFolder(),
$folder,
$c->get(UserConfig::class),
$c->get(ViewConfig::class),
$c->get(IL10N::class),
Expand All @@ -93,14 +98,20 @@ public function register(IRegistrationContext $context): void {
* Services
*/
$context->registerService(TagService::class, function (ContainerInterface $c) {
/** @var IServerContainer $server */
$server = $c->get(IServerContainer::class);
$user = $c->get(IUserSession::class)->getUser();
if (!$user) {
$folder = null;
} else {
$userId = $user->getUID();
$root = $c->get(IRootFolder::class);
$folder = $root->getUserFolder($userId);
}

return new TagService(
$c->get(IUserSession::class),
$c->get(IActivityManager::class),
$c->get(ITagManager::class)->load(self::APP_ID),
$server->getUserFolder(),
$folder,
);
});

Expand Down
4 changes: 2 additions & 2 deletions apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
use OCP\IConfig;
use OCP\IL10N;
use OCP\IPreview;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
use OCP\PreConditionNotMetException;
use OCP\Share\IManager;
use OCP\Share\IShare;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;
use Throwable;

Expand All @@ -55,7 +55,7 @@
class ApiController extends Controller {
public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private IUserSession $userSession,
private TagService $tagService,
private IPreview $previewManager,
Expand Down
4 changes: 2 additions & 2 deletions apps/files/lib/Controller/ConversionApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
use OCP\Files\GenericFileException;
use OCP\Files\IRootFolder;
use OCP\IL10N;
use OCP\IRequest;
use Psr\Http\Message\ServerRequestInterface;
use function OCP\Log\logger;

class ConversionApiController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private IConversionManager $fileConversionManager,
private IRootFolder $rootFolder,
private IL10N $l10n,
Expand Down
4 changes: 2 additions & 2 deletions apps/files/lib/Controller/DirectEditingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
use OCP\DirectEditing\IManager;
use OCP\DirectEditing\RegisterDirectEditorEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IRequest;
use OCP\IURLGenerator;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

class DirectEditingController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
string $corsMethods,
string $corsAllowedHeaders,
int $corsMaxAge,
Expand Down
6 changes: 3 additions & 3 deletions apps/files/lib/Controller/DirectEditingViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
use OCP\DirectEditing\IManager;
use OCP\DirectEditing\RegisterDirectEditorEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IRequest;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class DirectEditingViewController extends Controller {
public function __construct(
$appName,
IRequest $request,
string $appName,
ServerRequestInterface $request,
private IEventDispatcher $eventDispatcher,
private IManager $directEditingManager,
private LoggerInterface $logger,
Expand Down
8 changes: 2 additions & 6 deletions apps/files/lib/Controller/FilenamesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,17 @@
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Services\IAppConfig;
use OCP\BackgroundJob\IJobList;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserManager;
use Psr\Http\Message\ServerRequestInterface;

class FilenamesController extends OCSController {

public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private IL10N $l10n,
private IJobList $jobList,
private IAppConfig $appConfig,
private IUserManager $userManager,
private SettingsService $settingsService,
) {
parent::__construct($appName, $request);
Expand Down
4 changes: 2 additions & 2 deletions apps/files/lib/Controller/OpenLocalEditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use OCP\AppFramework\OCSController;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\Exception;
use OCP\IRequest;
use OCP\Security\ISecureRandom;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

class OpenLocalEditorController extends OCSController {
Expand All @@ -31,7 +31,7 @@ class OpenLocalEditorController extends OCSController {

public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
protected ITimeFactory $timeFactory,
protected OpenLocalEditorMapper $mapper,
protected ISecureRandom $secureRandom,
Expand Down
4 changes: 2 additions & 2 deletions apps/files/lib/Controller/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use OCP\Files\Template\ITemplateManager;
use OCP\Files\Template\Template;
use OCP\Files\Template\TemplateFileCreator;
use OCP\IRequest;
use Psr\Http\Message\ServerRequestInterface;

/**
* @psalm-import-type FilesTemplateFile from ResponseDefinitions
Expand All @@ -30,7 +30,7 @@
class TemplateController extends OCSController {
public function __construct(
$appName,
IRequest $request,
ServerRequestInterface $request,
protected ITemplateManager $templateManager,
) {
parent::__construct($appName, $request);
Expand Down
4 changes: 2 additions & 2 deletions apps/files/lib/Controller/TransferOwnershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
use OCP\BackgroundJob\IJobList;
use OCP\Files\IHomeStorage;
use OCP\Files\IRootFolder;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\Notification\IManager as NotificationManager;
use Psr\Http\Message\ServerRequestInterface;

class TransferOwnershipController extends OCSController {

public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private string $userId,
private NotificationManager $notificationManager,
private ITimeFactory $timeFactory,
Expand Down
6 changes: 2 additions & 4 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@
use OCP\Files\NotFoundException;
use OCP\Files\Template\ITemplateManager;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Util;
use Psr\Http\Message\ServerRequestInterface;

/**
* @package OCA\Files\Controller
Expand All @@ -48,9 +47,8 @@ class ViewController extends Controller {

public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private IURLGenerator $urlGenerator,
private IL10N $l10n,
private IConfig $config,
private IEventDispatcher $eventDispatcher,
private IUserSession $userSession,
Expand Down
4 changes: 0 additions & 4 deletions apps/files/tests/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use OCP\Files\Template\ITemplateManager;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUser;
Expand All @@ -53,7 +52,6 @@ class ViewControllerTest extends TestCase {
private IEventDispatcher $eventDispatcher;
private IEventLogger&MockObject $eventLogger;
private IInitialState&MockObject $initialState;
private IL10N&MockObject $l10n;
private IRequest&MockObject $request;
private IRootFolder&MockObject $rootFolder;
private ITemplateManager&MockObject $templateManager;
Expand All @@ -74,7 +72,6 @@ protected function setUp(): void {
$this->config = $this->createMock(IConfig::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->initialState = $this->createMock(IInitialState::class);
$this->l10n = $this->createMock(IL10N::class);
$this->request = $this->createMock(IRequest::class);
$this->rootFolder = $this->createMock(IRootFolder::class);
$this->templateManager = $this->createMock(ITemplateManager::class);
Expand Down Expand Up @@ -130,7 +127,6 @@ protected function setUp(): void {
'files',
$this->request,
$this->urlGenerator,
$this->l10n,
$this->config,
$this->eventDispatcher,
$this->userSession,
Expand Down
9 changes: 5 additions & 4 deletions apps/theming/lib/Themes/DefaultTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\AppFramework\RequestHelper;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
use Psr\Http\Message\ServerRequestInterface;

class DefaultTheme implements ITheme {
use CommonThemeTrait;
Expand All @@ -34,7 +35,7 @@ public function __construct(
public IConfig $config,
public IL10N $l,
public IAppManager $appManager,
private ?IRequest $request,
private ?ServerRequestInterface $request,
) {
$this->defaultPrimaryColor = $this->themingDefaults->getDefaultColorPrimary();
$this->primaryColor = $this->themingDefaults->getColorPrimary();
Expand Down Expand Up @@ -97,9 +98,9 @@ public function getCSSVariables(): array {

$user = $this->userSession->getUser();
// Chromium based browsers currently (2024) have huge performance issues with blur filters
$isChromium = $this->request !== null && $this->request->isUserAgent([Request::USER_AGENT_CHROME, Request::USER_AGENT_MS_EDGE]);
$isChromium = $this->request !== null && RequestHelper::isUserAgent($this->request, [Request::USER_AGENT_CHROME, Request::USER_AGENT_MS_EDGE]);
// Ignore MacOS because they always have hardware accelartion
$isChromium = $isChromium && !$this->request->isUserAgent(['/Macintosh/']);
$isChromium = $isChromium && !RequestHelper::isUserAgent($this->request, ['/Macintosh/']);
// Allow to force the blur filter
$forceEnableBlur = $user === null ? false : $this->config->getUserValue(
$user->getUID(),
Expand Down
10 changes: 6 additions & 4 deletions apps/webhook_listeners/lib/Controller/WebhooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\ISession;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -37,7 +37,7 @@
class WebhooksController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
ServerRequestInterface $request,
private LoggerInterface $logger,
private WebhookListenerMapper $mapper,
private ?string $userId,
Expand Down Expand Up @@ -143,7 +143,8 @@ public function create(
): DataResponse {
$appId = null;
if ($this->session->get('app_api') === true) {
$appId = $this->request->getHeader('ex-app-id');
$appIds = $this->request->getHeader('ex-app-id');
$appId = $appIds !== [] ? $appIds[0] : null;
}
try {
$authMethod = AuthMethod::from($authMethod ?? AuthMethod::None->value);
Expand Down Expand Up @@ -219,7 +220,8 @@ public function update(
): DataResponse {
$appId = null;
if ($this->session->get('app_api') === true) {
$appId = $this->request->getHeader('ex-app-id');
$appIds = $this->request->getHeader('ex-app-id');
$appId = $appIds !== [] ? $appIds[0] : null;
}
try {
$authMethod = AuthMethod::from($authMethod ?? AuthMethod::None->value);
Expand Down
6 changes: 0 additions & 6 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1227,14 +1227,8 @@
</TypeDoesNotContainType>
</file>
<file src="apps/files/lib/AppInfo/Application.php">
<DeprecatedInterface>
<code><![CDATA[$server]]></code>
<code><![CDATA[$server]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
<code><![CDATA[Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig')]]></code>
<code><![CDATA[getUserFolder]]></code>
<code><![CDATA[getUserFolder]]></code>
</DeprecatedMethod>
</file>
<file src="apps/files/lib/BackgroundJob/ScanFiles.php">
Expand Down
1 change: 1 addition & 0 deletions core/Controller/ClientFlowLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function __construct(
}

private function getClientName(): string {
/** @var string $userAgent */
$userAgent = $this->request->getHeader('user-agent');
return $userAgent !== '' ? $userAgent : 'unknown';
}
Expand Down
Loading
Loading