feat: add header with user id in response

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/55176/head
Robin Appelman 2025-09-18 18:30:04 +07:00
parent 4c64e09ecd
commit 26ae51c4b3
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
1 changed files with 8 additions and 1 deletions

@ -11,6 +11,8 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@ -228,7 +230,7 @@ class Response {
/**
* @psalm-suppress UndefinedClass
*/
$request = \OCP\Server::get(IRequest::class);
$request = Server::get(IRequest::class);
$mergeWith = [
'X-Request-Id' => $request->getId(),
'Cache-Control' => 'no-cache, no-store, must-revalidate',
@ -245,6 +247,11 @@ class Response {
$mergeWith['ETag'] = '"' . $this->ETag . '"';
}
$userSession = Server::get(IUserSession::class);
if ($user = $userSession->getUser()) {
$mergeWith['X-User-Id'] = $user->getUID();
}
return array_merge($mergeWith, $this->headers);
}