Skip to content
Merged
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
feat: add header with user id in response
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and backportbot[bot] committed Oct 2, 2025
commit caa2762140b61087ee227e2ab3a1570d9d36ee9f
9 changes: 8 additions & 1 deletion lib/public/AppFramework/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Server;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -228,7 +230,7 @@ public function getHeaders() {
/**
* @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',
Expand All @@ -245,6 +247,11 @@ public function getHeaders() {
$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);
}

Expand Down
Loading