-
Notifications
You must be signed in to change notification settings - Fork 436
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 #13519
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
use OCA\Talk\Middleware\Attribute\RequireCallEnabled; | ||
use OCA\Talk\Middleware\Attribute\RequireFederatedParticipant; | ||
use OCA\Talk\Middleware\Attribute\RequireModeratorOrNoLobby; | ||
use OCA\Talk\Middleware\Attribute\RequireModeratorParticipant; | ||
use OCA\Talk\Middleware\Attribute\RequireParticipant; | ||
use OCA\Talk\Middleware\Attribute\RequirePermission; | ||
use OCA\Talk\Middleware\Attribute\RequireReadWriteConversation; | ||
|
@@ -33,7 +34,9 @@ | |
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\Attribute\BruteForceProtection; | ||
use OCP\AppFramework\Http\Attribute\PublicPage; | ||
use OCP\AppFramework\Http\DataDownloadResponse; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\Http\Response; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\IRequest; | ||
use OCP\IUserManager; | ||
|
@@ -111,6 +114,53 @@ public function getPeersForCall(): DataResponse { | |
return new DataResponse($result); | ||
} | ||
|
||
/** | ||
* Download the list of current call participants | ||
* | ||
* Required capability: `download-call-participants` | ||
* | ||
* @param 'csv'|'pdf' $format Download format | ||
* @return DataDownloadResponse<Http::STATUS_OK, 'text/csv'|'application/pdf', array{}>|Response<Http::STATUS_BAD_REQUEST, array{}> | ||
* | ||
* 200: List of participants in the call downloaded in the requested format | ||
* 400: No call in progress | ||
*/ | ||
#[PublicPage] | ||
#[RequireModeratorParticipant] | ||
public function downloadParticipantsForCall(string $format = 'csv'): DataDownloadResponse|Response { | ||
$timeout = $this->timeFactory->getTime() - Session::SESSION_TIMEOUT; | ||
$participants = $this->participantService->getParticipantsInCall($this->room, $timeout); | ||
|
||
if (empty($participants)) { | ||
return new Response(Http::STATUS_BAD_REQUEST); | ||
} | ||
|
||
if ($format !== 'csv' && $format !== 'pdf') { | ||
// Unsupported format | ||
return new Response(Http::STATUS_BAD_REQUEST); | ||
} | ||
|
||
if ($format !== 'csv') { | ||
// FIXME Remove once pdf was implemented. | ||
return new Response(Http::STATUS_BAD_REQUEST); | ||
} | ||
|
||
$output = fopen('php://memory', 'w'); | ||
fputcsv($output, [ | ||
'name', | ||
'type', | ||
'identifier', | ||
]); | ||
Comment on lines
+149
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do that for the PDF version later. For the CSV I would keep it "ugly" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as-is should be less confusing for later use (like import) |
||
|
||
foreach ($participants as $participant) { | ||
fputcsv($output, [$participant->getAttendee()->getDisplayName(), $participant->getAttendee()->getActorType(), $participant->getAttendee()->getActorId()]); | ||
} | ||
|
||
fseek($output, 0); | ||
|
||
return new DataDownloadResponse(stream_get_contents($output), 'participants.csv', 'text/csv'); | ||
} | ||
|
||
/** | ||
* Join a call | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Currently only CSV is functional