From 0a2b09378c2753c2907eb2154aacc1d544f4fc1e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Oct 2024 08:36:59 +0200 Subject: [PATCH] fix(call): Respect user timezone for date Signed-off-by: Joas Schilling --- lib/Controller/CallController.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Controller/CallController.php b/lib/Controller/CallController.php index 128e79c616c..854a8e5bbef 100644 --- a/lib/Controller/CallController.php +++ b/lib/Controller/CallController.php @@ -38,6 +38,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\IConfig; use OCP\IRequest; use OCP\IUserManager; @@ -55,6 +56,7 @@ public function __construct( private RoomService $roomService, private IUserManager $userManager, private ITimeFactory $timeFactory, + private IConfig $serverConfig, private Config $talkConfig, protected Authenticator $federationAuthenticator, private SIPDialOutService $dialOutService, @@ -163,9 +165,21 @@ public function downloadParticipantsForCall(string $format = 'csv'): DataDownloa $cleanedRoomName = preg_replace('/[\/\\:*?"<>|\- ]+/', '-', $this->room->getName()); // Limit to a reasonable length $cleanedRoomName = substr($cleanedRoomName, 0, 100); - $date = $this->timeFactory->getDateTime()->format('Y-m-d'); + + $timezone = 'UTC'; + if ($this->participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) { + $timezone = $this->serverConfig->getUserValue($this->participant->getAttendee()->getActorId(), 'core', 'timezone', 'UTC'); + } + + try { + $dateTimeZone = new \DateTimeZone($timezone); + } catch (\DateInvalidTimeZoneException) { + $dateTimeZone = null; + } + + $date = $this->timeFactory->getDateTime('now', $dateTimeZone)->format('Y-m-d'); $fileName = $cleanedRoomName . ' ' . $date . '.csv'; - + return new DataDownloadResponse(stream_get_contents($output), $fileName, 'text/csv'); }