Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(calls): Allow moderators to download a call participants list - frontend #13557

Merged
merged 2 commits into from
Oct 18, 2024
Merged
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
24 changes: 23 additions & 1 deletion 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 @@ -127,6 +129,7 @@ public function getPeersForCall(): DataResponse {
*/
#[PublicPage]
#[RequireModeratorParticipant]
#[Http\Attribute\NoCSRFRequired]
public function downloadParticipantsForCall(string $format = 'csv'): DataDownloadResponse|Response {
$timeout = $this->timeFactory->getTime() - Session::SESSION_TIMEOUT;
$participants = $this->participantService->getParticipantsInCall($this->room, $timeout);
Expand Down Expand Up @@ -158,7 +161,26 @@ public function downloadParticipantsForCall(string $format = 'csv'): DataDownloa

fseek($output, 0);

return new DataDownloadResponse(stream_get_contents($output), 'participants.csv', 'text/csv');
// Clean the room name
$cleanedRoomName = preg_replace('/[\/\\:*?"<>|\- ]+/', '-', $this->room->getName());
// Limit to a reasonable length
$cleanedRoomName = substr($cleanedRoomName, 0, 100);

$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');
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved
$fileName = $cleanedRoomName . ' ' . $date . '.csv';

return new DataDownloadResponse(stream_get_contents($output), $fileName, 'text/csv');
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/components/TopBar/TopBarMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@
</template>
{{ t('spreed', 'Conversation settings') }}
</NcActionButton>
<NcActionLink v-if="isInCall && canModerate"
:href="downloadCallParticipantsLink"
target="_blank">
<template #icon>
<IconDownload :size="20" />
</template>
{{ t('spreed', 'Download attendance list') }}
</NcActionLink>
</NcActions>
</div>
</template>
Expand All @@ -147,6 +155,7 @@
import Cog from 'vue-material-design-icons/Cog.vue'
import DotsCircle from 'vue-material-design-icons/DotsCircle.vue'
import DotsHorizontal from 'vue-material-design-icons/DotsHorizontal.vue'
import IconDownload from 'vue-material-design-icons/Download.vue'
import File from 'vue-material-design-icons/File.vue'
import Fullscreen from 'vue-material-design-icons/Fullscreen.vue'
import FullscreenExit from 'vue-material-design-icons/FullscreenExit.vue'
Expand All @@ -161,6 +170,7 @@ import GridView from 'vue-material-design-icons/ViewGrid.vue'
import { showWarning } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { t } from '@nextcloud/l10n'
import { generateOcsUrl } from '@nextcloud/router'

import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
Expand Down Expand Up @@ -208,6 +218,7 @@ export default {
FullscreenExit,
GridView,
HandBackLeft,
IconDownload,
MicrophoneOff,
PromotedView,
RecordCircle,
Expand Down Expand Up @@ -369,6 +380,10 @@ export default {
showCallLayoutSwitch() {
return !this.callViewStore.isEmptyCallView
},

downloadCallParticipantsLink() {
return generateOcsUrl('apps/spreed/api/v4/call/{token}/download', { token: this.token })
},
},

watch: {
Expand Down
Loading