Skip to content

Commit

Permalink
fix(call): Respect user timezone for date
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Oct 18, 2024
1 parent 078b3f2 commit 4312dbf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/Controller/CallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -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');
}

Expand Down

0 comments on commit 4312dbf

Please sign in to comment.