From 2f858b04e3258552a8042d57108a03b7bc6bce47 Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 12 Nov 2026 17:38:12 +0100 Subject: [PATCH 1/4] Store OIDC subject identifier of users Save the sub claim in users.oidc_sub at every OIDC login, so that external services can identify the user. The column is hidden from serialization. --- app/Auth/OIDC/OIDCProvider.php | 3 ++ app/Models/User.php | 2 +- ..._12_000000_add_oidc_sub_to_users_table.php | 30 +++++++++++ tests/Backend/Feature/api/v1/OIDCTest.php | 50 +++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2026_11_12_000000_add_oidc_sub_to_users_table.php diff --git a/app/Auth/OIDC/OIDCProvider.php b/app/Auth/OIDC/OIDCProvider.php index 2101c45b12..37c870d5bb 100644 --- a/app/Auth/OIDC/OIDCProvider.php +++ b/app/Auth/OIDC/OIDCProvider.php @@ -87,6 +87,9 @@ public function login(Request $request): User // Get eloquent user (existing or new) $user = $oidc_user->createOrFindEloquentModel('oidc'); + // Store the subject identifier, it is used to identify the user in external services + $user->oidc_sub = $user_info['sub']; + // Sync attributes $oidc_user->syncWithEloquentModel($user, config('services.oidc.mapping')->roles); diff --git a/app/Models/User.php b/app/Models/User.php index 7940c509e0..91ecdbc2be 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -43,7 +43,7 @@ class User extends Authenticatable implements HasLocalePreference * @var array */ protected $hidden = [ - 'password', 'remember_token', + 'password', 'remember_token', 'oidc_sub', ]; /** diff --git a/database/migrations/2026_11_12_000000_add_oidc_sub_to_users_table.php b/database/migrations/2026_11_12_000000_add_oidc_sub_to_users_table.php new file mode 100644 index 0000000000..5b3a069f1e --- /dev/null +++ b/database/migrations/2026_11_12_000000_add_oidc_sub_to_users_table.php @@ -0,0 +1,30 @@ +string('oidc_sub', 255)->nullable()->after('external_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('oidc_sub'); + }); + } +}; diff --git a/tests/Backend/Feature/api/v1/OIDCTest.php b/tests/Backend/Feature/api/v1/OIDCTest.php index 05a67675e6..cbfb865d3c 100644 --- a/tests/Backend/Feature/api/v1/OIDCTest.php +++ b/tests/Backend/Feature/api/v1/OIDCTest.php @@ -1027,6 +1027,56 @@ public function test_callback_with_existing_user() $this->assertEquals($user->roles()->pluck('name')->toArray(), ['admin', 'user']); } + /** + * Log in via the fake OIDC server with the given subject identifier + */ + private function loginWithSubject(string $sub): void + { + $nonce = Str::random(); + $state = Str::random(); + + $userInfoClaims = [ + 'sub' => $sub, + 'given_name' => 'Ada', + 'family_name' => 'Testperson', + 'email' => 'ada.testperson@example.org', + 'groups' => ['student'], + ]; + + $this->fake_oidc_server($sub, $this->faker->uuid(), $nonce, $userInfoClaims); + + Session::put('openid_connect_state', $state); + Session::put('openid_connect_nonce', $nonce); + + $this->get(route('auth.oidc.callback', [ + 'code' => Str::random(), + 'state' => $state, + ])); + } + + public function test_callback_stores_oidc_sub_for_new_user() + { + $this->loginWithSubject('fixture-sub-ada-0001'); + + $this->assertAuthenticated(); + $this->assertEquals('fixture-sub-ada-0001', Auth::user()->oidc_sub); + $this->assertEquals('fixture-sub-ada-0001', Auth::user()->fresh()->oidc_sub); + } + + public function test_callback_updates_oidc_sub_of_existing_user() + { + $user = User::factory()->create([ + 'authenticator' => 'oidc', + 'external_id' => 'fixture-sub-ada-0001', + 'oidc_sub' => 'fixture-sub-stale-0000', + ]); + + $this->loginWithSubject('fixture-sub-ada-0001'); + + $this->assertAuthenticatedAs($user); + $this->assertEquals('fixture-sub-ada-0001', $user->fresh()->oidc_sub); + } + public function test_callback_with_user_info_unsigned() { // Create a new RSA key pair for signing the ID token From 92e175c24bef32a00b531e8bff44fa8da5d87e2d Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 12 Nov 2026 17:38:12 +0100 Subject: [PATCH 2/4] Add meeting summaries using an external summary service Rooms can opt in to AI meeting summaries created by an external summary service. The feature is off unless RECAP_ENABLED, RECAP_SERVICE_URL and RECAP_FRONTEND_TOKEN are set. - Room setting recap, changeable by the room owner only and available once the owner has logged in via OIDC; room types set the meeting type and the summary destination and can enforce the setting off - On meeting start PILOS records the meeting, adds the meta_-* create parameters, stores the internal meeting ID and registers the owner with the summary service in a queued job; deleting the room cancels the registrations - Join and start ask for consent to the summary; meetings with a summary but without recording do not record the camera video and their playback recordings are not imported - After the meeting ends a queued job polls the service for the result and stores it as a meeting summary of the room: a document link or the summary text, which can be downloaded as a Markdown file - Meeting summaries use the access levels of recordings and are deleted after the recording retention period --- .env.example | 14 + .../Commands/CleanupRecordingsCommand.php | 7 +- .../api/v1/MeetingSummaryController.php | 117 ++++ .../Controllers/api/v1/RoomController.php | 2 + .../Controllers/api/v1/RoomTypeController.php | 6 + app/Http/Requests/JoinMeetingRequest.php | 49 ++ .../Requests/MeetingSummaryIndexRequest.php | 25 + app/Http/Requests/RoomTypeRequest.php | 8 + app/Http/Requests/StartMeetingRequest.php | 52 ++ .../Requests/UpdateMeetingSummaryRequest.php | 25 + .../Requests/UpdateRoomSettingsRequest.php | 11 + app/Http/Resources/ConfigResource.php | 4 + app/Http/Resources/MeetingSummaryResource.php | 30 + app/Http/Resources/RoomResource.php | 1 + app/Http/Resources/RoomSettingsResource.php | 2 + app/Http/Resources/RoomTypeResource.php | 2 + app/Jobs/CancelRecapRegistration.php | 125 +++++ app/Jobs/PollMeetingSummary.php | 353 ++++++++++++ app/Jobs/ProcessRecording.php | 16 + app/Jobs/RegisterRecapMeeting.php | 129 +++++ app/Models/Meeting.php | 1 + app/Models/MeetingSummary.php | 73 +++ app/Models/Room.php | 47 ++ app/Observers/RoomObserver.php | 16 + app/Policies/RoomPolicy.php | 43 ++ app/Rules/CustomCreateMeetingParameters.php | 10 + app/Services/MeetingService.php | 25 +- app/Services/RecapService.php | 105 ++++ app/Services/RoomService.php | 21 + config/recap.php | 16 + database/factories/MeetingSummaryFactory.php | 43 ++ ...2_000001_add_recap_to_room_types_table.php | 33 ++ ..._11_12_000002_add_recap_to_rooms_table.php | 30 + ..._12_000003_add_recap_to_meetings_table.php | 31 ++ ..._000004_create_meeting_summaries_table.php | 40 ++ lang/en/admin.php | 7 + lang/en/app.php | 1 + lang/en/rooms.php | 42 ++ lang/en/validation.php | 17 + routes/api.php | 9 + .../Feature/api/v1/MeetingSummaryTest.php | 367 ++++++++++++ .../api/v1/Room/RoomRecapStartTest.php | 447 +++++++++++++++ .../Feature/api/v1/Room/RoomRecapTest.php | 242 ++++++++ .../Backend/Feature/api/v1/Room/RoomTest.php | 4 +- .../Feature/api/v1/RoomTypeRecapTest.php | 153 +++++ tests/Backend/Feature/api/v1/RoomTypeTest.php | 4 + .../Console/CleanupRecordingsCommandTest.php | 25 + .../Unit/Jobs/CancelRecapRegistrationTest.php | 121 ++++ .../Unit/Jobs/PollMeetingSummaryTest.php | 524 ++++++++++++++++++ .../Unit/Jobs/ProcessRecordingTest.php | 72 +++ .../Unit/Jobs/RegisterRecapMeetingTest.php | 213 +++++++ tests/Backend/Unit/RecapConfigTest.php | 62 +++ 52 files changed, 3819 insertions(+), 3 deletions(-) create mode 100644 app/Http/Controllers/api/v1/MeetingSummaryController.php create mode 100644 app/Http/Requests/MeetingSummaryIndexRequest.php create mode 100644 app/Http/Requests/UpdateMeetingSummaryRequest.php create mode 100644 app/Http/Resources/MeetingSummaryResource.php create mode 100644 app/Jobs/CancelRecapRegistration.php create mode 100644 app/Jobs/PollMeetingSummary.php create mode 100644 app/Jobs/RegisterRecapMeeting.php create mode 100644 app/Models/MeetingSummary.php create mode 100644 app/Services/RecapService.php create mode 100644 config/recap.php create mode 100644 database/factories/MeetingSummaryFactory.php create mode 100644 database/migrations/2026_11_12_000001_add_recap_to_room_types_table.php create mode 100644 database/migrations/2026_11_12_000002_add_recap_to_rooms_table.php create mode 100644 database/migrations/2026_11_12_000003_add_recap_to_meetings_table.php create mode 100644 database/migrations/2026_11_12_000004_create_meeting_summaries_table.php create mode 100644 tests/Backend/Feature/api/v1/MeetingSummaryTest.php create mode 100644 tests/Backend/Feature/api/v1/Room/RoomRecapStartTest.php create mode 100644 tests/Backend/Feature/api/v1/Room/RoomRecapTest.php create mode 100644 tests/Backend/Feature/api/v1/RoomTypeRecapTest.php create mode 100644 tests/Backend/Unit/Jobs/CancelRecapRegistrationTest.php create mode 100644 tests/Backend/Unit/Jobs/PollMeetingSummaryTest.php create mode 100644 tests/Backend/Unit/Jobs/RegisterRecapMeetingTest.php create mode 100644 tests/Backend/Unit/RecapConfigTest.php diff --git a/.env.example b/.env.example index 6996bc6703..ad3b3c5620 100644 --- a/.env.example +++ b/.env.example @@ -83,6 +83,20 @@ MAIL_FROM_NAME="${APP_NAME}" #OIDC_CLIENT_SECRET= #OIDC_SCOPES=profile,email +# Meeting summaries (recap) +# Master switch for the room setting and the room type fields (also requires RECAP_SERVICE_URL and RECAP_FRONTEND_TOKEN) +#RECAP_ENABLED=false +# Prefix of the BBB meta parameters (meta_-*), must equal the prefix of the recording exporter +# Lowercase letter followed by 1-15 lowercase letters or digits; an invalid prefix disables the feature +#RECAP_META_PREFIX=recap +# Base URL of the meeting summary service; the feature stays off without it +#RECAP_SERVICE_URL=https://recap.example.org +# Bearer token of this front end at the meeting summary service; the feature stays off without it +#RECAP_FRONTEND_TOKEN= +# Timeouts in seconds for requests to the meeting summary service +#RECAP_SERVER_TIMEOUT=10 +#RECAP_SERVER_CONNECT_TIMEOUT=20 + # Enabled locales # Comma separated list, e.g. de,en # If unset all available locales are enabled (lang + resources/custom/lang) diff --git a/app/Console/Commands/CleanupRecordingsCommand.php b/app/Console/Commands/CleanupRecordingsCommand.php index 13c2ae4fd6..0459cf0ecd 100644 --- a/app/Console/Commands/CleanupRecordingsCommand.php +++ b/app/Console/Commands/CleanupRecordingsCommand.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use App\Enums\TimePeriod; +use App\Models\MeetingSummary; use App\Models\Recording; use App\Settings\RecordingSettings; use Illuminate\Console\Command; @@ -24,7 +25,7 @@ class CleanupRecordingsCommand extends Command * * @var string */ - protected $description = 'Remove recordings after retention period'; + protected $description = 'Remove recordings and meeting summaries after retention period'; /** * Execute the console command. @@ -42,6 +43,10 @@ public function handle() Recording::where('start', '<', $day)->get()->each(function ($recording) { $recording->delete(); }); + + // Meeting summaries follow the retention period of the recordings + Log::info('Removing meeting summaries older than '.$day); + MeetingSummary::where('start', '<', $day)->delete(); } } } diff --git a/app/Http/Controllers/api/v1/MeetingSummaryController.php b/app/Http/Controllers/api/v1/MeetingSummaryController.php new file mode 100644 index 0000000000..788c4a4b5b --- /dev/null +++ b/app/Http/Controllers/api/v1/MeetingSummaryController.php @@ -0,0 +1,117 @@ + + */ + private const LIST_COLUMNS = ['id', 'room_id', 'meeting_id', 'access', 'start', 'end', 'document_url', 'delivered_at']; + + public function index(Room $room, MeetingSummaryIndexRequest $request, GeneralSettings $generalSettings): AnonymousResourceCollection + { + $additional = []; + + // Sort direction, fallback/default is newest first + $sortOrder = match ($request->query('sort_direction')) { + 'asc' => 'ASC', + default => 'DESC', + }; + + // Filter, default is no filter + $filter = match ($request->query('filter')) { + 'everyone_access' => RecordingAccess::EVERYONE, + 'participant_access' => RecordingAccess::PARTICIPANT, + 'moderator_access' => RecordingAccess::MODERATOR, + 'owner_access' => RecordingAccess::OWNER, + default => null, + }; + + $resource = $room->meetingSummaries()->select(self::LIST_COLUMNS)->orderBy('start', $sortOrder)->orderBy('id'); + + // If user is not allowed to view all summaries, only query summaries that should be visible to the user + if (! Gate::allows('viewAllMeetingSummaries', $room)) { + $allowedAccess = [RecordingAccess::EVERYONE]; + + if ($room->isModerator(Auth::user())) { + $allowedAccess[] = RecordingAccess::MODERATOR; + $allowedAccess[] = RecordingAccess::PARTICIPANT; + } elseif ($room->isMember(Auth::user())) { + $allowedAccess[] = RecordingAccess::PARTICIPANT; + } + + $resource = $resource->whereIn('access', $allowedAccess); + } + + // count all before applying filters + $additional['meta']['total_no_filter'] = $resource->count(); + + if ($filter) { + $resource = $resource->where('access', $filter); + } + + return MeetingSummaryResource::collection($resource->paginate($generalSettings->pagination_page_size))->additional($additional); + } + + /** + * Download the summary text as a Markdown file; only for summaries stored in PILOS (not for document links) + */ + public function download(Room $room, MeetingSummary $meetingSummary, GeneralSettings $generalSettings): Response + { + $this->authorize('viewMeetingSummary', [$room, $meetingSummary]); + + if ($meetingSummary->content === null) { + abort(404); + } + + // ASCII file name from the room ID and the local start time, e.g. meeting-summary-abc-def-123-2026-11-12-0930.md + $timezone = Auth::user()?->timezone ?? $generalSettings->default_timezone; + $start = $meetingSummary->start->copy()->setTimezone($timezone)->format('Y-m-d-Hi'); + $filename = preg_replace('/[^A-Za-z0-9_-]/', '-', 'meeting-summary-'.$room->id.'-'.$start).'.md'; + + // Same protection as room files: never rendered as a document, no active content if opened directly + return response($meetingSummary->content, 200, [ + 'Content-Type' => 'text/markdown; charset=utf-8', + 'Content-Disposition' => HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $filename), + 'Content-Security-Policy' => "default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'", + 'X-Content-Type-Options' => 'nosniff', + ]); + } + + public function update(UpdateMeetingSummaryRequest $request, Room $room, MeetingSummary $meetingSummary): MeetingSummaryResource + { + $meetingSummary->access = $request->enum('access', RecordingAccess::class); + $meetingSummary->save(); + + return new MeetingSummaryResource($meetingSummary); + } + + public function destroy(Room $room, MeetingSummary $meetingSummary): Response + { + Log::info('Deleted meeting summary {summary} in room {room}', ['room' => $room->getLogLabel(), 'summary' => $meetingSummary->getLogLabel()]); + + $meetingSummary->delete(); + + return response()->noContent(); + } +} diff --git a/app/Http/Controllers/api/v1/RoomController.php b/app/Http/Controllers/api/v1/RoomController.php index 102cccde38..8c1d25cc14 100644 --- a/app/Http/Controllers/api/v1/RoomController.php +++ b/app/Http/Controllers/api/v1/RoomController.php @@ -241,6 +241,7 @@ public function getStartRequirements(Room $room) { $features = [ 'recording' => config('recording.enabled') && $room->getRoomSetting('record'), + 'recap' => (new RoomService($room))->isRecapActive(), 'attendance_recording' => $room->getRoomSetting('record_attendance'), 'streaming' => $room->streaming->enabled, ]; @@ -254,6 +255,7 @@ public function getJoinRequirements(Room $room) $features = [ 'recording' => $meeting?->record ?? false, + 'recap' => $meeting?->recap ?? false, 'attendance_recording' => $meeting?->record_attendance ?? false, 'streaming' => $meeting ? $room->streaming->enabled_for_current_meeting : false, ]; diff --git a/app/Http/Controllers/api/v1/RoomTypeController.php b/app/Http/Controllers/api/v1/RoomTypeController.php index 9f4a50c0c3..f088c3e5f4 100644 --- a/app/Http/Controllers/api/v1/RoomTypeController.php +++ b/app/Http/Controllers/api/v1/RoomTypeController.php @@ -112,6 +112,9 @@ public function update(RoomTypeRequest $request, RoomType $roomType) $roomType->has_access_code_default = $request->has_access_code_default; $roomType->has_access_code_enforced = $request->has_access_code_enforced; + $roomType->recap_type = $request->recap_type; + $roomType->recap_sink = $request->recap_sink; + $roomType->save(); if ($roomType->restrict) { @@ -148,6 +151,9 @@ public function store(RoomTypeRequest $request) $roomType->has_access_code_default = $request->has_access_code_default; $roomType->has_access_code_enforced = $request->has_access_code_enforced; + $roomType->recap_type = $request->recap_type; + $roomType->recap_sink = $request->recap_sink; + $roomType->save(); if ($roomType->restrict) { diff --git a/app/Http/Requests/JoinMeetingRequest.php b/app/Http/Requests/JoinMeetingRequest.php index 44f053cc3a..bfc68d41cf 100644 --- a/app/Http/Requests/JoinMeetingRequest.php +++ b/app/Http/Requests/JoinMeetingRequest.php @@ -47,9 +47,58 @@ private function getRecordingRules(): array ]; } + // Meeting summary without recording, the camera video is not recorded + if ($this->isSummaryOnly()) { + return [ + 'consent_record' => ['required', 'boolean', 'accepted'], // Consent to join meeting with meeting summary enabled + ]; + } + return []; } + /** + * Custom messages for the meeting summary consent, which shares the field with the recording consent + * + * @return array + */ + public function messages(): array + { + if ($this->isSummaryOnly()) { + return [ + 'consent_record.accepted' => __('validation.custom.consent_recap.accepted'), + ]; + } + + return []; + } + + /** + * Custom attribute names for the meeting summary consent, which shares the field with the recording consent + * + * @return array + */ + public function attributes(): array + { + if ($this->isSummaryOnly()) { + return [ + 'consent_record' => __('validation.attributes.consent_recap'), + ]; + } + + return []; + } + + /** + * Whether the meeting creates a meeting summary without a recording + */ + private function isSummaryOnly(): bool + { + $meeting = $this->room->latestMeeting; + + return ! $meeting?->record && (bool) $meeting?->recap; + } + private function getStreamingRules(): array { $streaming = $this->room->streaming; diff --git a/app/Http/Requests/MeetingSummaryIndexRequest.php b/app/Http/Requests/MeetingSummaryIndexRequest.php new file mode 100644 index 0000000000..afc40d36ea --- /dev/null +++ b/app/Http/Requests/MeetingSummaryIndexRequest.php @@ -0,0 +1,25 @@ +|string> + */ + public function rules(): array + { + return [ + 'filter' => [Rule::in(['everyone_access', 'participant_access', 'moderator_access', 'owner_access'])], + 'sort_direction' => [Rule::in(['asc', 'desc'])], + ]; + } +} diff --git a/app/Http/Requests/RoomTypeRequest.php b/app/Http/Requests/RoomTypeRequest.php index 3182711768..1663ef3c2e 100644 --- a/app/Http/Requests/RoomTypeRequest.php +++ b/app/Http/Requests/RoomTypeRequest.php @@ -37,6 +37,14 @@ public function rules() $rules[$setting.'_enforced'] = ['required', 'boolean']; } + // Meeting summaries (recap) can only be enforced off, never on + $rules['recap_default'][] = 'declined_if:recap_enforced,true'; + + // Meeting type and sink of the summaries, required if the room type offers summaries + $recapOffered = Room::isRecapEnabled() && ! $this->boolean('recap_enforced'); + $rules['recap_type'] = [Rule::requiredIf($recapOffered), 'nullable', 'string', 'regex:/^[a-z][a-z0-9-]{0,62}$/']; + $rules['recap_sink'] = [Rule::requiredIf($recapOffered), 'nullable', 'string', 'regex:/^[a-z][a-z0-9-]{0,62}$/']; + if ($this->roomType) { $rules['name'] = ['required', 'string', 'max:255', Rule::unique('room_types', 'name')->ignore($this->roomType->id)]; } diff --git a/app/Http/Requests/StartMeetingRequest.php b/app/Http/Requests/StartMeetingRequest.php index e26a3db697..9a6689f166 100644 --- a/app/Http/Requests/StartMeetingRequest.php +++ b/app/Http/Requests/StartMeetingRequest.php @@ -4,6 +4,7 @@ namespace App\Http\Requests; +use App\Services\RoomService; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Context; @@ -46,9 +47,60 @@ private function getRecordingRules(): array ]; } + // Meeting summary without recording, the camera video is not recorded + if ($this->isSummaryOnly()) { + return [ + 'consent_record' => ['required', 'boolean', 'accepted'], // Consent to join meeting with meeting summary enabled + ]; + } + return []; } + /** + * Custom messages for the meeting summary consent, which shares the field with the recording consent + * + * @return array + */ + public function messages(): array + { + if ($this->isSummaryOnly()) { + return [ + 'consent_record.accepted' => __('validation.custom.consent_recap.accepted'), + ]; + } + + return []; + } + + /** + * Custom attribute names for the meeting summary consent, which shares the field with the recording consent + * + * @return array + */ + public function attributes(): array + { + if ($this->isSummaryOnly()) { + return [ + 'consent_record' => __('validation.attributes.consent_recap'), + ]; + } + + return []; + } + + /** + * Whether the meeting creates a meeting summary without a recording + */ + private function isSummaryOnly(): bool + { + if ($this->room->getRoomSetting('record')) { + return false; + } + + return (new RoomService($this->room))->isRecapActive(); + } + private function getStreamingRules(): array { $streaming = $this->room->streaming; diff --git a/app/Http/Requests/UpdateMeetingSummaryRequest.php b/app/Http/Requests/UpdateMeetingSummaryRequest.php new file mode 100644 index 0000000000..25084d3ba2 --- /dev/null +++ b/app/Http/Requests/UpdateMeetingSummaryRequest.php @@ -0,0 +1,25 @@ +|string> + */ + public function rules(): array + { + return [ + 'access' => ['required', Rule::enum(RecordingAccess::class)], + ]; + } +} diff --git a/app/Http/Requests/UpdateRoomSettingsRequest.php b/app/Http/Requests/UpdateRoomSettingsRequest.php index 8d50976d0d..637edb58be 100644 --- a/app/Http/Requests/UpdateRoomSettingsRequest.php +++ b/app/Http/Requests/UpdateRoomSettingsRequest.php @@ -11,6 +11,17 @@ class UpdateRoomSettingsRequest extends FormRequest { + /** + * Keep the current recap setting if the user is not allowed to change it + * or if the feature is not available for the room. + */ + protected function prepareForValidation(): void + { + if (! $this->room->isRecapAvailable() || ! $this->user()->can('manageRecap', $this->room)) { + $this->merge(['recap' => $this->room->recap]); + } + } + public function rules() { $rules = [ diff --git a/app/Http/Resources/ConfigResource.php b/app/Http/Resources/ConfigResource.php index 18d5ddaf97..6909ef75cd 100644 --- a/app/Http/Resources/ConfigResource.php +++ b/app/Http/Resources/ConfigResource.php @@ -4,6 +4,7 @@ namespace App\Http\Resources; +use App\Models\Room; use App\Settings\BannerSettings; use App\Settings\GeneralSettings; use App\Settings\RecordingSettings; @@ -110,6 +111,9 @@ public function toArray($request) 'refresh_interval' => config('streaming.refresh_interval'), 'show_fps' => config('streaming.show_fps'), ], + 'recap' => [ + 'enabled' => Room::isRecapEnabled(), + ], 'auth' => [ 'local' => config('auth.local.enabled'), 'ldap' => config('ldap.enabled'), diff --git a/app/Http/Resources/MeetingSummaryResource.php b/app/Http/Resources/MeetingSummaryResource.php new file mode 100644 index 0000000000..6cf082f008 --- /dev/null +++ b/app/Http/Resources/MeetingSummaryResource.php @@ -0,0 +1,30 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'model_name' => $this->model_name, + 'start' => $this->start, + 'end' => $this->end, + 'delivered_at' => $this->delivered_at, + 'access' => $this->access, + 'type' => $this->document_url !== null ? 'document' : 'content', + 'document_url' => $this->document_url, + ]; + } +} diff --git a/app/Http/Resources/RoomResource.php b/app/Http/Resources/RoomResource.php index cc784db201..fa2f133f4b 100644 --- a/app/Http/Resources/RoomResource.php +++ b/app/Http/Resources/RoomResource.php @@ -66,6 +66,7 @@ public function getDetails($latestMeeting) 'can_start' => Gate::inspect('start', [$this->resource])->allowed(), 'access_code' => $this->when(Gate::inspect('viewAccessCode', [$this->resource])->allowed(), $this->access_code), 'room_type_invalid' => $this->roomTypeInvalid, + 'has_meeting_summaries' => $this->resource->meetingSummaries()->exists(), 'current_user' => new UserResource(Auth::user())->withPermissions()->withoutRoles(), ]; } diff --git a/app/Http/Resources/RoomSettingsResource.php b/app/Http/Resources/RoomSettingsResource.php index 6c1851f1dd..857da296a5 100644 --- a/app/Http/Resources/RoomSettingsResource.php +++ b/app/Http/Resources/RoomSettingsResource.php @@ -7,6 +7,7 @@ use App\Models\Room; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Support\Facades\Auth; class RoomSettingsResource extends JsonResource { @@ -36,6 +37,7 @@ public function toArray($request) 'short_description' => $this->short_description, 'access_code' => $this->access_code, 'room_type' => (new RoomTypeResource($this->roomType))->withDefaultRoomSettings()->withFeatures(), + 'recap_available' => $this->when(Auth::user()?->can('manageRecap', $this->resource) ?? false, fn () => $this->isRecapAvailable()), $this->merge($this->getRoomSettings()), ]; } diff --git a/app/Http/Resources/RoomTypeResource.php b/app/Http/Resources/RoomTypeResource.php index ebc2917748..901cd3db69 100644 --- a/app/Http/Resources/RoomTypeResource.php +++ b/app/Http/Resources/RoomTypeResource.php @@ -103,6 +103,8 @@ public function toArray($request) 'max_duration' => $this->max_duration, 'create_parameters' => $this->create_parameters, 'join_parameters' => $this->join_parameters, + 'recap_type' => $this->recap_type, + 'recap_sink' => $this->recap_sink, 'roles' => new RoleResourceCollection($this->roles), ]), diff --git a/app/Jobs/CancelRecapRegistration.php b/app/Jobs/CancelRecapRegistration.php new file mode 100644 index 0000000000..7e27e6e5c5 --- /dev/null +++ b/app/Jobs/CancelRecapRegistration.php @@ -0,0 +1,125 @@ +recordId; + } + + /** + * Get the tags that should be assigned to the job. + * + * @return array + */ + public function tags(): array + { + return ['recap']; + } + + /** + * Determine the time at which the job should timeout. + */ + public function retryUntil(): DateTime + { + return now()->addDay(); + } + + /** + * Calculate the number of seconds to wait before retrying the job. + * + * @return array + */ + public function backoff(): array + { + return [30, 60, 60 * 5]; + } + + /** + * Execute the job. + * + * @throws RuntimeException + */ + public function handle(RecapService $recapService): void + { + if (! RecapService::isConfigured()) { + Log::warning('Meeting summary registration {record} not cancelled; service not configured', ['record' => $this->recordId]); + $this->fail('Meeting summary service not configured'); + + return; + } + + // Connection errors are thrown and the job is retried + $response = $recapService->cancel($this->recordId); + + // 204: cancelled, 202: running job stopped, 404: unknown or already removed + if ($response->successful() || $response->notFound()) { + Log::info('Cancelled meeting summary registration {record}', ['record' => $this->recordId]); + + return; + } + + if ($response->conflict() && $response->json('type') === 'urn:recap:problem:already-delivered') { + Log::notice('Meeting summary registration {record} not cancelled; summary already delivered', ['record' => $this->recordId]); + + return; + } + + if (RecapService::isRetryable($response)) { + throw new RuntimeException('Cancelling meeting summary registration failed with status '.$response->status()); + } + + Log::error('Cancelling meeting summary registration {record} rejected with status {status}', [ + 'record' => $this->recordId, + 'status' => $response->status(), + 'type' => $response->json('type'), + ]); + $this->fail('Cancelling meeting summary registration rejected with status '.$response->status()); + } +} diff --git a/app/Jobs/PollMeetingSummary.php b/app/Jobs/PollMeetingSummary.php new file mode 100644 index 0000000000..dc78f7fa61 --- /dev/null +++ b/app/Jobs/PollMeetingSummary.php @@ -0,0 +1,353 @@ + + */ + public const POLL_DELAYS = [2, 5, 10, 30]; + + /** + * Minutes between polls after POLL_DELAYS + */ + public const POLL_INTERVAL = 60; + + /** + * Hours after the meeting end after which polling stops + */ + public const POLL_HOURS = 24; + + /** + * Maximum accepted size of a summary text in bytes (2 MiB) + */ + public const MAX_SUMMARY_BYTES = 2 * 1024 * 1024; + + /** + * Delete the job if the meeting no longer exists (e.g. room deleted). + * + * @var bool + */ + public $deleteWhenMissingModels = true; + + /** + * The number of times the job may be attempted, limited by retryUntil(). + * + * @var int + */ + public $tries = 0; + + /** + * The number of seconds after which the job's unique lock will be released. + * + * @var int + */ + public $uniqueFor = (self::POLL_HOURS + 1) * 3600; + + /** + * Create a new job instance. + * + * @param Meeting $meeting Ended meeting with a meeting summary + */ + public function __construct(public Meeting $meeting) {} + + /** + * Dispatch the first poll for an ended meeting + */ + public static function dispatchAfterEnd(Meeting $meeting): void + { + self::dispatch($meeting)->delay(now()->addMinutes(self::pollDelay(1))); + } + + /** + * Minutes to wait before the given poll (1 = first poll after the meeting end) + */ + public static function pollDelay(int $poll): int + { + return self::POLL_DELAYS[$poll - 1] ?? self::POLL_INTERVAL; + } + + /** + * Get the unique ID for the job. + */ + public function uniqueId(): string + { + return $this->meeting->id; + } + + /** + * Get the tags that should be assigned to the job. + * + * @return array + */ + public function tags(): array + { + return ['recap']; + } + + /** + * Safety limit, polling normally stops earlier (see pollAgain()). + */ + public function retryUntil(): DateTime + { + return now()->addHours(self::POLL_HOURS + 1); + } + + /** + * Execute the job. + */ + public function handle(RecapService $recapService): void + { + $recordId = $this->meeting->internal_meeting_id; + + if (! RecapService::isConfigured() || empty($recordId)) { + Log::warning('Meeting summary result of meeting {meeting} not polled; service or record id missing', ['meeting' => $this->meeting->getLogLabel()]); + + return; + } + + try { + $response = $recapService->getRegistration($recordId); + } catch (ConnectionException) { + $this->pollAgain('connection error'); + + return; + } + + if ($response->notFound()) { + Log::info('Meeting summary result of meeting {meeting} not available; registration not found', ['meeting' => $this->meeting->getLogLabel()]); + + return; + } + + if (! $response->successful()) { + $this->handleErrorResponse($response, 'registration'); + + return; + } + + $status = $response->json('status'); + $job = $response->json('job'); + + if ($status === 'cancelled' || ($job['state'] ?? null) === 'failed' || in_array($job['outcome'] ?? null, ['cancelled', 'purged'], true)) { + Log::info('Meeting summary of meeting {meeting} not delivered; registration {status}, job {state}, outcome {outcome}', [ + 'meeting' => $this->meeting->getLogLabel(), + 'status' => $status, + 'state' => $job['state'] ?? null, + 'outcome' => $job['outcome'] ?? null, + ]); + + return; + } + + if (($job['outcome'] ?? null) !== 'delivered') { + $this->pollAgain(); + + return; + } + + $this->storeResult($recapService, $recordId, $job); + } + + /** + * Store the delivered result and confirm the pickup of a summary text + * + * @param array{document_url?: string|null, summary_available?: bool, delivered_at?: string|null} $job + */ + private function storeResult(RecapService $recapService, string $recordId, array $job): void + { + $summaryAvailable = ($job['summary_available'] ?? false) === true; + $meetingSummary = MeetingSummary::where('meeting_id', $this->meeting->id)->first(); + + if ($meetingSummary === null) { + $content = null; + $contentReceived = false; + if ($summaryAvailable) { + try { + $summaryResponse = $recapService->getSummary($recordId); + } catch (ConnectionException) { + $this->pollAgain('connection error'); + + return; + } + + if ($summaryResponse->successful()) { + $contentReceived = true; + $content = $this->acceptedContent($summaryResponse->body()); + } elseif (! $summaryResponse->notFound()) { + $this->handleErrorResponse($summaryResponse, 'summary'); + + return; + } + } + + $documentUrlReceived = ($job['document_url'] ?? null) !== null; + $documentUrl = $this->acceptedDocumentUrl($job['document_url'] ?? null); + + if ($documentUrl === null && $content === null) { + // A rejected text or link was already logged as a warning + if (! $contentReceived && ! $documentUrlReceived) { + Log::notice('Meeting summary of meeting {meeting} delivered without a document link or summary text', ['meeting' => $this->meeting->getLogLabel()]); + } + } else { + $meetingSummary = new MeetingSummary; + $meetingSummary->room_id = $this->meeting->room_id; + $meetingSummary->meeting_id = $this->meeting->id; + $meetingSummary->access = RecordingAccess::OWNER; + $meetingSummary->start = $this->meeting->start; + $meetingSummary->end = $this->meeting->end; + $meetingSummary->document_url = $documentUrl; + $meetingSummary->content = $content; + $meetingSummary->delivered_at = $job['delivered_at'] ?? now(); + $meetingSummary->save(); + + Log::info('Stored meeting summary {summary} of meeting {meeting} in room {room}', [ + 'summary' => $meetingSummary->getLogLabel(), + 'meeting' => $this->meeting->getLogLabel(), + 'room' => $this->meeting->room->getLogLabel(), + 'type' => $content !== null ? 'content' : 'document', + ]); + } + } + + if ($summaryAvailable) { + $this->confirmSummary($recapService, $recordId); + } + } + + /** + * Confirm the pickup, so the service deletes the summary text + */ + private function confirmSummary(RecapService $recapService, string $recordId): void + { + try { + $response = $recapService->confirmSummary($recordId); + } catch (ConnectionException) { + $this->pollAgain('connection error'); + + return; + } + + if ($response->successful() || $response->notFound()) { + Log::info('Confirmed the pickup of the meeting summary of meeting {meeting}', ['meeting' => $this->meeting->getLogLabel()]); + + return; + } + + $this->handleErrorResponse($response, 'summary confirmation'); + } + + /** + * Returns the summary text if it is valid UTF-8 and within the size limit + */ + private function acceptedContent(string $content): ?string + { + if (strlen($content) > self::MAX_SUMMARY_BYTES || ! mb_check_encoding($content, 'UTF-8')) { + Log::warning('Meeting summary text of meeting {meeting} rejected; {bytes} bytes, limit {limit} bytes, UTF-8 required', [ + 'meeting' => $this->meeting->getLogLabel(), + 'bytes' => strlen($content), + 'limit' => self::MAX_SUMMARY_BYTES, + ]); + + return null; + } + + return $content; + } + + /** + * Returns the document link if it is an absolute http(s) URL, as it is shown as a link to users + */ + private function acceptedDocumentUrl(mixed $url): ?string + { + if ($url === null) { + return null; + } + + $scheme = is_string($url) ? strtolower((string) parse_url($url, PHP_URL_SCHEME)) : ''; + if (filter_var($url, FILTER_VALIDATE_URL) === false || ! in_array($scheme, ['http', 'https'], true)) { + Log::warning('Meeting summary document link of meeting {meeting} rejected; not an http(s) URL', ['meeting' => $this->meeting->getLogLabel()]); + + return null; + } + + return $url; + } + + /** + * Retry later on rate limits and server errors, stop on other errors + */ + private function handleErrorResponse(Response $response, string $request): void + { + if (RecapService::isRetryable($response)) { + $this->pollAgain('status '.$response->status()); + + return; + } + + Log::error('Meeting summary {request} request for meeting {meeting} rejected with status {status}', [ + 'request' => $request, + 'meeting' => $this->meeting->getLogLabel(), + 'status' => $response->status(), + 'type' => $response->json('type'), + ]); + $this->fail('Meeting summary '.$request.' request rejected with status '.$response->status()); + } + + /** + * Release the job for the next poll, or give up if the next poll would be too late + * + * @param string|null $error Reason if the poll failed + */ + private function pollAgain(?string $error = null): void + { + if ($error !== null) { + Log::warning('Polling the meeting summary result of meeting {meeting} failed: {error}', ['meeting' => $this->meeting->getLogLabel(), 'error' => $error]); + } + + $delay = self::pollDelay($this->attempts() + 1); + $deadline = ($this->meeting->end ?? $this->meeting->start)->copy()->addHours(self::POLL_HOURS); + + if (now()->addMinutes($delay)->greaterThan($deadline)) { + Log::notice('Stopped polling the meeting summary result of meeting {meeting}; no result {hours} hours after the meeting end', [ + 'meeting' => $this->meeting->getLogLabel(), + 'hours' => self::POLL_HOURS, + ]); + + return; + } + + $this->release($delay * 60); + } +} diff --git a/app/Jobs/ProcessRecording.php b/app/Jobs/ProcessRecording.php index 77bd73258d..1efe0e105e 100644 --- a/app/Jobs/ProcessRecording.php +++ b/app/Jobs/ProcessRecording.php @@ -7,6 +7,7 @@ use App\Enums\RecordingAccess; use App\Exceptions\RecordingExtractionFailed; use App\Exceptions\UnsafeArchiveEntryException; +use App\Models\Meeting; use App\Models\RecordingFormat; use DateTime; use Exception; @@ -179,6 +180,9 @@ public function handle(): void return str_ends_with($file, 'metadata.xml'); }); + // Meetings with a meeting summary but without recording, their recordings are discarded + $summaryOnlyMeetingIds = []; + foreach ($metadataFiles as $metadataFile) { // Each directory with a metadata file inside is a recording format // the metadata file is describing the recording @@ -187,6 +191,14 @@ public function handle(): void $xmlContent = Storage::disk('recordings')->get($metadataFile); $xml = simplexml_load_string($xmlContent); + // BBB only records the meeting for the meeting summary, nobody asked for a recording + $meeting = Meeting::find((string) $xml->meta->meetingId); + if ($meeting?->recap && ! $meeting->record) { + $summaryOnlyMeetingIds[$meeting->id] = true; + + continue; + } + // Create or update the recording format in the database $recordingFormat = RecordingFormat::createFromRecordingXML($xml); @@ -209,6 +221,10 @@ public function handle(): void return; } } + + foreach (array_keys($summaryOnlyMeetingIds) as $meetingId) { + Log::info('Discarded recording of meeting {meeting}; the meeting only has a meeting summary, not a recording', ['meeting' => $meetingId]); + } } catch (Exception $e) { // Extraction failed, retry the job later (.tar file might be incomplete yet) Log::error('Extracting recording file '.$this->file.' failed: '.$e->getMessage()); diff --git a/app/Jobs/RegisterRecapMeeting.php b/app/Jobs/RegisterRecapMeeting.php new file mode 100644 index 0000000000..ddbbd31859 --- /dev/null +++ b/app/Jobs/RegisterRecapMeeting.php @@ -0,0 +1,129 @@ +meeting->id; + } + + /** + * Get the tags that should be assigned to the job. + * + * @return array + */ + public function tags(): array + { + return ['recap']; + } + + /** + * Determine the time at which the job should timeout. + */ + public function retryUntil(): DateTime + { + return now()->addDay(); + } + + /** + * Calculate the number of seconds to wait before retrying the job. + * + * @return array + */ + public function backoff(): array + { + return [30, 60, 60 * 5]; + } + + /** + * Execute the job. + * + * @throws RuntimeException + */ + public function handle(RecapService $recapService): void + { + if (! RecapService::isConfigured() || empty($this->meeting->internal_meeting_id) || empty($this->owner->oidc_sub)) { + Log::warning('Meeting summary registration for meeting {meeting} skipped; service, record id or owner subject missing', ['meeting' => $this->meeting->getLogLabel()]); + $this->fail('Meeting summary registration not possible'); + + return; + } + + // Connection errors are thrown and the job is retried + $response = $recapService->register($this->meeting, $this->owner); + + if ($response->successful()) { + Log::info('Registered meeting {meeting} for a meeting summary', ['meeting' => $this->meeting->getLogLabel()]); + + return; + } + + if (RecapService::isRetryable($response)) { + throw new RuntimeException('Meeting summary registration failed with status '.$response->status()); + } + + Log::error('Meeting summary registration for meeting {meeting} rejected with status {status}', [ + 'meeting' => $this->meeting->getLogLabel(), + 'status' => $response->status(), + 'type' => $response->json('type'), + ]); + $this->fail('Meeting summary registration rejected with status '.$response->status()); + } +} diff --git a/app/Models/Meeting.php b/app/Models/Meeting.php index 4a61d681e6..cc290551a4 100644 --- a/app/Models/Meeting.php +++ b/app/Models/Meeting.php @@ -41,6 +41,7 @@ class Meeting extends Model 'end' => 'datetime', 'record_attendance' => 'boolean', 'record' => 'boolean', + 'recap' => 'boolean', 'detached' => 'datetime', ]; diff --git a/app/Models/MeetingSummary.php b/app/Models/MeetingSummary.php new file mode 100644 index 0000000000..050a81ca81 --- /dev/null +++ b/app/Models/MeetingSummary.php @@ -0,0 +1,73 @@ + + */ + protected $fillable = [ + 'room_id', + 'meeting_id', + 'access', + 'start', + 'end', + 'document_url', + 'content', + 'delivered_at', + ]; + + /** + * The summary text is never serialized, it is only sent as a file by the download endpoint. + * + * @var list + */ + protected $hidden = [ + 'content', + ]; + + protected $casts = [ + 'start' => 'datetime', + 'end' => 'datetime', + 'delivered_at' => 'datetime', + 'access' => RecordingAccess::class, + ]; + + public function getLogLabel(): string + { + return $this->id.' (meeting '.$this->meeting_id.')'; + } + + /** + * Room the summary belongs to + */ + public function room(): BelongsTo + { + return $this->belongsTo(Room::class); + } + + /** + * Meeting the summary belongs to + */ + public function meeting(): BelongsTo + { + return $this->belongsTo(Meeting::class); + } +} diff --git a/app/Models/Room.php b/app/Models/Room.php index 1efc58cf79..87a44294d6 100644 --- a/app/Models/Room.php +++ b/app/Models/Room.php @@ -17,7 +17,9 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Context; +use Illuminate\Support\Facades\Log; use Illuminate\Validation\Rule; #[ObservedBy([RoomObserver::class])] @@ -122,6 +124,10 @@ protected function casts() 'cast' => 'boolean', 'expert' => true, ], + 'recap' => [ + 'cast' => 'boolean', + 'expert' => false, + ], ]; /** @@ -176,6 +182,16 @@ public function recordings() return $this->hasMany(Recording::class)->chaperone(); } + /** + * Meeting summaries (results of the meeting summary service) + * + * @return HasMany + */ + public function meetingSummaries() + { + return $this->hasMany(MeetingSummary::class)->chaperone(); + } + /** * Room owner * @@ -408,6 +424,37 @@ public function getRoomSetting(string $settingName) return $this->roomType[$settingName.'_default']; } + /** + * Indicates whether the meeting summary (recap) feature is enabled. + * An invalid meta parameter prefix disables the feature, as the meta parameters would not match the recording exporter of the summary service. + * The warning about an invalid prefix is logged at most once per hour, as this is checked on every page load. + */ + public static function isRecapEnabled(): bool + { + if (! config('recap.enabled')) { + return false; + } + + if (preg_match('/^[a-z][a-z0-9]{1,15}$/', (string) config('recap.meta_prefix')) !== 1) { + if (Cache::add('recap-invalid-meta-prefix-logged', true, now()->addHour())) { + Log::warning('Meeting summaries disabled: RECAP_META_PREFIX must match ^[a-z][a-z0-9]{1,15}$'); + } + + return false; + } + + return true; + } + + /** + * Indicates whether the meeting summary (recap) can be activated for this room. + * Requires the feature to be enabled and the room owner to have logged in via OIDC (stored subject). + */ + public function isRecapAvailable(): bool + { + return self::isRecapEnabled() && ! empty($this->owner->oidc_sub); + } + /** * Returns true if the passed owner has rights to create a room * with the passed room type. diff --git a/app/Observers/RoomObserver.php b/app/Observers/RoomObserver.php index 9241636812..1f19e89693 100644 --- a/app/Observers/RoomObserver.php +++ b/app/Observers/RoomObserver.php @@ -6,9 +6,12 @@ use App\Enums\RoomAuthTokenType; use App\Exceptions\RoomIdGenerationFailed; +use App\Jobs\CancelRecapRegistration; use App\Models\Room; use App\Models\RoomAuthToken; +use App\Services\RecapService; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; @@ -59,6 +62,19 @@ public function updated(Room $room): void */ public function deleting(Room $room): void { + // Cancel meeting summary registrations, meetings are deleted by the database cascade + $recapRecordIds = $room->meetings() + ->where('recap', true) + ->whereNotNull('internal_meeting_id') + ->pluck('internal_meeting_id'); + if ($recapRecordIds->isNotEmpty()) { + if (RecapService::isConfigured()) { + $recapRecordIds->each(fn (string $recordId) => CancelRecapRegistration::dispatch($recordId)); + } else { + Log::warning('Meeting summary registrations of room {room} not cancelled; service not configured', ['room' => $room->getLogLabel(), 'count' => $recapRecordIds->count()]); + } + } + $room->files->each->delete(); $room->recordings->each->delete(); Storage::deleteDirectory($room->id); diff --git a/app/Policies/RoomPolicy.php b/app/Policies/RoomPolicy.php index a40566e284..1c0d2a5498 100644 --- a/app/Policies/RoomPolicy.php +++ b/app/Policies/RoomPolicy.php @@ -5,6 +5,7 @@ namespace App\Policies; use App\Enums\RecordingAccess; +use App\Models\MeetingSummary; use App\Models\RecordingFormat; use App\Models\Room; use App\Models\RoomFile; @@ -130,6 +131,15 @@ public function update(User $user, Room $room) return $room->owner->is($user) || $room->isCoOwner($user) || $user->can('rooms.manage'); } + /** + * Determine whether the user can change the meeting summary (recap) setting of the room. + * Only the room owner can opt in, as the summary is delivered to the owner. + */ + public function manageRecap(User $user, Room $room): bool + { + return $room->owner->is($user); + } + /** * Determine whether the user can transfer the room ownership * @@ -263,6 +273,39 @@ public function viewRecordingFormat(?User $user, Room $room, RecordingFormat $re return false; } + /** + * Determine whether the user can see all meeting summaries of the room, regardless of their access setting + */ + public function viewAllMeetingSummaries(User $user, Room $room): bool + { + return $user->can('manageMeetingSummaries', $room) || $user->can('rooms.viewAll'); + } + + /** + * Determine whether the user can change the access of and delete meeting summaries + */ + public function manageMeetingSummaries(User $user, Room $room): bool + { + return $room->owner->is($user) || $room->isCoOwner($user) || $user->can('rooms.manage'); + } + + /** + * Determine whether the user can view a meeting summary, based on its access setting + */ + public function viewMeetingSummary(?User $user, Room $room, MeetingSummary $meetingSummary): bool + { + if ($user && $user->can('viewAllMeetingSummaries', $room)) { + return true; + } + + return match ($meetingSummary->access) { + RecordingAccess::EVERYONE => true, + RecordingAccess::PARTICIPANT => $room->isMember($user), + RecordingAccess::MODERATOR => $room->isModerator($user), + default => false, + }; + } + public function viewStreaming(User $user, Room $room) { return $user->can('manageStreaming', $room) || $user->can('rooms.viewAll'); diff --git a/app/Rules/CustomCreateMeetingParameters.php b/app/Rules/CustomCreateMeetingParameters.php index e0e823151c..e81bdad372 100644 --- a/app/Rules/CustomCreateMeetingParameters.php +++ b/app/Rules/CustomCreateMeetingParameters.php @@ -8,6 +8,7 @@ use BigBlueButton\Parameters\CreateMeetingParameters; use Closure; use Illuminate\Contracts\Validation\ValidationRule; +use Illuminate\Support\Str; use Illuminate\Translation\PotentiallyTranslatedString; class CustomCreateMeetingParameters implements ValidationRule @@ -24,5 +25,14 @@ public function validate(string $attribute, mixed $value, Closure $fail): void foreach ($errors as $error) { $fail($error); } + + // Meta parameters of the meeting summary (recap) are reserved, they are set per room by the application + $reservedPrefix = 'meta_'.Str::lower(config('recap.meta_prefix')).'-'; + foreach (preg_split('/\n|\r\n?/', $value) as $createParameter) { + $parameter = trim(explode('=', $createParameter, 2)[0]); + if (Str::startsWith(Str::lower($parameter), $reservedPrefix)) { + $fail(__('validation.custom_parameter_reserved', ['parameter' => $parameter])); + } + } } } diff --git a/app/Services/MeetingService.php b/app/Services/MeetingService.php index dae44e9faf..fb279af383 100644 --- a/app/Services/MeetingService.php +++ b/app/Services/MeetingService.php @@ -9,6 +9,7 @@ use App\Events\RoomEnded; use App\Http\Requests\JoinMeetingRequest; use App\Http\Requests\StartMeetingRequest; +use App\Jobs\PollMeetingSummary; use App\Models\Meeting; use App\Models\MeetingAttendee; use App\Models\User; @@ -85,8 +86,9 @@ public function start(): ?CreateMeetingResponse } // Room settings take precedence + // A meeting summary needs the recording marks of BBB, so the meeting is recorded even if the room setting is off $meetingParams - ->setRecord($this->meeting->record) + ->setRecord($this->meeting->recap ? true : $this->meeting->record) ->setAutoStartRecording($this->meeting->room->auto_start_recording) ->setLogoutURL(url('rooms/'.$this->meeting->room->id)) ->setMeetingEndedURL($this->getCallbackUrl()) @@ -106,6 +108,15 @@ public function start(): ?CreateMeetingResponse $meetingParams->addMeta('bbb-origin', 'PILOS'); $meetingParams->addMeta('pilos-sub-spool-dir', config('recording.spool-sub-directory')); + // Opt in to a meeting summary, version 1 of the meta parameters read by the summary service + if ($this->meeting->recap) { + $recapPrefix = config('recap.meta_prefix'); + $meetingParams->addMeta($recapPrefix.'-v', '1'); + $meetingParams->addMeta($recapPrefix.'-enabled', 'true'); + $meetingParams->addMeta($recapPrefix.'-type', $this->meeting->room->roomType->recap_type); + $meetingParams->addMeta($recapPrefix.'-sink', $this->meeting->room->roomType->recap_sink); + } + // Add system default presentation, if exists $useSystemDefaultFileAsStart = false; if (app(BigBlueButtonSettings::class)->default_presentation) { @@ -201,6 +212,10 @@ public function start(): ?CreateMeetingResponse return null; } + // Internal meeting id, used as record id of the recording + $this->meeting->internal_meeting_id = $result->getInternalMeetingId(); + $this->meeting->save(); + return $result; } @@ -529,6 +544,11 @@ public function setEnd(): void RoomEnded::dispatch($this->meeting->room); + // Poll the meeting summary service for the result of this meeting + if ($this->meeting->recap && ! empty($this->meeting->internal_meeting_id) && RecapService::isConfigured()) { + PollMeetingSummary::dispatchAfterEnd($this->meeting); + } + // set end time of the attendance to the end time of the meeting // for all users that have been present to the end foreach ($this->meeting->attendees()->whereNull('leave')->get() as $attendee) { @@ -708,6 +728,9 @@ public function getJoinUrl(JoinMeetingRequest|StartMeetingRequest $request): str // If meeting has recording enabled, add parameter to allow recording of own video if ($this->meeting->record) { $joinMeetingParams->addUserData('bbb_record_video', $request->consent_record_video); + } elseif ($this->meeting->recap) { + // Meeting summary without recording, camera video is never recorded + $joinMeetingParams->addUserData('bbb_record_video', false); } // If a custom style file is set, pass url to bbb html5 client diff --git a/app/Services/RecapService.php b/app/Services/RecapService.php new file mode 100644 index 0000000000..21afa4de4a --- /dev/null +++ b/app/Services/RecapService.php @@ -0,0 +1,105 @@ +connectTimeout(config('recap.server_connect_timeout')) + ->baseUrl(config('recap.service_url')) + ->withToken(config('recap.frontend_token')) + ->acceptJson(); + } + + /** + * Register the owner of a meeting with the service + * + * @throws ConnectionException + */ + public function register(Meeting $meeting, User $owner): Response + { + return $this->getHttpClient()->put('api/v1/registrations/'.rawurlencode($meeting->internal_meeting_id), [ + 'schema_version' => self::SCHEMA_VERSION, + 'meeting_id' => $meeting->id, + 'record_id' => $meeting->internal_meeting_id, + 'owner' => [ + 'sub' => $owner->oidc_sub, + 'email' => $owner->email, + ], + ]); + } + + /** + * Cancel the registration of a meeting + * + * @throws ConnectionException + */ + public function cancel(string $recordId): Response + { + return $this->getHttpClient()->delete('api/v1/registrations/'.rawurlencode($recordId)); + } + + /** + * Get the registration of a meeting, including the result of its job + * + * @throws ConnectionException + */ + public function getRegistration(string $recordId): Response + { + return $this->getHttpClient()->get('api/v1/registrations/'.rawurlencode($recordId)); + } + + /** + * Get the summary text (Markdown) that the service holds for pickup + * + * @throws ConnectionException + */ + public function getSummary(string $recordId): Response + { + return $this->getHttpClient() + ->accept('text/markdown') + ->get('api/v1/registrations/'.rawurlencode($recordId).'/summary'); + } + + /** + * Confirm the pickup of the summary text, the service then deletes it + * + * @throws ConnectionException + */ + public function confirmSummary(string $recordId): Response + { + return $this->getHttpClient()->delete('api/v1/registrations/'.rawurlencode($recordId).'/summary'); + } + + /** + * Indicates whether a failed request should be retried (rate limit or server error) + */ + public static function isRetryable(Response $response): bool + { + return $response->tooManyRequests() || $response->serverError(); + } +} diff --git a/app/Services/RoomService.php b/app/Services/RoomService.php index 143100d8ae..e8ac2bc6f3 100644 --- a/app/Services/RoomService.php +++ b/app/Services/RoomService.php @@ -6,6 +6,7 @@ use App\Enums\CustomStatusCodes; use App\Events\RoomStarted; +use App\Jobs\RegisterRecapMeeting; use App\Models\Meeting; use App\Models\Room; use App\Prometheus\Counter; @@ -79,6 +80,7 @@ public function start(): MeetingService $meeting = new Meeting; $meeting->record_attendance = $this->room->getRoomSetting('record_attendance'); $meeting->record = config('recording.enabled') && $this->room->getRoomSetting('record'); + $meeting->recap = $this->isRecapActive(); $meeting->server()->associate($server); $meeting->room()->associate($this->room); $meeting->save(); @@ -115,6 +117,11 @@ public function start(): MeetingService $meeting->save(); + // Register the room owner with the meeting summary service + if ($meeting->recap) { + RegisterRecapMeeting::dispatch($meeting, $this->room->owner); + } + // Change latest meeting or the room to newly created meeting $this->room->latestMeeting()->associate($meeting); @@ -138,6 +145,20 @@ public function start(): MeetingService return $meetingService; } + /** + * Indicates whether a new meeting of this room should create a meeting summary (recap). + * + * Requires the feature, an owner with OIDC subject, the effective room setting recap, + * and a meeting type and sink on the room type. The recording setting of the room is not required. + */ + public function isRecapActive(): bool + { + return $this->room->isRecapAvailable() + && $this->room->getRoomSetting('recap') + && ! empty($this->room->roomType->recap_type) + && ! empty($this->room->roomType->recap_sink); + } + /** * Join a running meeting */ diff --git a/config/recap.php b/config/recap.php new file mode 100644 index 0000000000..e54cb52a39 --- /dev/null +++ b/config/recap.php @@ -0,0 +1,16 @@ + (bool) env('RECAP_ENABLED', false) && ! empty($serviceUrl) && ! empty($frontendToken), + 'meta_prefix' => env('RECAP_META_PREFIX', 'recap'), + 'service_url' => $serviceUrl, + 'frontend_token' => $frontendToken, + 'server_timeout' => (int) env('RECAP_SERVER_TIMEOUT', 10), + 'server_connect_timeout' => (int) env('RECAP_SERVER_CONNECT_TIMEOUT', 20), +]; diff --git a/database/factories/MeetingSummaryFactory.php b/database/factories/MeetingSummaryFactory.php new file mode 100644 index 0000000000..52186545c6 --- /dev/null +++ b/database/factories/MeetingSummaryFactory.php @@ -0,0 +1,43 @@ + + */ +class MeetingSummaryFactory extends Factory +{ + protected $model = MeetingSummary::class; + + public function definition(): array + { + return [ + 'meeting_id' => Meeting::factory(), + 'room_id' => fn (array $attributes) => Meeting::find($attributes['meeting_id'])->room_id, + 'access' => RecordingAccess::OWNER, + 'start' => fn (array $attributes) => Meeting::find($attributes['meeting_id'])->start, + 'end' => fn (array $attributes) => Meeting::find($attributes['meeting_id'])->end, + 'document_url' => null, + 'content' => "# Meeting summary\n\nFixture summary text.\n", + 'delivered_at' => now(), + ]; + } + + /** + * Summary delivered as a link to a document in the sink + */ + public function document(): static + { + return $this->state(fn () => [ + 'document_url' => 'https://docs.recap.test/docs/'.$this->faker->uuid().'/', + 'content' => null, + ]); + } +} diff --git a/database/migrations/2026_11_12_000001_add_recap_to_room_types_table.php b/database/migrations/2026_11_12_000001_add_recap_to_room_types_table.php new file mode 100644 index 0000000000..d67711fa97 --- /dev/null +++ b/database/migrations/2026_11_12_000001_add_recap_to_room_types_table.php @@ -0,0 +1,33 @@ +boolean('recap_default')->default(false); + $table->boolean('recap_enforced')->default(false); + $table->string('recap_type', 63)->nullable(); + $table->string('recap_sink', 63)->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('room_types', function (Blueprint $table) { + $table->dropColumn(['recap_default', 'recap_enforced', 'recap_type', 'recap_sink']); + }); + } +}; diff --git a/database/migrations/2026_11_12_000002_add_recap_to_rooms_table.php b/database/migrations/2026_11_12_000002_add_recap_to_rooms_table.php new file mode 100644 index 0000000000..63744e06a4 --- /dev/null +++ b/database/migrations/2026_11_12_000002_add_recap_to_rooms_table.php @@ -0,0 +1,30 @@ +boolean('recap')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('rooms', function (Blueprint $table) { + $table->dropColumn('recap'); + }); + } +}; diff --git a/database/migrations/2026_11_12_000003_add_recap_to_meetings_table.php b/database/migrations/2026_11_12_000003_add_recap_to_meetings_table.php new file mode 100644 index 0000000000..a6372feb02 --- /dev/null +++ b/database/migrations/2026_11_12_000003_add_recap_to_meetings_table.php @@ -0,0 +1,31 @@ +boolean('recap')->default(false); + $table->string('internal_meeting_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('meetings', function (Blueprint $table) { + $table->dropColumn(['recap', 'internal_meeting_id']); + }); + } +}; diff --git a/database/migrations/2026_11_12_000004_create_meeting_summaries_table.php b/database/migrations/2026_11_12_000004_create_meeting_summaries_table.php new file mode 100644 index 0000000000..8c2b4fc3ab --- /dev/null +++ b/database/migrations/2026_11_12_000004_create_meeting_summaries_table.php @@ -0,0 +1,40 @@ +id(); + $table->string('room_id'); + $table->foreign('room_id')->references('id')->on('rooms')->onDelete('cascade'); + $table->string('meeting_id')->unique(); + $table->foreign('meeting_id')->references('id')->on('meetings')->onDelete('cascade'); + $table->tinyInteger('access')->default(RecordingAccess::OWNER); + $table->dateTime('start'); + $table->dateTime('end')->nullable(); + $table->text('document_url')->nullable(); + $table->mediumText('content')->nullable(); + $table->dateTime('delivered_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('meeting_summaries'); + } +}; diff --git a/lang/en/admin.php b/lang/en/admin.php index 73b9371aca..b146eee091 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -184,6 +184,13 @@ 'no_data' => 'No room types found!', 'no_data_filtered' => 'For the filter query no room types were found!', 'preview' => 'Preview', + 'recap' => [ + 'enforced_hint' => 'Meeting summaries can only be enforced off.', + 'sink' => 'Summary destination', + 'sink_description' => 'Name of the destination the summaries are delivered to. Lowercase letters, digits and hyphens.', + 'type' => 'Meeting type', + 'type_description' => 'Name of the meeting type that selects the summary template. Lowercase letters, digits and hyphens.', + ], 'restrict' => 'Restrict usage', 'restrict_description' => 'The usage of this room type and the corresponding servers will be restricted to the selected roles.', 'search_aria' => 'Search room types', diff --git a/lang/en/app.php b/lang/en/app.php index 7a07b98fb3..adcfbbc672 100644 --- a/lang/en/app.php +++ b/lang/en/app.php @@ -118,6 +118,7 @@ ], 'model' => [ 'meeting' => 'Meeting', + 'meeting_summary' => 'Meeting summary', 'recording' => 'Recording', 'recording_format' => 'Recording format', 'role' => 'Role', diff --git a/lang/en/rooms.php b/lang/en/rooms.php index 0208a802f3..45838f6c50 100644 --- a/lang/en/rooms.php +++ b/lang/en/rooms.php @@ -226,6 +226,39 @@ 'sort_descending' => 'Sort history descending', 'title' => 'History', ], + 'meeting_summaries' => [ + 'delete' => 'Delete meeting summary', + 'delete_aria' => 'Delete meeting summary of :date', + 'document_hint' => 'The document is stored in the account of the room owner. You can only open it if the owner has shared it with you.', + 'document_hint_owner' => 'The document opens in your account. Other people can only open it if you share it with them.', + 'download' => 'Download meeting summary', + 'download_aria' => 'Download the meeting summary of :date as a Markdown file', + 'edit' => 'Change access', + 'edit_aria' => 'Change access to the meeting summary of :date', + 'filter_aria' => 'Filter meeting summaries', + 'gone' => 'The meeting summary is no longer available.', + 'modals' => [ + 'delete' => [ + 'confirm' => 'Should the meeting summary be irrevocably deleted?', + 'title' => 'Delete meeting summary', + ], + 'edit' => [ + 'title' => 'Change access to the meeting summary', + ], + ], + 'nodata' => 'No meeting summaries available', + 'open_document' => 'Open document', + 'open_document_aria' => 'Open the meeting summary document of :date in a new tab', + 'reload_aria' => 'Reload meeting summaries', + 'retention_period' => [ + 'days' => 'The meeting summaries are stored for :days days.', + 'title' => 'Retention period', + 'unlimited' => 'The meeting summaries are stored indefinitely.', + ], + 'sort_ascending' => 'Sort meeting summaries ascending', + 'sort_descending' => 'Sort meeting summaries descending', + 'title' => 'Meeting summaries', + ], 'members' => [ 'add_single_user' => 'Add single user', 'add_user' => 'Add user', @@ -362,11 +395,15 @@ 'title' => 'Phone number and pin', ], 'placeholder_name' => 'John Doe', + 'recap_accept' => 'I consent to the transcription and AI summary of the audio.', + 'recap_info' => 'An AI may transcribe and summarize the audio of this meeting. No recording is published.', 'recording_accept' => 'I consent to the recording.', 'recording_attendance_accept' => 'I consent to the attendance logging.', 'recording_attendance_info' => 'The attendance in this room is logged.', 'recording_hint' => 'If you don\'t want your voice recorded, make sure your microphone is muted. Use the chat to participate instead.', 'recording_info' => 'This room may be recorded.', + 'recording_recap_accept' => 'I consent to the recording and to the transcription and AI summary of the audio.', + 'recording_recap_info' => 'This room may be recorded, and an AI may transcribe and summarize the audio.', 'recording_video_accept' => '(Optional) My video image may be recorded.', 'recordings' => [ 'access' => 'Access', @@ -499,8 +536,13 @@ ], 'title' => 'Participants', ], + 'recap' => [ + 'title' => 'Meeting summary (AI)', + ], 'recordings' => [ 'auto_start_recording' => 'Automatic recording start', + 'recap' => 'Create a meeting summary (AI)', + 'recap_unavailable' => 'Available after you have logged in once via OpenID Connect.', 'record_attendance' => 'Log attendance of participants', 'record_video_conference' => 'Record video conference', 'title' => 'Recordings', diff --git a/lang/en/validation.php b/lang/en/validation.php index b1dcfd940f..4ac90eebef 100644 --- a/lang/en/validation.php +++ b/lang/en/validation.php @@ -48,6 +48,7 @@ 'bbb_style' => 'CSS style file', 'city' => 'City', 'color' => 'Color', + 'consent_recap' => 'Consent to the transcription and AI summary of the audio', 'consent_record' => 'Consent to the recording of the video conference', 'consent_record_attendance' => 'Consent to attendance logging', 'consent_record_video' => 'Consent to record own video', @@ -118,6 +119,9 @@ 'per_page' => 'Entries per page', 'permissions' => 'Permissions', 'phone' => 'Phone', + 'recap' => 'Meeting summary', + 'recap_sink' => 'Summary destination', + 'recap_type' => 'Summary meeting type', 'recording_attendance_retention_period' => 'Retention period of the attendance logging in days', 'recording_meeting_usage_enabled' => 'Record utilisation of meetings', 'recording_meeting_usage_retention_period' => 'Retention period of the meeting utilisation in days', @@ -202,6 +206,9 @@ ], 'required' => 'The message banner settings are missing!', ], + 'consent_recap' => [ + 'accepted' => 'Consent to the transcription and AI summary of the audio must be given.', + ], 'consent_record' => [ 'accepted' => 'Consent to the recording of the video conference must be given.', ], @@ -219,6 +226,15 @@ 'in' => 'The selected language isn\'t supported by the server.', ], 'password' => 'The password must contain at least one character from each of the following four categories: Uppercase letter (A - Z), lowercase letter (a - z), number (0 - 9), non-alphanumeric character (for example: !, $, #, or %).', + 'recap_default' => [ + 'declined_if' => 'Meeting summaries can only be enforced off, not on.', + ], + 'recap_sink' => [ + 'regex' => 'The :attribute may only contain lowercase letters, digits and hyphens, must start with a letter and be at most 63 characters long.', + ], + 'recap_type' => [ + 'regex' => 'The :attribute may only contain lowercase letters, digits and hyphens, must start with a letter and be at most 63 characters long.', + ], 'replacement_room_type' => [ 'exists' => 'Replacement room type invalid! A replacement room type is required because rooms are still assigned to this room type.', 'not_in' => 'Replacement room type invalid! A replacement room type is required because rooms are still assigned to this room type.', @@ -274,6 +290,7 @@ 'custom_parameter_invalid' => 'The :parameter parameter value is invalid.', 'custom_parameter_missing' => 'The :parameter parameter is missing a value.', 'custom_parameter_not_found' => 'The :parameter parameter does not exist.', + 'custom_parameter_reserved' => 'The :parameter parameter is reserved and cannot be set here.', 'date' => 'The :attribute is not a valid date.', 'date_equals' => 'The :attribute must be a date equal to :date.', 'date_format' => 'The :attribute does not match the format :format.', diff --git a/routes/api.php b/routes/api.php index fd41990baf..207df89b0a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -10,6 +10,7 @@ use App\Http\Controllers\api\v1\auth\VerificationController; use App\Http\Controllers\api\v1\LocaleController; use App\Http\Controllers\api\v1\MeetingController; +use App\Http\Controllers\api\v1\MeetingSummaryController; use App\Http\Controllers\api\v1\PermissionController; use App\Http\Controllers\api\v1\RecordingController; use App\Http\Controllers\api\v1\RoleController; @@ -112,6 +113,12 @@ Route::delete('rooms/{room}/recordings/{recording}', [RecordingController::class, 'destroy'])->name('rooms.recordings.destroy'); }); + // Meeting summary operations + Route::middleware('can:manageMeetingSummaries,room')->group(function () { + Route::put('rooms/{room}/meetingSummaries/{meetingSummary}', [MeetingSummaryController::class, 'update'])->name('rooms.meetingSummaries.update'); + Route::delete('rooms/{room}/meetingSummaries/{meetingSummary}', [MeetingSummaryController::class, 'destroy'])->name('rooms.meetingSummaries.destroy'); + }); + // Streaming operations Route::middleware('can:viewStreaming,room')->group(function () { Route::get('rooms/{room}/streaming/config', [RoomStreamingController::class, 'getConfig'])->name('rooms.streaming.config.get'); @@ -193,6 +200,8 @@ Route::post('rooms/{room}/join', [RoomController::class, 'join'])->name('rooms.join'); Route::get('rooms/{room}/files', [RoomFileController::class, 'index'])->name('rooms.files.get'); Route::get('rooms/{room}/recordings', [RecordingController::class, 'index'])->name('rooms.recordings.index')->middleware('enable_if_config:recording.enabled'); + Route::get('rooms/{room}/meetingSummaries', [MeetingSummaryController::class, 'index'])->name('rooms.meetingSummaries.index'); + Route::get('rooms/{room}/meetingSummaries/{meetingSummary}/download', [MeetingSummaryController::class, 'download'])->name('rooms.meetingSummaries.download'); }); diff --git a/tests/Backend/Feature/api/v1/MeetingSummaryTest.php b/tests/Backend/Feature/api/v1/MeetingSummaryTest.php new file mode 100644 index 0000000000..5ecaeadec3 --- /dev/null +++ b/tests/Backend/Feature/api/v1/MeetingSummaryTest.php @@ -0,0 +1,367 @@ + + */ + protected array $summaries; + + protected User $participant; + + protected User $moderator; + + protected User $coOwner; + + protected User $otherUser; + + protected function setUp(): void + { + parent::setUp(); + + $this->seed(RolesAndPermissionsSeeder::class); + + $this->room = Room::factory()->create(['allow_guests' => true, 'access_code' => null]); + + $this->participant = User::factory()->create(); + $this->moderator = User::factory()->create(); + $this->coOwner = User::factory()->create(); + $this->otherUser = User::factory()->create(); + $this->room->members()->attach($this->participant, ['role' => RoomUserRole::USER]); + $this->room->members()->attach($this->moderator, ['role' => RoomUserRole::MODERATOR]); + $this->room->members()->attach($this->coOwner, ['role' => RoomUserRole::CO_OWNER]); + + $this->summaries = []; + foreach (['everyone' => RecordingAccess::EVERYONE, 'participant' => RecordingAccess::PARTICIPANT, 'moderator' => RecordingAccess::MODERATOR, 'owner' => RecordingAccess::OWNER] as $name => $access) { + $this->summaries[$name] = MeetingSummary::factory()->create([ + 'meeting_id' => Meeting::factory()->create(['room_id' => $this->room->id])->id, + 'access' => $access, + ]); + } + } + + /** + * Visible summaries per user, keyed by the access names of setUp() + * + * @return array}> + */ + public static function visibilityProvider(): array + { + return [ + 'guest' => ['guest', ['everyone']], + 'other user' => ['otherUser', ['everyone']], + 'participant' => ['participant', ['everyone', 'participant']], + 'moderator' => ['moderator', ['everyone', 'participant', 'moderator']], + 'co-owner' => ['coOwner', ['everyone', 'participant', 'moderator', 'owner']], + 'owner' => ['owner', ['everyone', 'participant', 'moderator', 'owner']], + ]; + } + + private function actAs(string $user): void + { + match ($user) { + 'guest' => Auth::logout(), + 'owner' => $this->actingAs($this->room->owner), + default => $this->actingAs($this->{$user}), + }; + } + + /** + * @param list $visible + */ + #[DataProvider('visibilityProvider')] + public function test_index_access(string $user, array $visible) + { + $this->actAs($user); + + $response = $this->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room])) + ->assertOk() + ->assertJsonPath('meta.total_no_filter', count($visible)); + + $expectedIds = collect($visible)->map(fn ($name) => $this->summaries[$name]->id)->sort()->values()->all(); + $this->assertSame($expectedIds, collect($response->json('data'))->pluck('id')->sort()->values()->all()); + + // The list never contains the summary text + foreach ($response->json('data') as $item) { + $this->assertArrayNotHasKey('content', $item); + $this->assertSame('content', $item['type']); + $this->assertSame('MeetingSummary', $item['model_name']); + } + } + + /** + * @param list $visible + */ + #[DataProvider('visibilityProvider')] + public function test_download_access(string $user, array $visible) + { + $this->actAs($user); + + foreach ($this->summaries as $name => $summary) { + $response = $this->get(route('api.v1.rooms.meetingSummaries.download', ['room' => $this->room, 'meetingSummary' => $summary])); + if (in_array($name, $visible)) { + $response->assertOk(); + $this->assertSame($summary->content, $response->getContent()); + } else { + $response->assertForbidden(); + } + } + } + + /** + * Summary of the given room, visible to everyone, started 2026-11-12 08:30 UTC + */ + private function createDownloadSummary(Room $room): MeetingSummary + { + return MeetingSummary::factory()->create([ + 'meeting_id' => Meeting::factory()->create(['room_id' => $room->id])->id, + 'access' => RecordingAccess::EVERYONE, + 'start' => '2026-11-12 08:30:00', + 'content' => "# Summary\n\n- Ada Testperson: täglich prüfen\n", + ]); + } + + public function test_download_response() + { + $room = Room::factory()->create(['id' => 'abc-def-123', 'allow_guests' => true, 'access_code' => null]); + $summary = $this->createDownloadSummary($room); + + // File name date in the timezone of the user + $room->owner->update(['timezone' => 'Europe/Berlin']); + $response = $this->actingAs($room->owner) + ->get(route('api.v1.rooms.meetingSummaries.download', ['room' => $room, 'meetingSummary' => $summary])) + ->assertOk() + ->assertHeader('Content-Type', 'text/markdown; charset=utf-8') + ->assertHeader('Content-Disposition', 'attachment; filename=meeting-summary-abc-def-123-2026-11-12-0930.md') + ->assertHeader('Content-Security-Policy', "default-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'") + ->assertHeader('X-Content-Type-Options', 'nosniff'); + $this->assertSame("# Summary\n\n- Ada Testperson: täglich prüfen\n", $response->getContent()); + + // Guests get the default timezone of the application + Auth::logout(); + $this->generalSettings->default_timezone = 'America/New_York'; + $this->generalSettings->save(); + $this->get(route('api.v1.rooms.meetingSummaries.download', ['room' => $room, 'meetingSummary' => $summary])) + ->assertOk() + ->assertHeader('Content-Disposition', 'attachment; filename=meeting-summary-abc-def-123-2026-11-12-0330.md'); + } + + public function test_download_file_name_is_safe() + { + $room = Room::factory()->create(['id' => 'a"b c;ü\\d', 'allow_guests' => true, 'access_code' => null]); + $summary = $this->createDownloadSummary($room); + + $this->actingAs($room->owner) + ->get(route('api.v1.rooms.meetingSummaries.download', ['room' => $room, 'meetingSummary' => $summary])) + ->assertOk() + ->assertHeader('Content-Disposition', 'attachment; filename=meeting-summary-a-b-c----d-2026-11-12-0830.md'); + } + + public function test_view_all_permission() + { + $role = Role::factory()->create(); + $role->permissions()->attach(Permission::where('name', 'rooms.viewAll')->first()); + $this->otherUser->roles()->attach($role); + + $this->actingAs($this->otherUser) + ->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room])) + ->assertOk() + ->assertJsonCount(4, 'data'); + + $this->get(route('api.v1.rooms.meetingSummaries.download', ['room' => $this->room, 'meetingSummary' => $this->summaries['owner']])) + ->assertOk(); + } + + public function test_index_filter_and_sort() + { + $this->summaries['everyone']->update(['start' => now()->subDays(3)]); + $this->summaries['participant']->update(['start' => now()->subDays(2)]); + $this->summaries['moderator']->update(['start' => now()->subDays(1)]); + $this->summaries['owner']->update(['start' => now()]); + + $this->actingAs($this->room->owner); + + // Newest first by default + $this->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room])) + ->assertOk() + ->assertJsonPath('data.0.id', $this->summaries['owner']->id) + ->assertJsonPath('data.3.id', $this->summaries['everyone']->id); + + $this->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room, 'sort_direction' => 'asc'])) + ->assertOk() + ->assertJsonPath('data.0.id', $this->summaries['everyone']->id); + + $this->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room, 'filter' => 'moderator_access'])) + ->assertOk() + ->assertJsonCount(1, 'data') + ->assertJsonPath('data.0.id', $this->summaries['moderator']->id) + ->assertJsonPath('meta.total_no_filter', 4); + + $this->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room, 'filter' => 'invalid'])) + ->assertUnprocessable(); + } + + public function test_document_summary() + { + $summary = MeetingSummary::factory()->document()->create([ + 'meeting_id' => Meeting::factory()->create(['room_id' => $this->room->id])->id, + 'access' => RecordingAccess::EVERYONE, + ]); + + $response = $this->getJson(route('api.v1.rooms.meetingSummaries.index', ['room' => $this->room])) + ->assertOk(); + $item = collect($response->json('data'))->firstWhere('id', $summary->id); + $this->assertSame('document', $item['type']); + $this->assertSame($summary->document_url, $item['document_url']); + + // Nothing to download for a document link + $this->get(route('api.v1.rooms.meetingSummaries.download', ['room' => $this->room, 'meetingSummary' => $summary])) + ->assertNotFound(); + } + + public function test_download_summary_of_other_room() + { + $otherSummary = MeetingSummary::factory()->create(['access' => RecordingAccess::EVERYONE]); + + $this->actingAs($this->room->owner) + ->getJson(route('api.v1.rooms.meetingSummaries.download', ['room' => $this->room, 'meetingSummary' => $otherSummary])) + ->assertNotFound() + ->assertJson(['message' => 'model_not_found', 'model' => 'meeting_summary']); + } + + /** + * @return array + */ + public static function manageProvider(): array + { + return [ + 'guest' => ['guest', 401], + 'other user' => ['otherUser', 403], + 'participant' => ['participant', 403], + 'moderator' => ['moderator', 403], + 'co-owner' => ['coOwner', 200], + 'owner' => ['owner', 200], + ]; + } + + #[DataProvider('manageProvider')] + public function test_update_access(string $user, int $status) + { + $summary = $this->summaries['owner']; + $this->actAs($user); + + $response = $this->putJson(route('api.v1.rooms.meetingSummaries.update', ['room' => $this->room, 'meetingSummary' => $summary]), ['access' => RecordingAccess::PARTICIPANT->value]) + ->assertStatus($status); + + $summary->refresh(); + if ($status === 200) { + $response->assertJsonPath('data.access', RecordingAccess::PARTICIPANT->value); + $this->assertSame(RecordingAccess::PARTICIPANT, $summary->access); + } else { + $this->assertSame(RecordingAccess::OWNER, $summary->access); + } + } + + public function test_update_invalid_data() + { + $summary = $this->summaries['owner']; + $this->actingAs($this->room->owner); + + $this->putJson(route('api.v1.rooms.meetingSummaries.update', ['room' => $this->room, 'meetingSummary' => $summary]), ['access' => 7]) + ->assertJsonValidationErrors(['access']); + $this->putJson(route('api.v1.rooms.meetingSummaries.update', ['room' => $this->room, 'meetingSummary' => $summary]), []) + ->assertJsonValidationErrors(['access']); + + // Summary of another room + $otherSummary = MeetingSummary::factory()->create(); + $this->putJson(route('api.v1.rooms.meetingSummaries.update', ['room' => $this->room, 'meetingSummary' => $otherSummary]), ['access' => RecordingAccess::EVERYONE->value]) + ->assertNotFound(); + } + + #[DataProvider('manageProvider')] + public function test_delete(string $user, int $status) + { + $summary = $this->summaries['everyone']; + $this->actAs($user); + + $this->deleteJson(route('api.v1.rooms.meetingSummaries.destroy', ['room' => $this->room, 'meetingSummary' => $summary])) + ->assertStatus($status === 200 ? 204 : $status); + + if ($status === 200) { + $this->assertModelMissing($summary); + + $this->deleteJson(route('api.v1.rooms.meetingSummaries.destroy', ['room' => $this->room, 'meetingSummary' => $summary])) + ->assertNotFound() + ->assertJson(['message' => 'model_not_found', 'model' => 'meeting_summary']); + } else { + $this->assertModelExists($summary); + } + } + + public function test_manage_permission() + { + $role = Role::factory()->create(); + $role->permissions()->attach(Permission::where('name', 'rooms.manage')->first()); + $this->otherUser->roles()->attach($role); + + $this->actingAs($this->otherUser) + ->putJson(route('api.v1.rooms.meetingSummaries.update', ['room' => $this->room, 'meetingSummary' => $this->summaries['owner']]), ['access' => RecordingAccess::EVERYONE->value]) + ->assertOk(); + $this->deleteJson(route('api.v1.rooms.meetingSummaries.destroy', ['room' => $this->room, 'meetingSummary' => $this->summaries['owner']])) + ->assertNoContent(); + } + + public function test_delete_with_room() + { + $otherSummary = MeetingSummary::factory()->create(); + + $this->actingAs($this->room->owner) + ->deleteJson(route('api.v1.rooms.destroy', ['room' => $this->room])) + ->assertNoContent(); + + foreach ($this->summaries as $summary) { + $this->assertModelMissing($summary); + } + $this->assertModelExists($otherSummary); + } + + public function test_room_shows_whether_it_has_summaries() + { + $this->getJson(route('api.v1.rooms.show', ['room' => $this->room])) + ->assertOk() + ->assertJsonPath('data.has_meeting_summaries', true); + + $this->room->meetingSummaries()->delete(); + + $this->getJson(route('api.v1.rooms.show', ['room' => $this->room])) + ->assertOk() + ->assertJsonPath('data.has_meeting_summaries', false); + } +} diff --git a/tests/Backend/Feature/api/v1/Room/RoomRecapStartTest.php b/tests/Backend/Feature/api/v1/Room/RoomRecapStartTest.php new file mode 100644 index 0000000000..317f53aad9 --- /dev/null +++ b/tests/Backend/Feature/api/v1/Room/RoomRecapStartTest.php @@ -0,0 +1,447 @@ +seed(RolesAndPermissionsSeeder::class); + + config([ + 'recap.enabled' => true, + 'recap.meta_prefix' => 'recap', + 'recap.service_url' => self::SERVICE_URL, + 'recap.frontend_token' => self::FRONTEND_TOKEN, + ]); + + $roomType = RoomType::factory()->create([ + 'recap_type' => 'meeting-summary', + 'recap_sink' => 'docs-main', + ]); + $owner = User::factory()->create([ + 'authenticator' => 'oidc', + 'oidc_sub' => self::OWNER_SUB, + 'email' => self::OWNER_EMAIL, + ]); + $this->room = Room::factory()->create([ + 'room_type_id' => $roomType->id, + 'user_id' => $owner->id, + 'expert_mode' => true, + 'record' => true, + 'record_attendance' => false, + 'recap' => true, + ]); + + $server = Server::factory()->create(); + $roomType->serverPool->servers()->attach($server); + $this->bbbFaker = new BigBlueButtonServerFaker($server->base_url, $server->secret); + } + + /** + * Start the room as owner and return the query parameters of the BBB create call + */ + private function startRoom(): array + { + $this->bbbFaker->addCreateMeetingRequest(); + $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.start', ['room' => $this->room]), [ + 'consent_record_attendance' => false, + 'consent_record' => true, + 'consent_record_video' => false, + ])->assertSuccessful(); + + return $this->bbbFaker->getRequest(0)->data(); + } + + private function recapMetaKeys(array $createParameters): array + { + return array_values(array_filter(array_keys($createParameters), fn (string $key) => str_starts_with(strtolower($key), 'meta_recap'))); + } + + public function test_start_with_recap() + { + Queue::fake(); + + $createParameters = $this->startRoom(); + + $this->assertEqualsCanonicalizing(self::RECAP_META_KEYS, $this->recapMetaKeys($createParameters)); + $this->assertEquals('1', $createParameters['meta_recap-v']); + $this->assertEquals('true', $createParameters['meta_recap-enabled']); + $this->assertEquals('meeting-summary', $createParameters['meta_recap-type']); + $this->assertEquals('docs-main', $createParameters['meta_recap-sink']); + $this->assertEquals('PILOS', $createParameters['meta_bbb-origin']); + + $meeting = $this->room->refresh()->latestMeeting; + $this->assertTrue($meeting->recap); + $this->assertEquals(self::INTERNAL_MEETING_ID, $meeting->internal_meeting_id); + $this->assertEquals($meeting->id, $createParameters['meetingID']); + + Queue::assertPushed(RegisterRecapMeeting::class, 1); + Queue::assertPushed(RegisterRecapMeeting::class, fn (RegisterRecapMeeting $job) => $job->meeting->is($meeting) && $job->owner->is($this->room->owner)); + } + + public function test_start_with_configured_meta_prefix() + { + Queue::fake(); + config(['recap.meta_prefix' => 'summary']); + + $createParameters = $this->startRoom(); + + $this->assertEquals([], $this->recapMetaKeys($createParameters)); + $this->assertEquals('1', $createParameters['meta_summary-v']); + $this->assertEquals('true', $createParameters['meta_summary-enabled']); + $this->assertEquals('meeting-summary', $createParameters['meta_summary-type']); + $this->assertEquals('docs-main', $createParameters['meta_summary-sink']); + } + + /** + * The meeting end reaches PILOS through the signed meetingEndedURL; only a valid callback ends the meeting and + * starts polling for the summary, an unsigned callback (old salt URL) is rejected and the server poll ends the meeting later + */ + public function test_end_callback_dispatches_summary_poll() + { + Queue::fake(); + + $createParameters = $this->startRoom(); + $meeting = $this->room->refresh()->latestMeeting; + + $this->assertArrayNotHasKey('meta_endCallbackUrl', $createParameters); + $callbackUrl = $createParameters['meetingEndedURL']; + $this->assertStringContainsString('signature=', $callbackUrl); + + $this->get(route('api.v1.meetings.endcallback', ['meeting' => $meeting]))->assertUnauthorized(); + $this->assertNull($meeting->fresh()->end); + Queue::assertNotPushed(PollMeetingSummary::class); + + // BBB may append parameters to the callback URL + $this->get($callbackUrl.'&recordingmarks=true&meetingID='.$meeting->id)->assertSuccessful(); + $this->assertNotNull($meeting->fresh()->end); + Queue::assertPushed(PollMeetingSummary::class, 1); + Queue::assertPushed(PollMeetingSummary::class, fn (PollMeetingSummary $job) => $job->meeting->is($meeting)); + } + + public function test_start_registers_owner() + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(['status' => 'registered'], 201)]); + + $this->startRoom(); + + $meeting = $this->room->refresh()->latestMeeting; + Http::assertSent(fn (Request $request) => $request->method() === 'PUT' + && $request->url() === self::SERVICE_URL.'/api/v1/registrations/'.self::INTERNAL_MEETING_ID + && $request->hasHeader('Authorization', 'Bearer '.self::FRONTEND_TOKEN) + && $request->data() === [ + 'schema_version' => '1.0.0', + 'meeting_id' => $meeting->id, + 'record_id' => self::INTERNAL_MEETING_ID, + 'owner' => [ + 'sub' => self::OWNER_SUB, + 'email' => self::OWNER_EMAIL, + ], + ]); + } + + public static function recapConditionProvider(): array + { + return [ + 'feature disabled' => ['feature_disabled'], + 'invalid meta prefix' => ['invalid_meta_prefix'], + 'room setting off' => ['room_setting_off'], + 'room setting enforced off by room type' => ['enforced_off'], + 'owner without OIDC subject' => ['owner_without_sub'], + 'room type without meeting type' => ['no_recap_type'], + 'room type without sink' => ['no_recap_sink'], + ]; + } + + /** + * Each condition alone prevents the meeting summary. The stored room value stays true in all cases except + * 'room_setting_off', like a room type default copied into the room at creation. + */ + #[DataProvider('recapConditionProvider')] + public function test_start_without_recap(string $condition) + { + Queue::fake(); + + match ($condition) { + 'feature_disabled' => config(['recap.enabled' => false]), + 'invalid_meta_prefix' => config(['recap.meta_prefix' => 'Recap']), + 'room_setting_off' => $this->room->forceFill(['recap' => false])->save(), + 'enforced_off' => $this->room->roomType->forceFill(['recap_default' => false, 'recap_enforced' => true])->save(), + 'owner_without_sub' => $this->room->owner->forceFill(['oidc_sub' => null])->save(), + 'no_recap_type' => $this->room->roomType->forceFill(['recap_type' => null])->save(), + 'no_recap_sink' => $this->room->roomType->forceFill(['recap_sink' => null])->save(), + }; + + $createParameters = $this->startRoom(); + + $this->assertEquals([], $this->recapMetaKeys($createParameters)); + + $meeting = $this->room->refresh()->latestMeeting; + $this->assertFalse($meeting->recap); + $this->assertEquals(self::INTERNAL_MEETING_ID, $meeting->internal_meeting_id); + + Queue::assertNotPushed(RegisterRecapMeeting::class); + } + + public static function createParameterProvider(): array + { + $cases = []; + foreach ([true, false] as $recap) { + foreach ([true, false] as $record) { + foreach ([true, false] as $autoStart) { + $label = ($recap ? 'summary on' : 'summary off').', '.($record ? 'recording on' : 'recording off').', '.($autoStart ? 'auto start on' : 'auto start off'); + $cases[$label] = [$recap, $record, $autoStart]; + } + } + } + + return $cases; + } + + /** + * BBB records the meeting if the room asks for a recording or a meeting summary, + * the automatic recording start always follows the room + */ + #[DataProvider('createParameterProvider')] + public function test_start_record_parameters(bool $recap, bool $record, bool $autoStart) + { + Queue::fake(); + $this->room->forceFill(['recap' => $recap, 'record' => $record, 'auto_start_recording' => $autoStart])->save(); + + $createParameters = $this->startRoom(); + + $this->assertEquals($recap || $record ? 'true' : 'false', $createParameters['record']); + $this->assertEquals($autoStart ? 'true' : 'false', $createParameters['autoStartRecording']); + $this->assertEqualsCanonicalizing($recap ? self::RECAP_META_KEYS : [], $this->recapMetaKeys($createParameters)); + + // The meeting keeps the recording setting of the room + $meeting = $this->room->refresh()->latestMeeting; + $this->assertSame($record, $meeting->record); + $this->assertSame($recap, $meeting->recap); + } + + /** + * Fake response of the BBB getMeetingInfo call for a running meeting + */ + private function addRunningMeetingInfoRequest(): void + { + $this->bbbFaker->addRequest(fn (Request $request) => Http::response(' + + SUCCESS + test + '.$this->room->latestMeeting->id.' + '.self::INTERNAL_MEETING_ID.' + true + true + false + false + 0 + 0 + 0 + 0 + 0 + false + ')); + } + + /** + * Summary-only meeting: consent is required on start and join, camera video is never recorded + */ + public function test_start_and_join_summary_only() + { + Queue::fake(); + $this->room->forceFill(['record' => false])->save(); + + // Start requirements and consent + $this->actingAs($this->room->owner)->optionsJson(route('api.v1.rooms.start-requirements', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.features.recording', false) + ->assertJsonPath('data.features.recap', true); + + $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.start', ['room' => $this->room]), ['consent_record' => false]) + ->assertStatus(422) + ->assertJsonValidationErrors(['consent_record' => __('validation.custom.consent_recap.accepted')]) + ->assertJsonMissingValidationErrors(['consent_record_video']); + + $this->bbbFaker->addCreateMeetingRequest(); + $joinUrl = $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.start', ['room' => $this->room]), ['consent_record' => true, 'consent_record_video' => true]) + ->assertSuccessful() + ->json('url'); + $this->assertStringContainsString('userdata-bbb_record_video=false', $joinUrl); + + // Join requirements and consent + $this->room->refresh(); + $this->actingAs($this->room->owner)->optionsJson(route('api.v1.rooms.join-requirements', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.features.recording', false) + ->assertJsonPath('data.features.recap', true); + + $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.join', ['room' => $this->room])) + ->assertStatus(422) + ->assertJsonValidationErrors(['consent_record' => __('validation.required', ['attribute' => __('validation.attributes.consent_recap')])]) + ->assertJsonMissingValidationErrors(['consent_record_video']); + + $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.join', ['room' => $this->room]), ['consent_record' => false]) + ->assertStatus(422) + ->assertJsonValidationErrors(['consent_record' => __('validation.custom.consent_recap.accepted')]); + + $this->addRunningMeetingInfoRequest(); + $joinUrl = $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.join', ['room' => $this->room]), ['consent_record' => true, 'consent_record_video' => true]) + ->assertSuccessful() + ->json('url'); + $this->assertStringContainsString('userdata-bbb_record_video=false', $joinUrl); + } + + /** + * Meeting with recording and summary: the consent to record the own video is asked as for a recording + */ + public function test_join_recording_and_summary() + { + Queue::fake(); + + $this->startRoom(); + $this->room->refresh(); + + $this->actingAs($this->room->owner)->optionsJson(route('api.v1.rooms.join-requirements', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.features.recording', true) + ->assertJsonPath('data.features.recap', true); + + $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.join', ['room' => $this->room])) + ->assertStatus(422) + ->assertJsonValidationErrors([ + 'consent_record' => __('validation.required', ['attribute' => __('validation.attributes.consent_record')]), + 'consent_record_video', + ]); + + $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.join', ['room' => $this->room]), ['consent_record' => false, 'consent_record_video' => false]) + ->assertStatus(422) + ->assertJsonValidationErrors(['consent_record' => __('validation.custom.consent_record.accepted')]); + + $this->addRunningMeetingInfoRequest(); + $joinUrl = $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.join', ['room' => $this->room]), ['consent_record' => true, 'consent_record_video' => true]) + ->assertSuccessful() + ->json('url'); + $this->assertStringContainsString('userdata-bbb_record_video=true', $joinUrl); + } + + /** + * Without recording and summary no consent is needed and the video parameter is not passed + */ + public function test_start_without_recording_and_summary() + { + Queue::fake(); + $this->room->forceFill(['record' => false, 'recap' => false])->save(); + + $this->actingAs($this->room->owner)->optionsJson(route('api.v1.rooms.start-requirements', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.features.recording', false) + ->assertJsonPath('data.features.recap', false); + + $this->bbbFaker->addCreateMeetingRequest(); + $joinUrl = $this->actingAs($this->room->owner)->postJson(route('api.v1.rooms.start', ['room' => $this->room])) + ->assertSuccessful() + ->json('url'); + $this->assertStringNotContainsString('userdata-bbb_record_video', $joinUrl); + } + + public function test_room_deletion_cancels_registrations() + { + Queue::fake(); + + $eligible = Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => true, 'internal_meeting_id' => 'record-id-a-1695892370102']); + Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => true, 'internal_meeting_id' => 'record-id-b-1695892370103']); + Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => false, 'internal_meeting_id' => 'record-id-c-1695892370104']); + Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => true, 'internal_meeting_id' => null]); + Meeting::factory()->create(['recap' => true, 'internal_meeting_id' => 'record-id-other-room']); + + $this->actingAs($this->room->owner)->deleteJson(route('api.v1.rooms.destroy', ['room' => $this->room])) + ->assertNoContent(); + + $this->assertModelMissing($eligible); + + Queue::assertPushed(CancelRecapRegistration::class, 2); + Queue::assertPushed(CancelRecapRegistration::class, fn (CancelRecapRegistration $job) => $job->recordId === 'record-id-a-1695892370102'); + Queue::assertPushed(CancelRecapRegistration::class, fn (CancelRecapRegistration $job) => $job->recordId === 'record-id-b-1695892370103'); + } + + public function test_room_deletion_without_service_configuration() + { + Queue::fake(); + Log::swap(new LogFake); + config(['recap.frontend_token' => null]); + + Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => true, 'internal_meeting_id' => 'record-id-a-1695892370102']); + Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => true, 'internal_meeting_id' => 'record-id-b-1695892370103']); + + $this->actingAs($this->room->owner)->deleteJson(route('api.v1.rooms.destroy', ['room' => $this->room])) + ->assertNoContent(); + + Queue::assertNotPushed(CancelRecapRegistration::class); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'warning' + && $log->context['room'] === $this->room->getLogLabel() + && $log->context['count'] === 2); + Log::assertNotLogged(fn (LogEntry $log) => str_contains($log->message.json_encode($log->context), self::OWNER_SUB) + || str_contains($log->message.json_encode($log->context), self::OWNER_EMAIL)); + } + + public function test_owner_deletion_cancels_registrations() + { + Queue::fake(); + + Meeting::factory()->create(['room_id' => $this->room->id, 'recap' => true, 'internal_meeting_id' => 'record-id-a-1695892370102']); + + $this->room->owner->delete(); + + Queue::assertPushed(CancelRecapRegistration::class, fn (CancelRecapRegistration $job) => $job->recordId === 'record-id-a-1695892370102'); + } +} diff --git a/tests/Backend/Feature/api/v1/Room/RoomRecapTest.php b/tests/Backend/Feature/api/v1/Room/RoomRecapTest.php new file mode 100644 index 0000000000..3a807bec8f --- /dev/null +++ b/tests/Backend/Feature/api/v1/Room/RoomRecapTest.php @@ -0,0 +1,242 @@ +seed(RolesAndPermissionsSeeder::class); + + config(['recap.enabled' => true]); + + $owner = User::factory()->create([ + 'authenticator' => 'oidc', + 'oidc_sub' => 'fixture-sub-ada-0001', + ]); + $this->room = Room::factory()->create([ + 'user_id' => $owner->id, + 'expert_mode' => false, + 'recap' => false, + ]); + } + + /** + * Build the settings payload for a room update without expert mode + */ + private function settingsPayload(bool $recap): array + { + return [ + 'access_code' => null, + 'room_type' => $this->room->roomType->id, + 'expert_mode' => false, + 'name' => RoomFactory::createValidRoomName(), + 'short_description' => null, + 'allow_guests' => false, + 'recap' => $recap, + ]; + } + + public function test_owner_can_change_recap() + { + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap', false) + ->assertJsonPath('data.recap_available', true); + + $this->actingAs($this->room->owner)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(true)) + ->assertSuccessful() + ->assertJsonPath('data.recap', true); + + $this->assertTrue($this->room->refresh()->recap); + + $this->actingAs($this->room->owner)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(false)) + ->assertSuccessful() + ->assertJsonPath('data.recap', false); + + $this->assertFalse($this->room->refresh()->recap); + + // Invalid value + $this->actingAs($this->room->owner)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), array_merge($this->settingsPayload(true), ['recap' => 'yes'])) + ->assertJsonValidationErrors(['recap']); + } + + public function test_others_cannot_change_recap() + { + $coOwner = User::factory()->create(['oidc_sub' => 'fixture-sub-dup-0007']); + $this->room->members()->attach($coOwner, ['role' => RoomUserRole::CO_OWNER]); + + $member = User::factory()->create(); + $this->room->members()->attach($member, ['role' => RoomUserRole::MODERATOR]); + + $admin = User::factory()->create(['oidc_sub' => 'fixture-sub-admin-0010']); + $role = Role::factory()->create(); + $role->permissions()->attach(Permission::where('name', 'rooms.manage')->first()); + $admin->roles()->attach($role); + + // Co-owner and admin can update the settings, but the recap value is ignored + foreach ([$coOwner, $admin] as $user) { + $this->actingAs($user)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(true)) + ->assertSuccessful() + ->assertJsonPath('data.recap', false); + + $this->assertFalse($this->room->refresh()->recap); + } + + // Value set by the owner is kept, even if others send a different value + $this->room->recap = true; + $this->room->save(); + $this->actingAs($coOwner)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(false)) + ->assertSuccessful() + ->assertJsonPath('data.recap', true); + $this->assertTrue($this->room->refresh()->recap); + + // Members cannot update the settings at all + $this->actingAs($member)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(false)) + ->assertForbidden(); + $this->assertTrue($this->room->refresh()->recap); + } + + public function test_recap_unavailable_without_oidc_sub() + { + $this->room->owner->oidc_sub = null; + $this->room->owner->save(); + + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap_available', false); + + // Value is ignored while the feature is unavailable + $this->actingAs($this->room->owner)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(true)) + ->assertSuccessful() + ->assertJsonPath('data.recap', false); + $this->assertFalse($this->room->refresh()->recap); + } + + public function test_recap_unavailable_if_disabled() + { + config(['recap.enabled' => false]); + + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap_available', false); + + $this->actingAs($this->room->owner)->putJson(route('api.v1.rooms.update', ['room' => $this->room]), $this->settingsPayload(true)) + ->assertSuccessful() + ->assertJsonPath('data.recap', false); + $this->assertFalse($this->room->refresh()->recap); + } + + public function test_recap_available_only_shown_to_owner() + { + $coOwner = User::factory()->create(); + $this->room->members()->attach($coOwner, ['role' => RoomUserRole::CO_OWNER]); + + $this->actingAs($coOwner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap', false) + ->assertJsonMissingPath('data.recap_available'); + + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap_available', true); + } + + public function test_recap_disabled_with_invalid_meta_prefix() + { + Log::swap(new LogFake); + + foreach (['Recap', 'recap-x', 'r', 'recap_x', '1recap', 'a'.str_repeat('b', 16)] as $invalidPrefix) { + config(['recap.meta_prefix' => $invalidPrefix]); + + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap_available', false); + + $this->getJson(route('api.v1.config')) + ->assertSuccessful() + ->assertJsonPath('data.recap.enabled', false); + } + + // Checked on every request, but logged only once per hour (guarded by a cache entry) + $warning = fn (LogEntry $log) => $log->level === 'warning' + && $log->message === 'Meeting summaries disabled: RECAP_META_PREFIX must match ^[a-z][a-z0-9]{1,15}$'; + Log::assertLoggedTimes($warning, 1); + + // Logged again after the cache entry has expired + $this->travel(61)->minutes(); + $this->getJson(route('api.v1.config')) + ->assertSuccessful() + ->assertJsonPath('data.recap.enabled', false); + Log::assertLoggedTimes($warning, 2); + + // Valid prefixes (minimum and maximum length) + foreach (['ab', 'a'.str_repeat('b', 15), 'summary2'] as $validPrefix) { + config(['recap.meta_prefix' => $validPrefix]); + + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap_available', true); + } + } + + public function test_recap_enforced_off_by_room_type() + { + $roomType = RoomType::factory()->create([ + 'recap_default' => false, + 'recap_enforced' => true, + ]); + $this->room->roomType()->associate($roomType); + $this->room->recap = true; + $this->room->save(); + + $this->assertFalse($this->room->getRoomSetting('recap')); + + $this->actingAs($this->room->owner)->getJson(route('api.v1.rooms.settings', ['room' => $this->room])) + ->assertSuccessful() + ->assertJsonPath('data.recap', false) + ->assertJsonPath('data.room_type.recap_default', false) + ->assertJsonPath('data.room_type.recap_enforced', true); + } + + public function test_new_room_uses_room_type_default() + { + $roomType = RoomType::factory()->create(['recap_default' => true]); + $user = User::factory()->create(); + $role = Role::factory()->create(); + $role->permissions()->attach(Permission::where('name', 'rooms.create')->first()); + $user->roles()->attach($role); + + $response = $this->actingAs($user)->postJson(route('api.v1.rooms.store'), [ + 'name' => RoomFactory::createValidRoomName(), + 'room_type' => $roomType->id, + ])->assertCreated(); + + $this->assertTrue(Room::find($response->json('data.id'))->recap); + } +} diff --git a/tests/Backend/Feature/api/v1/Room/RoomTest.php b/tests/Backend/Feature/api/v1/Room/RoomTest.php index 1848572340..5917acfd97 100644 --- a/tests/Backend/Feature/api/v1/Room/RoomTest.php +++ b/tests/Backend/Feature/api/v1/Room/RoomTest.php @@ -2979,7 +2979,7 @@ public function test_update_settings_expert() // Check if correct setting values get returned $new_settings = $response->json('data'); - $settings['room_type'] = (new RoomTypeResource($roomType))->withDefaultRoomSettings()->withFeatures(); + $settings['room_type'] = (new RoomTypeResource($roomType->refresh()))->withDefaultRoomSettings()->withFeatures(); $settings['allow_membership'] = false; $settings['everyone_can_start'] = false; $settings['lock_settings_disable_cam'] = true; @@ -2996,6 +2996,8 @@ public function test_update_settings_expert() $settings['record_attendance'] = false; $settings['record'] = false; $settings['auto_start_recording'] = false; + $settings['recap'] = false; + $settings['recap_available'] = false; $this->assertJsonStringEqualsJsonString(json_encode($new_settings), json_encode($settings)); diff --git a/tests/Backend/Feature/api/v1/RoomTypeRecapTest.php b/tests/Backend/Feature/api/v1/RoomTypeRecapTest.php new file mode 100644 index 0000000000..d62e6f8d69 --- /dev/null +++ b/tests/Backend/Feature/api/v1/RoomTypeRecapTest.php @@ -0,0 +1,153 @@ +seed(RolesAndPermissionsSeeder::class); + + config(['recap.enabled' => true]); + + $this->user = User::factory()->create(); + $role = Role::factory()->create(); + $role->permissions()->attach(Permission::where('name', 'roomTypes.update')->first()); + $this->user->roles()->attach($role); + + $this->roomType = RoomType::factory()->create()->refresh(); + } + + /** + * Build a valid update payload for the room type + */ + private function payload(array $overrides = []): array + { + $data = [ + 'name' => $this->roomType->name, + 'color' => $this->roomType->color, + 'description' => $this->roomType->description, + 'server_pool' => $this->roomType->serverPool->id, + 'restrict' => false, + 'max_duration' => null, + 'max_participants' => null, + 'has_access_code_default' => false, + 'has_access_code_enforced' => false, + 'create_parameters' => null, + 'join_parameters' => null, + 'recap_type' => 'lecture', + 'recap_sink' => 'docs', + 'updated_at' => $this->roomType->updated_at, + ]; + + foreach (Room::ROOM_SETTINGS_DEFINITION as $setting => $config) { + $data[$setting.'_default'] = $this->roomType[$setting.'_default']; + $data[$setting.'_enforced'] = false; + } + + return array_merge($data, $overrides); + } + + private function update(array $overrides = []) + { + $response = $this->actingAs($this->user)->putJson(route('api.v1.roomTypes.update', ['roomType' => $this->roomType->id]), $this->payload($overrides)); + $this->roomType->refresh(); + + return $response; + } + + public function test_recap_settings_saved() + { + $this->update(['recap_default' => true, 'recap_enforced' => false]) + ->assertSuccessful() + ->assertJsonPath('data.recap_default', true) + ->assertJsonPath('data.recap_enforced', false) + ->assertJsonPath('data.recap_type', 'lecture') + ->assertJsonPath('data.recap_sink', 'docs'); + + $this->assertTrue($this->roomType->recap_default); + $this->assertEquals('lecture', $this->roomType->recap_type); + $this->assertEquals('docs', $this->roomType->recap_sink); + + $this->actingAs($this->user)->getJson(route('api.v1.roomTypes.show', ['roomType' => $this->roomType->id])) + ->assertSuccessful() + ->assertJsonPath('data.recap_type', 'lecture') + ->assertJsonPath('data.recap_sink', 'docs'); + } + + public function test_recap_cannot_be_enforced_on() + { + $this->update(['recap_default' => true, 'recap_enforced' => true]) + ->assertJsonValidationErrors(['recap_default']); + + $this->assertFalse($this->roomType->recap_enforced); + + // Enforced off is allowed, type and sink are not required then + $this->update(['recap_default' => false, 'recap_enforced' => true, 'recap_type' => null, 'recap_sink' => null]) + ->assertSuccessful() + ->assertJsonPath('data.recap_enforced', true); + } + + public function test_recap_type_and_sink_validation() + { + // Required if recap is offered + $this->update(['recap_type' => null, 'recap_sink' => null]) + ->assertJsonValidationErrors(['recap_type', 'recap_sink']); + + // Invalid names + foreach (['Lecture', '1lecture', '-lecture', 'lec_ture', 'lec ture', 'lécture', 'a'.str_repeat('b', 63)] as $invalid) { + $this->update(['recap_type' => $invalid, 'recap_sink' => $invalid]) + ->assertJsonValidationErrors(['recap_type', 'recap_sink']); + } + + // Valid names (maximum length 63) + $maxLength = 'a'.str_repeat('b', 62); + $this->update(['recap_type' => 'seminar-2', 'recap_sink' => $maxLength]) + ->assertSuccessful(); + $this->assertEquals('seminar-2', $this->roomType->recap_type); + $this->assertEquals($maxLength, $this->roomType->recap_sink); + + // Not required if the feature is disabled + config(['recap.enabled' => false]); + $this->update(['recap_type' => null, 'recap_sink' => null]) + ->assertSuccessful(); + } + + public function test_reserved_create_parameters_rejected() + { + foreach (['meta_recap-v=1', 'META_RECAP-ENABLED=true', "meetingLayout=PRESENTATION_FOCUS\nmeta_Recap-type=lecture"] as $parameters) { + $this->update(['create_parameters' => $parameters]) + ->assertJsonValidationErrors(['create_parameters']); + } + + // Other meta parameters are allowed + $this->update(['create_parameters' => "meta_recapitulation=1\nmeta_other-key=1"]) + ->assertSuccessful(); + + // Prefix comes from the config + config(['recap.meta_prefix' => 'summary']); + $this->update(['create_parameters' => 'meta_summary-v=1']) + ->assertJsonValidationErrors(['create_parameters']); + } +} diff --git a/tests/Backend/Feature/api/v1/RoomTypeTest.php b/tests/Backend/Feature/api/v1/RoomTypeTest.php index 53ecda1ae4..5b70fa9a4f 100644 --- a/tests/Backend/Feature/api/v1/RoomTypeTest.php +++ b/tests/Backend/Feature/api/v1/RoomTypeTest.php @@ -388,6 +388,8 @@ public function test_create() 'record_enforced' => false, 'auto_start_recording_default' => false, 'auto_start_recording_enforced' => false, + 'recap_default' => false, + 'recap_enforced' => false, 'has_access_code_default' => true, 'has_access_code_enforced' => false, 'create_parameters' => 'meetingLayout=PRESENTATION_FOCUS', @@ -663,6 +665,8 @@ public function test_update() 'record_enforced' => false, 'auto_start_recording_default' => false, 'auto_start_recording_enforced' => false, + 'recap_default' => false, + 'recap_enforced' => false, 'has_access_code_default' => true, 'has_access_code_enforced' => false, 'create_parameters' => 'meetingLayout=PRESENTATION_FOCUS', diff --git a/tests/Backend/Unit/Console/CleanupRecordingsCommandTest.php b/tests/Backend/Unit/Console/CleanupRecordingsCommandTest.php index 16ef5c9b20..1d65c09a55 100644 --- a/tests/Backend/Unit/Console/CleanupRecordingsCommandTest.php +++ b/tests/Backend/Unit/Console/CleanupRecordingsCommandTest.php @@ -5,6 +5,7 @@ namespace Tests\Backend\Unit\Console; use App\Enums\TimePeriod; +use App\Models\MeetingSummary; use App\Models\Recording; use App\Models\RecordingFormat; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -71,4 +72,28 @@ public function test_retention_period_enabled() $this->assertDirectoryDoesNotExist(Storage::disk('recordings')->path($recording1->id)); $this->assertDirectoryExists(Storage::disk('recordings')->path($recording2->id)); } + + public function test_meeting_summaries_follow_retention_period() + { + $summary1 = MeetingSummary::factory()->create(['start' => now()->subDays(10)]); + $summary2 = MeetingSummary::factory()->document()->create(['start' => now()->subDays(7)]); + + // Unlimited retention period keeps all summaries + $this->recordingSettings->recording_retention_period = TimePeriod::UNLIMITED; + $this->recordingSettings->save(); + + $this->artisan('cleanup:recordings'); + + $this->assertModelExists($summary1); + $this->assertModelExists($summary2); + + // Set the retention period to a week + $this->recordingSettings->recording_retention_period = TimePeriod::ONE_WEEK; + $this->recordingSettings->save(); + + $this->artisan('cleanup:recordings'); + + $this->assertModelMissing($summary1); + $this->assertModelExists($summary2); + } } diff --git a/tests/Backend/Unit/Jobs/CancelRecapRegistrationTest.php b/tests/Backend/Unit/Jobs/CancelRecapRegistrationTest.php new file mode 100644 index 0000000000..fbc866c7e4 --- /dev/null +++ b/tests/Backend/Unit/Jobs/CancelRecapRegistrationTest.php @@ -0,0 +1,121 @@ + self::SERVICE_URL, + 'recap.frontend_token' => self::FRONTEND_TOKEN, + ]); + } + + private function createJob(): CancelRecapRegistration + { + return (new CancelRecapRegistration(self::RECORD_ID))->withFakeQueueInteractions(); + } + + public static function successStatusProvider(): array + { + return [ + 'cancelled' => [204], + 'running job stopped' => [202], + 'not found' => [404], + ]; + } + + #[DataProvider('successStatusProvider')] + public function test_cancel(int $status) + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(null, $status)]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + Http::assertSentCount(1); + Http::assertSent(fn (Request $request) => $request->method() === 'DELETE' + && $request->url() === self::SERVICE_URL.'/api/v1/registrations/'.self::RECORD_ID + && $request->hasHeader('Authorization', 'Bearer '.self::FRONTEND_TOKEN)); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'info' && $log->context['record'] === self::RECORD_ID); + } + + public function test_already_delivered() + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(['type' => 'urn:recap:problem:already-delivered'], 409)]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'notice' && $log->context['record'] === self::RECORD_ID); + } + + public static function retryableStatusProvider(): array + { + return [ + 'too many requests' => [429], + 'bad gateway' => [502], + ]; + } + + #[DataProvider('retryableStatusProvider')] + public function test_retry_on_status(int $status) + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(null, $status)]); + + $job = $this->createJob(); + + $this->expectException(RuntimeException::class); + $job->handle(new RecapService); + } + + public function test_retry_on_connection_error() + { + Http::fake([self::SERVICE_URL.'/*' => Http::failedConnection()]); + + $job = $this->createJob(); + + $this->expectException(ConnectionException::class); + $job->handle(new RecapService); + } + + public function test_fail_on_client_error() + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(['type' => 'urn:recap:problem:unauthorized'], 401)]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertFailed(); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'error' + && $log->context['status'] === 401 + && ! str_contains($log->message.json_encode($log->context), self::FRONTEND_TOKEN)); + } +} diff --git a/tests/Backend/Unit/Jobs/PollMeetingSummaryTest.php b/tests/Backend/Unit/Jobs/PollMeetingSummaryTest.php new file mode 100644 index 0000000000..e929fda134 --- /dev/null +++ b/tests/Backend/Unit/Jobs/PollMeetingSummaryTest.php @@ -0,0 +1,524 @@ + self::SERVICE_URL, + 'recap.frontend_token' => self::FRONTEND_TOKEN, + ]); + + $this->meeting = Meeting::factory()->create([ + 'recap' => true, + 'internal_meeting_id' => self::RECORD_ID, + 'start' => now()->subHour(), + 'end' => now()->subMinutes(2), + ]); + } + + private function createJob(int $attempts = 1): PollMeetingSummary + { + $job = (new PollMeetingSummary($this->meeting))->withFakeQueueInteractions(); + $job->job->attempts = $attempts; + + return $job; + } + + /** + * Registration response (metadata-interface.md section 2.3 and 2.7) + * + * @param array|null $job + * @return array + */ + private function registration(string $status = 'matched', ?array $job = []): array + { + return [ + 'schema_version' => '1.1.0', + 'record_id' => self::RECORD_ID, + 'meeting_id' => $this->meeting->id, + 'frontend_id' => 'pilos-fixture', + 'status' => $status, + 'created_at' => '2026-10-29T10:00:00Z', + 'updated_at' => '2026-10-29T10:00:00Z', + 'expires_at' => null, + 'job' => $job === null ? null : array_merge([ + 'job_id' => '7f0c2d4e-1b2a-4c3d-8e9f-0a1b2c3d4e5f', + 'state' => 'running', + 'held_reason' => null, + 'outcome' => null, + 'delivered_at' => null, + 'document_url' => null, + 'summary_available' => false, + ], $job), + ]; + } + + /** + * @return array + */ + private function deliveredFrontend(): array + { + return $this->registration('matched', [ + 'state' => 'delivered', + 'outcome' => 'delivered', + 'delivered_at' => '2026-10-29T11:00:00Z', + 'summary_available' => true, + ]); + } + + private function assertSummaryNotLogged(): void + { + Log::assertNotLogged(function (LogEntry $log) { + $entry = $log->message.json_encode($log->context); + + return str_contains($entry, 'FIXTURE-SUMMARY-SECRET-TEXT') || str_contains($entry, 'Fixture meeting summary'); + }); + } + + public function test_meeting_end_dispatches_first_poll() + { + Queue::fake(); + $this->freezeSecond(); + + $meeting = Meeting::factory()->create(['recap' => true, 'internal_meeting_id' => self::RECORD_ID, 'end' => null]); + (new MeetingService($meeting))->setEnd(); + + Queue::assertPushed(PollMeetingSummary::class, function (PollMeetingSummary $job) use ($meeting) { + return $job->meeting->is($meeting) && $job->delay->equalTo(now()->addMinutes(2)); + }); + } + + public function test_meeting_end_without_summary_dispatches_nothing() + { + Queue::fake(); + + $meeting = Meeting::factory()->create(['recap' => false, 'internal_meeting_id' => self::RECORD_ID, 'end' => null]); + (new MeetingService($meeting))->setEnd(); + + config(['recap.service_url' => null]); + $meeting = Meeting::factory()->create(['recap' => true, 'internal_meeting_id' => self::RECORD_ID, 'end' => null]); + (new MeetingService($meeting))->setEnd(); + + Queue::assertNotPushed(PollMeetingSummary::class); + } + + public function test_document_result_is_stored() + { + Http::fake([ + self::REGISTRATION_URL => Http::response($this->registration('matched', [ + 'state' => 'cleaned', + 'outcome' => 'delivered', + 'delivered_at' => '2026-10-29T11:00:00Z', + 'document_url' => self::DOCUMENT_URL, + ])), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + $job->assertNotReleased(); + + $summary = MeetingSummary::sole(); + $this->assertSame(self::DOCUMENT_URL, $summary->document_url); + $this->assertNull($summary->content); + $this->assertSame(RecordingAccess::OWNER, $summary->access); + $this->assertTrue($summary->room->is($this->meeting->room)); + $this->assertEquals($this->meeting->start, $summary->start); + $this->assertEquals($this->meeting->end, $summary->end); + $this->assertSame('2026-10-29 11:00:00', $summary->delivered_at->format('Y-m-d H:i:s')); + + // Only the registration is requested, no summary text + Http::assertSentCount(1); + Http::assertSent(function (Request $request) { + return $request->method() === 'GET' + && $request->url() === self::REGISTRATION_URL + && $request->hasHeader('Authorization', 'Bearer '.self::FRONTEND_TOKEN); + }); + } + + public function test_frontend_result_is_stored_and_confirmed() + { + Http::fake([ + self::SUMMARY_URL => Http::sequence() + ->push(self::SUMMARY_MARKDOWN, 200, ['Content-Type' => 'text/markdown; charset=utf-8']) + ->push(null, 204), + self::REGISTRATION_URL => Http::response($this->deliveredFrontend()), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + $job->assertNotReleased(); + + $summary = MeetingSummary::sole(); + $this->assertNull($summary->document_url); + $this->assertSame(self::SUMMARY_MARKDOWN, $summary->content); + $this->assertSame(RecordingAccess::OWNER, $summary->access); + + // Registration, summary text, then the confirmation + $recorded = Http::recorded()->map(fn ($pair) => $pair[0]->method().' '.$pair[0]->url())->all(); + $this->assertSame([ + 'GET '.self::REGISTRATION_URL, + 'GET '.self::SUMMARY_URL, + 'DELETE '.self::SUMMARY_URL, + ], $recorded); + + $this->assertSummaryNotLogged(); + } + + public function test_frontend_result_confirmation_is_retried() + { + Http::fake([ + self::SUMMARY_URL => Http::sequence() + ->push(self::SUMMARY_MARKDOWN, 200, ['Content-Type' => 'text/markdown; charset=utf-8']) + ->push(null, 503) + ->push(null, 204), + self::REGISTRATION_URL => Http::response($this->deliveredFrontend()), + ]); + + // Confirmation fails, the summary is stored and the job polls again + $job = $this->createJob(); + $job->handle(new RecapService); + $job->assertReleased(5 * 60); + $this->assertSame(self::SUMMARY_MARKDOWN, MeetingSummary::sole()->content); + + // The next poll only confirms the pickup, the text is not fetched again + $job = $this->createJob(2); + $job->handle(new RecapService); + $job->assertNotReleased(); + $job->assertNotFailed(); + + $this->assertSame(1, MeetingSummary::count()); + $recorded = Http::recorded()->map(fn ($pair) => $pair[0]->method().' '.$pair[0]->url())->all(); + $this->assertSame([ + 'GET '.self::REGISTRATION_URL, + 'GET '.self::SUMMARY_URL, + 'DELETE '.self::SUMMARY_URL, + 'GET '.self::REGISTRATION_URL, + 'DELETE '.self::SUMMARY_URL, + ], $recorded); + + $this->assertSummaryNotLogged(); + } + + public function test_too_large_summary_is_rejected() + { + Http::fake([ + self::SUMMARY_URL => Http::sequence() + ->push(str_repeat('a', PollMeetingSummary::MAX_SUMMARY_BYTES + 1), 200, ['Content-Type' => 'text/markdown; charset=utf-8']) + ->push(null, 204), + self::REGISTRATION_URL => Http::response($this->deliveredFrontend()), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + $job->assertNotReleased(); + $this->assertSame(0, MeetingSummary::count()); + // The pickup is still confirmed, so the service deletes the text + Http::assertSent(fn (Request $request) => $request->method() === 'DELETE' && $request->url() === self::SUMMARY_URL); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'warning' && $log->context['bytes'] === PollMeetingSummary::MAX_SUMMARY_BYTES + 1); + // One log line for the rejected text + Log::assertNotLogged(fn (LogEntry $log) => str_contains($log->message, 'delivered without')); + } + + public function test_summary_at_size_limit_is_stored() + { + $content = str_repeat('a', PollMeetingSummary::MAX_SUMMARY_BYTES); + Http::fake([ + self::SUMMARY_URL => Http::sequence() + ->push($content, 200, ['Content-Type' => 'text/markdown; charset=utf-8']) + ->push(null, 204), + self::REGISTRATION_URL => Http::response($this->deliveredFrontend()), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $this->assertSame($content, MeetingSummary::sole()->content); + } + + public function test_invalid_document_url_is_rejected() + { + Http::fake([ + self::REGISTRATION_URL => Http::response($this->registration('matched', [ + 'state' => 'cleaned', + 'outcome' => 'delivered', + 'delivered_at' => '2026-10-29T11:00:00Z', + 'document_url' => 'javascript:alert(1)', + ])), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + $job->assertNotReleased(); + $this->assertSame(0, MeetingSummary::count()); + // One log line for the rejected link + Log::assertLogged(fn (LogEntry $log) => $log->level === 'warning' && str_contains($log->message, 'document link')); + Log::assertNotLogged(fn (LogEntry $log) => str_contains($log->message, 'delivered without')); + } + + public function test_stored_result_is_not_duplicated() + { + MeetingSummary::factory()->document()->create(['meeting_id' => $this->meeting->id]); + + Http::fake([ + self::REGISTRATION_URL => Http::response($this->registration('matched', [ + 'state' => 'cleaned', + 'outcome' => 'delivered', + 'delivered_at' => '2026-10-29T11:00:00Z', + 'document_url' => self::DOCUMENT_URL, + ])), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $this->assertSame(1, MeetingSummary::count()); + $this->assertNotSame(self::DOCUMENT_URL, MeetingSummary::sole()->document_url); + } + + public static function pendingProvider(): array + { + return [ + 'registered' => ['registered', null], + 'received' => ['matched', ['state' => 'received']], + 'running' => ['matched', ['state' => 'running']], + 'held' => ['matched', ['state' => 'held', 'held_reason' => 'owner_unresolved']], + ]; + } + + /** + * @param array|null $job + */ + #[DataProvider('pendingProvider')] + public function test_pending_result_is_polled_again(string $status, ?array $job) + { + Http::fake([self::REGISTRATION_URL => Http::response($this->registration($status, $job))]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertReleased(5 * 60); + $job->assertNotFailed(); + $this->assertSame(0, MeetingSummary::count()); + } + + public static function backoffProvider(): array + { + // attempt that just ran => minutes until the next poll + return [ + 'after first poll' => [1, 5], + 'after second poll' => [2, 10], + 'after third poll' => [3, 30], + 'after fourth poll' => [4, 60], + 'after tenth poll' => [10, 60], + ]; + } + + #[DataProvider('backoffProvider')] + public function test_backoff(int $attempt, int $minutes) + { + Http::fake([self::REGISTRATION_URL => Http::response($this->registration('registered', null))]); + + $job = $this->createJob($attempt); + $job->handle(new RecapService); + + $job->assertReleased($minutes * 60); + } + + public function test_first_poll_delay() + { + $this->assertSame(2, PollMeetingSummary::pollDelay(1)); + } + + public function test_give_up_after_24_hours() + { + Http::fake([self::REGISTRATION_URL => Http::response($this->registration('matched', ['state' => 'held', 'held_reason' => 'owner_unresolved']))]); + + // Next poll in one hour would still be within 24 hours after the meeting end + $this->meeting->end = now()->subHours(22)->subMinutes(59); + $this->meeting->save(); + $job = $this->createJob(20); + $job->handle(new RecapService); + $job->assertReleased(60 * 60); + + // Next poll would be later than 24 hours after the meeting end + $this->meeting->end = now()->subHours(23)->subMinutes(1); + $this->meeting->save(); + $job = $this->createJob(21); + $job->handle(new RecapService); + $job->assertNotReleased(); + $job->assertNotFailed(); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'notice' && str_contains($log->message, 'Stopped polling')); + } + + public static function finalResultProvider(): array + { + return [ + 'registration cancelled' => ['cancelled', null], + 'job failed' => ['matched', ['state' => 'failed']], + 'outcome cancelled' => ['matched', ['state' => 'cleaned', 'outcome' => 'cancelled']], + 'outcome purged' => ['matched', ['state' => 'cleaned', 'outcome' => 'purged']], + ]; + } + + /** + * @param array|null $job + */ + #[DataProvider('finalResultProvider')] + public function test_stop_on_final_result(string $status, ?array $job) + { + Http::fake([self::REGISTRATION_URL => Http::response($this->registration($status, $job))]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotReleased(); + $job->assertNotFailed(); + $this->assertSame(0, MeetingSummary::count()); + Http::assertSentCount(1); + } + + public function test_stop_on_not_found() + { + Http::fake([self::REGISTRATION_URL => Http::response([ + 'type' => 'urn:recap:problem:not-found', + 'title' => 'Not found', + 'status' => 404, + ], 404, ['Content-Type' => 'application/problem+json'])]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotReleased(); + $job->assertNotFailed(); + $this->assertSame(0, MeetingSummary::count()); + } + + public static function retryableStatusProvider(): array + { + return [ + '429' => [429], + '500' => [500], + '503' => [503], + ]; + } + + #[DataProvider('retryableStatusProvider')] + public function test_poll_again_on_status(int $status) + { + Http::fake([self::REGISTRATION_URL => Http::response(null, $status)]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertReleased(5 * 60); + $job->assertNotFailed(); + } + + public function test_poll_again_on_connection_error() + { + Http::fake([self::REGISTRATION_URL => fn () => throw new ConnectionException('Connection refused')]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertReleased(5 * 60); + $job->assertNotFailed(); + } + + public function test_fail_on_client_error() + { + Http::fake([self::REGISTRATION_URL => Http::response([ + 'type' => 'urn:recap:problem:unauthorized', + 'title' => 'Unauthorized', + 'status' => 401, + ], 401, ['Content-Type' => 'application/problem+json'])]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertFailed(); + $job->assertNotReleased(); + } + + public function test_summary_not_available_is_not_stored() + { + Http::fake([ + self::SUMMARY_URL => Http::sequence() + ->push(['type' => 'urn:recap:problem:summary-not-available', 'status' => 404], 404, ['Content-Type' => 'application/problem+json']) + ->push(null, 204), + self::REGISTRATION_URL => Http::response($this->deliveredFrontend()), + ]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + $job->assertNotReleased(); + $this->assertSame(0, MeetingSummary::count()); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'notice' && str_contains($log->message, 'delivered without')); + } + + public function test_skip_without_service_configuration() + { + config(['recap.frontend_token' => null]); + Http::fake(); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotReleased(); + Http::assertNothingSent(); + } +} diff --git a/tests/Backend/Unit/Jobs/ProcessRecordingTest.php b/tests/Backend/Unit/Jobs/ProcessRecordingTest.php index e4c33ede54..901e16b3eb 100644 --- a/tests/Backend/Unit/Jobs/ProcessRecordingTest.php +++ b/tests/Backend/Unit/Jobs/ProcessRecordingTest.php @@ -322,4 +322,76 @@ public function test_public() $this->assertTrue(Storage::disk('recordings')->directoryExists(self::INTERNAL_MEETING_ID)); $this->assertFileExists(Storage::disk('recordings')->path(self::INTERNAL_MEETING_ID.'/notes/notes.pdf')); } + + /** + * The recording of a meeting with a meeting summary but without recording is discarded + */ + public function test_summary_only_meeting_is_discarded() + { + Storage::fake('recordings'); + Storage::fake('recordings-spool'); + + Meeting::factory()->create([ + 'id' => self::EXTERNAL_MEETING_ID, + 'record' => false, + 'recap' => true, + ]); + + Log::swap(new LogFake); + Queue::fake(); + + copy(base_path('tests/Backend/Fixtures/Recordings/multiple.tar'), Storage::disk('recordings-spool')->path('multiple.tar')); + + $job = (new ProcessRecording('multiple.tar'))->withFakeQueueInteractions(); + + $job->handle(); + + $job->assertNotFailed(); + + // Nothing stored or shown + $this->assertDatabaseCount('recordings', 0); + $this->assertDatabaseCount('recording_formats', 0); + $this->assertCount(0, Storage::disk('recordings')->allFiles()); + $this->assertFalse(Storage::disk('recordings')->directoryExists(self::INTERNAL_MEETING_ID)); + + // Spool file removed as after a successful import + $this->assertCount(0, Storage::disk('recordings-spool')->allFiles()); + + // One log line with the meeting ID only + Log::assertLoggedTimes(fn (LogEntry $log) => str_starts_with($log->message, 'Discarded recording of meeting'), 1); + Log::assertLogged(fn (LogEntry $log) => str_starts_with($log->message, 'Discarded recording of meeting') + && $log->level === 'info' + && $log->context === ['meeting' => self::EXTERNAL_MEETING_ID]); + Log::assertNotLogged(fn (LogEntry $log) => str_contains($log->message.json_encode($log->context), self::TITLE)); + } + + /** + * The recording of a meeting with recording and meeting summary is imported as before + */ + public function test_recording_with_summary_is_imported() + { + Storage::fake('recordings'); + Storage::fake('recordings-spool'); + + $meeting = Meeting::factory()->create([ + 'id' => self::EXTERNAL_MEETING_ID, + 'record' => true, + 'recap' => true, + ]); + + Log::swap(new LogFake); + Queue::fake(); + + copy(base_path('tests/Backend/Fixtures/Recordings/multiple.tar'), Storage::disk('recordings-spool')->path('multiple.tar')); + + $job = (new ProcessRecording('multiple.tar'))->withFakeQueueInteractions(); + + $job->handle(); + + $this->assertCount(0, Storage::disk('recordings-spool')->allFiles()); + $this->assertCount(1, $meeting->room->recordings); + $this->assertCount(5, $meeting->room->recordings->first()->formats); + $this->assertFileExists(Storage::disk('recordings')->path(self::INTERNAL_MEETING_ID.'/notes/notes.pdf')); + Log::assertNotLogged(fn (LogEntry $log) => str_starts_with($log->message, 'Discarded recording of meeting')); + } } diff --git a/tests/Backend/Unit/Jobs/RegisterRecapMeetingTest.php b/tests/Backend/Unit/Jobs/RegisterRecapMeetingTest.php new file mode 100644 index 0000000000..b7379236f9 --- /dev/null +++ b/tests/Backend/Unit/Jobs/RegisterRecapMeetingTest.php @@ -0,0 +1,213 @@ + self::SERVICE_URL, + 'recap.frontend_token' => self::FRONTEND_TOKEN, + ]); + + $this->owner = User::factory()->create([ + 'authenticator' => 'oidc', + 'oidc_sub' => self::OWNER_SUB, + 'email' => self::OWNER_EMAIL, + ]); + $this->meeting = Meeting::factory()->create([ + 'recap' => true, + 'internal_meeting_id' => self::RECORD_ID, + ]); + } + + private function createJob(): RegisterRecapMeeting + { + return (new RegisterRecapMeeting($this->meeting, $this->owner))->withFakeQueueInteractions(); + } + + /** + * Assert that no log entry contains the owner subject, email or the token + */ + private function assertNoPersonalDataLogged(): void + { + Log::assertNotLogged(function (LogEntry $log) { + $entry = $log->message.json_encode($log->context); + + return str_contains($entry, self::OWNER_SUB) + || str_contains($entry, self::OWNER_EMAIL) + || str_contains($entry, self::FRONTEND_TOKEN); + }); + } + + public function test_register() + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(['status' => 'registered'], 201)]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertNotFailed(); + Http::assertSentCount(1); + Http::assertSent(fn (Request $request) => $request->method() === 'PUT' + && $request->url() === self::SERVICE_URL.'/api/v1/registrations/'.self::RECORD_ID + && $request->hasHeader('Authorization', 'Bearer '.self::FRONTEND_TOKEN) + && $request->isJson() + && $request->data() === [ + 'schema_version' => '1.0.0', + 'meeting_id' => $this->meeting->id, + 'record_id' => self::RECORD_ID, + 'owner' => [ + 'sub' => self::OWNER_SUB, + 'email' => self::OWNER_EMAIL, + ], + ]); + + Log::assertLogged(fn (LogEntry $log) => $log->level === 'info' && $log->context['meeting'] === $this->meeting->id); + $this->assertNoPersonalDataLogged(); + } + + public function test_queue_payload_has_no_personal_data() + { + $payload = serialize(new RegisterRecapMeeting($this->meeting, $this->owner)); + + $this->assertStringNotContainsString(self::OWNER_SUB, $payload); + $this->assertStringNotContainsString(self::OWNER_EMAIL, $payload); + } + + public static function retryableStatusProvider(): array + { + return [ + 'too many requests' => [429], + 'internal server error' => [500], + 'service unavailable' => [503], + ]; + } + + #[DataProvider('retryableStatusProvider')] + public function test_retry_on_status(int $status) + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(['type' => 'urn:recap:problem:rate-limited'], $status)]); + + $job = $this->createJob(); + + try { + $job->handle(new RecapService); + $this->fail('Expected exception to retry the job'); + } catch (RuntimeException $exception) { + $this->assertStringNotContainsString(self::OWNER_SUB, $exception->getMessage()); + } + + $job->assertNotFailed(); + $this->assertNoPersonalDataLogged(); + } + + public function test_retry_on_connection_error() + { + Http::fake([self::SERVICE_URL.'/*' => Http::failedConnection()]); + + $job = $this->createJob(); + + $this->expectException(ConnectionException::class); + $job->handle(new RecapService); + } + + public function test_retry_settings() + { + $job = new RegisterRecapMeeting($this->meeting, $this->owner); + + $this->assertEquals(0, $job->tries); + $this->assertEquals([30, 60, 300], $job->backoff()); + $this->assertTrue($job->retryUntil() > now()->addHours(23)); + } + + public static function finalStatusProvider(): array + { + return [ + 'bad request' => [400, 'urn:recap:problem:invalid-request'], + 'unauthorized' => [401, 'urn:recap:problem:unauthorized'], + 'conflict' => [409, 'urn:recap:problem:registration-locked'], + 'unprocessable' => [422, 'urn:recap:problem:unsupported-schema-version'], + ]; + } + + #[DataProvider('finalStatusProvider')] + public function test_fail_on_client_error(int $status, string $type) + { + Http::fake([self::SERVICE_URL.'/*' => Http::response(['type' => $type, 'detail' => 'fixture detail'], $status)]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertFailed(); + Http::assertSentCount(1); + Log::assertLogged(fn (LogEntry $log) => $log->level === 'error' + && $log->context['status'] === $status + && $log->context['type'] === $type + && $log->context['meeting'] === $this->meeting->id); + $this->assertNoPersonalDataLogged(); + } + + public function test_fail_without_owner_subject() + { + Http::fake(); + $this->owner->forceFill(['oidc_sub' => null])->save(); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertFailed(); + Http::assertNothingSent(); + $this->assertNoPersonalDataLogged(); + } + + public function test_fail_without_service_configuration() + { + Http::fake(); + config(['recap.frontend_token' => null]); + + $job = $this->createJob(); + $job->handle(new RecapService); + + $job->assertFailed(); + Http::assertNothingSent(); + } +} diff --git a/tests/Backend/Unit/RecapConfigTest.php b/tests/Backend/Unit/RecapConfigTest.php new file mode 100644 index 0000000000..4172ca010f --- /dev/null +++ b/tests/Backend/Unit/RecapConfigTest.php @@ -0,0 +1,62 @@ +setEnv($key, null); + } + + parent::tearDown(); + } + + private function setEnv(string $key, ?string $value): void + { + if ($value === null) { + putenv($key); + unset($_ENV[$key], $_SERVER[$key]); + + return; + } + + putenv($key.'='.$value); + $_ENV[$key] = $value; + $_SERVER[$key] = $value; + } + + public static function environmentProvider(): array + { + return [ + 'all set' => ['true', 'https://service.recap.test', 'FIXTURE-NOT-A-SECRET-fe-0123456789abcdef0123456789abcdef', true], + 'switch off' => ['false', 'https://service.recap.test', 'FIXTURE-NOT-A-SECRET-fe-0123456789abcdef0123456789abcdef', false], + 'service url missing' => ['true', null, 'FIXTURE-NOT-A-SECRET-fe-0123456789abcdef0123456789abcdef', false], + 'token missing' => ['true', 'https://service.recap.test', null, false], + 'token empty' => ['true', 'https://service.recap.test', '', false], + ]; + } + + /** + * The feature is only enabled with the master switch, the service URL and the token + */ + #[DataProvider('environmentProvider')] + public function test_enabled_requires_service_url_and_token(string $enabled, ?string $serviceUrl, ?string $token, bool $expected) + { + $this->setEnv('RECAP_ENABLED', $enabled); + $this->setEnv('RECAP_SERVICE_URL', $serviceUrl); + $this->setEnv('RECAP_FRONTEND_TOKEN', $token); + + $config = require config_path('recap.php'); + + $this->assertSame($expected, $config['enabled']); + } +} From 2441b2c5fe7b1a7269b2306fd67e502b5d3974a2 Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 12 Nov 2026 17:38:12 +0100 Subject: [PATCH 3/4] Add meeting summary settings and room tab to the frontend - Room settings: section for the room owner to enable meeting summaries - Admin room types: default, enforced flag, meeting type and destination - Join dialog: consent texts for meetings with a summary - Room tab listing the meeting summaries with link, download, access change and delete --- resources/js/components/RoomJoinButton.vue | 32 +- .../js/components/RoomTabMeetingSummaries.vue | 380 ++++++++++++++++ .../RoomTabMeetingSummariesDeleteButton.vue | 115 +++++ .../RoomTabMeetingSummariesDownloadButton.vue | 118 +++++ .../RoomTabMeetingSummariesEditButton.vue | 168 ++++++++ resources/js/components/RoomTabSection.vue | 14 + resources/js/components/RoomTabSettings.vue | 19 + .../js/composables/useRoomTypeSettings.js | 9 + resources/js/constants/modelNames.js | 1 + resources/js/constants/roomSettings.js | 3 + resources/js/policies/RoomPolicy.js | 11 + resources/js/views/AdminRoomTypesView.vue | 104 +++++ tests/Frontend/e2e/AdminRoomTypesEdit.cy.js | 100 +++++ .../e2e/RoomsViewMeetingSummaries.cy.js | 277 ++++++++++++ .../RoomsViewMeetingSummariesActions.cy.js | 406 ++++++++++++++++++ tests/Frontend/e2e/RoomsViewMeetings.cy.js | 122 ++++++ tests/Frontend/e2e/RoomsViewSettings.cy.js | 90 ++++ .../fixtures/roomMeetingSummaries.json | 33 ++ tests/Frontend/fixtures/roomType.json | 4 + 19 files changed, 2001 insertions(+), 5 deletions(-) create mode 100644 resources/js/components/RoomTabMeetingSummaries.vue create mode 100644 resources/js/components/RoomTabMeetingSummariesDeleteButton.vue create mode 100644 resources/js/components/RoomTabMeetingSummariesDownloadButton.vue create mode 100644 resources/js/components/RoomTabMeetingSummariesEditButton.vue create mode 100644 tests/Frontend/e2e/RoomsViewMeetingSummaries.cy.js create mode 100644 tests/Frontend/e2e/RoomsViewMeetingSummariesActions.cy.js create mode 100644 tests/Frontend/fixtures/roomMeetingSummaries.json diff --git a/resources/js/components/RoomJoinButton.vue b/resources/js/components/RoomJoinButton.vue index 3e7a435c78..637f53ebb7 100644 --- a/resources/js/components/RoomJoinButton.vue +++ b/resources/js/components/RoomJoinButton.vue @@ -89,10 +89,10 @@
- {{ $t("rooms.recording_info") }} + {{ $t(recordingConsentInfo) }} {{ $t("rooms.recording_hint") }}
-
+
@@ -315,7 +316,7 @@ const autoJoin = computed(() => { return false; } - if (features.value.recording) { + if (features.value.recording || features.value.recap) { return false; } @@ -326,6 +327,27 @@ const autoJoin = computed(() => { return true; }); +/** + * Consent texts for the recording and the meeting summary (recap) + */ +const recordingConsentInfo = computed(() => { + if (!features.value.recap) { + return "rooms.recording_info"; + } + return features.value.recording + ? "rooms.recording_recap_info" + : "rooms.recap_info"; +}); + +const recordingConsentAccept = computed(() => { + if (!features.value.recap) { + return "rooms.recording_accept"; + } + return features.value.recording + ? "rooms.recording_recap_accept" + : "rooms.recap_accept"; +}); + /** * Handle the page is restored from the back/forward cache after redirecting to BBB * The modal is still shown and loaded, close and reload the page diff --git a/resources/js/components/RoomTabMeetingSummaries.vue b/resources/js/components/RoomTabMeetingSummaries.vue new file mode 100644 index 0000000000..9f489b5feb --- /dev/null +++ b/resources/js/components/RoomTabMeetingSummaries.vue @@ -0,0 +1,380 @@ + + diff --git a/resources/js/components/RoomTabMeetingSummariesDeleteButton.vue b/resources/js/components/RoomTabMeetingSummariesDeleteButton.vue new file mode 100644 index 0000000000..0114ff654d --- /dev/null +++ b/resources/js/components/RoomTabMeetingSummariesDeleteButton.vue @@ -0,0 +1,115 @@ + + diff --git a/resources/js/components/RoomTabMeetingSummariesDownloadButton.vue b/resources/js/components/RoomTabMeetingSummariesDownloadButton.vue new file mode 100644 index 0000000000..899041bb57 --- /dev/null +++ b/resources/js/components/RoomTabMeetingSummariesDownloadButton.vue @@ -0,0 +1,118 @@ + + diff --git a/resources/js/components/RoomTabMeetingSummariesEditButton.vue b/resources/js/components/RoomTabMeetingSummariesEditButton.vue new file mode 100644 index 0000000000..86d03b220d --- /dev/null +++ b/resources/js/components/RoomTabMeetingSummariesEditButton.vue @@ -0,0 +1,168 @@ + + diff --git a/resources/js/components/RoomTabSection.vue b/resources/js/components/RoomTabSection.vue index 8daa028cd4..f0fb1626a2 100644 --- a/resources/js/components/RoomTabSection.vue +++ b/resources/js/components/RoomTabSection.vue @@ -146,6 +146,7 @@ import RoomTabFiles from "./RoomTabFiles.vue"; import RoomTabHistory from "./RoomTabHistory.vue"; import RoomTabSettings from "./RoomTabSettings.vue"; import RoomTabRecordings from "./RoomTabRecordings.vue"; +import RoomTabMeetingSummaries from "./RoomTabMeetingSummaries.vue"; import { onRoomHasChanged } from "../composables/useRoomHelpers.js"; import { useUrlSearchParams } from "@vueuse/core"; import { useSettingsStore } from "../stores/settings.js"; @@ -270,6 +271,19 @@ const availableTabs = computed(() => { }); } + // Meeting summaries: shown if the room has summaries or the feature is enabled + if ( + props.room.has_meeting_summaries || + settingsStore.getSetting("recap.enabled") + ) { + tabs.push({ + key: "meeting_summaries", + label: t("rooms.meeting_summaries.title"), + icon: "fa-solid fa-file-pen", + component: RoomTabMeetingSummaries, + }); + } + if (userPermissions.can("viewSettings", props.room)) { tabs.push({ key: "streaming", diff --git a/resources/js/components/RoomTabSettings.vue b/resources/js/components/RoomTabSettings.vue index 2907228fb0..5a324cb2b1 100644 --- a/resources/js/components/RoomTabSettings.vue +++ b/resources/js/components/RoomTabSettings.vue @@ -261,6 +261,25 @@ const form = computed(() => { : []), ], }, + ...(settingsStore.getSetting("recap.enabled") && + userPermissions.can("manageRecap", props.room) + ? [ + { + title: t("rooms.settings.recap.title"), + items: [ + { + setting: "recap", + label: t("rooms.settings.recordings.recap"), + component: RoomTabSettingsToggleSwitch, + disabled: disabled.value || !settings.value.recap_available, + warningMessage: settings.value.recap_available + ? null + : t("rooms.settings.recordings.recap_unavailable"), + }, + ], + }, + ] + : []), { title: t("rooms.settings.restrictions.title"), items: [ diff --git a/resources/js/composables/useRoomTypeSettings.js b/resources/js/composables/useRoomTypeSettings.js index 5c00746d6d..e73c24b5d7 100644 --- a/resources/js/composables/useRoomTypeSettings.js +++ b/resources/js/composables/useRoomTypeSettings.js @@ -72,6 +72,15 @@ export function useRoomTypeSettings() { }, ] : []), + ...(settingsStore.getSetting("recap.enabled") + ? [ + { + key: "recap", + label: t("rooms.settings.recordings.recap"), + type: "switch", + }, + ] + : []), ], }, { diff --git a/resources/js/constants/modelNames.js b/resources/js/constants/modelNames.js index 60d9f8a1e5..322ef68890 100644 --- a/resources/js/constants/modelNames.js +++ b/resources/js/constants/modelNames.js @@ -3,3 +3,4 @@ export const ROOM_FILE = "room_file"; export const ROOM_PERSONALIZED_LINK = "room_personalized_link"; export const RECORDING = "recording"; export const USER = "user"; +export const MEETING_SUMMARY = "meeting_summary"; diff --git a/resources/js/constants/roomSettings.js b/resources/js/constants/roomSettings.js index 9a035eecce..d2de8cfd3d 100644 --- a/resources/js/constants/roomSettings.js +++ b/resources/js/constants/roomSettings.js @@ -47,6 +47,9 @@ export const ROOM_SETTINGS_DEFINITION = { auto_start_recording: { expert_setting: true, }, + recap: { + expert_setting: false, + }, visibility: { expert_setting: true, }, diff --git a/resources/js/policies/RoomPolicy.js b/resources/js/policies/RoomPolicy.js index aea3e698fa..6a38ee435b 100644 --- a/resources/js/policies/RoomPolicy.js +++ b/resources/js/policies/RoomPolicy.js @@ -88,6 +88,17 @@ export default { user.permissions.includes("rooms.manage"); }, + /** + * Is user allowed to change the meeting summary (recap) setting of this room + * Only the room owner can opt in, as the summary is delivered to the owner + * @param user + * @param model + * @return {boolean} + */ + manageRecap(user, model) { + return !user ? false : model.owner?.id === user.id; + }, + /** * Is user allowed to become member of this room * @param user diff --git a/resources/js/views/AdminRoomTypesView.vue b/resources/js/views/AdminRoomTypesView.vue index 97d48cc27e..4476248ef2 100644 --- a/resources/js/views/AdminRoomTypesView.vue +++ b/resources/js/views/AdminRoomTypesView.vue @@ -795,6 +795,106 @@
+ +

{{ $t("rooms.settings.restrictions.title") }} @@ -1624,6 +1724,10 @@ const model = ref({ record_enforced: false, auto_start_recording_default: false, auto_start_recording_enforced: false, + recap_default: false, + recap_enforced: false, + recap_type: null, + recap_sink: null, visibility_default: 0, visibility_enforced: false, has_access_code_default: true, diff --git a/tests/Frontend/e2e/AdminRoomTypesEdit.cy.js b/tests/Frontend/e2e/AdminRoomTypesEdit.cy.js index 0955320aa4..e3ba01e606 100644 --- a/tests/Frontend/e2e/AdminRoomTypesEdit.cy.js +++ b/tests/Frontend/e2e/AdminRoomTypesEdit.cy.js @@ -1231,6 +1231,106 @@ describe("Admin room types edit", function () { cy.url().should("not.include", "/edit"); }); + it("edit room type meeting summary settings", function () { + cy.fixture("config.json").then((config) => { + config.data.general.base_url = Cypress.config("baseUrl"); + config.data.recap = { enabled: true }; + + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + + cy.fixture("roomType.json").then((roomType) => { + roomType.data.recap_default = false; + roomType.data.recap_enforced = false; + roomType.data.recap_type = null; + roomType.data.recap_sink = null; + + cy.intercept("GET", "api/v1/roomTypes/3", { + statusCode: 200, + body: roomType, + }).as("roomTypeRequest"); + + cy.visit("/admin/room_types/3/edit"); + cy.wait("@roomTypeRequest"); + cy.wait("@serverPoolsRequest"); + + cy.get('[data-test="recap-field"]') + .should("include.text", "rooms.settings.recordings.recap") + .and("include.text", "admin.room_types.recap.enforced_hint") + .within(() => { + cy.get("#recap-default").should("not.be.checked").click(); + cy.get('[data-test="recap-enforced"]').should( + "have.attr", + "aria-pressed", + "false", + ); + }); + + cy.get('[data-test="recap-type-field"]') + .should("include.text", "admin.room_types.recap.type") + .and("include.text", "admin.room_types.recap.type_description") + .find("#recap-type") + .should("have.value", "") + .type("meeting-summary"); + + cy.get('[data-test="recap-sink-field"]') + .should("include.text", "admin.room_types.recap.sink") + .and("include.text", "admin.room_types.recap.sink_description") + .find("#recap-sink") + .should("have.value", "") + .type("docs"); + + cy.intercept("PUT", "api/v1/roomTypes/3", { + statusCode: 422, + body: { + message: "The given data was invalid.", + errors: { + recap_sink: ["The Summary destination format is invalid."], + }, + }, + }).as("saveChangesRequest"); + + cy.get('[data-test="room-types-save-button"]').click(); + + cy.wait("@saveChangesRequest").then((interception) => { + expect(interception.request.body).to.include({ + recap_default: true, + recap_enforced: false, + recap_type: "meeting-summary", + recap_sink: "docs", + }); + }); + + cy.get('[data-test="recap-sink-field"]').should( + "include.text", + "The Summary destination format is invalid.", + ); + cy.get(".p-toast-message") + .should("include.text", "The given data was invalid.") + .find("button") + .click(); + }); + + // Fields are hidden while the feature is disabled + cy.fixture("config.json").then((config) => { + config.data.general.base_url = Cypress.config("baseUrl"); + + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + cy.visit("/admin/room_types/3/edit"); + cy.wait("@roomTypeRequest"); + cy.get("#room-type-name").should("be.visible"); + cy.get('[data-test="recap-field"]').should("not.exist"); + cy.get('[data-test="recap-type-field"]').should("not.exist"); + cy.get('[data-test="recap-sink-field"]').should("not.exist"); + }); + it("edit room type errors", function () { cy.fixture("roomType.json").then((roomType) => { roomType.data.restrict = true; diff --git a/tests/Frontend/e2e/RoomsViewMeetingSummaries.cy.js b/tests/Frontend/e2e/RoomsViewMeetingSummaries.cy.js new file mode 100644 index 0000000000..9bb9d39410 --- /dev/null +++ b/tests/Frontend/e2e/RoomsViewMeetingSummaries.cy.js @@ -0,0 +1,277 @@ +import { interceptIndefinitely } from "../support/utils/interceptIndefinitely.js"; + +describe("Rooms view meeting summaries", function () { + beforeEach(function () { + cy.init(); + cy.interceptRoomViewRequests(); + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + fixture: "roomMeetingSummaries.json", + }).as("roomMeetingSummariesRequest"); + + cy.fixture("config.json").then((config) => { + config.data.general.base_url = Cypress.config("baseUrl"); + config.data.recap = { enabled: true }; + + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + + cy.setValidRememberedParticipantName("Laura Rivera"); + }); + + it("show tab", function () { + // Feature enabled + cy.visit("/rooms/abc-def-123"); + cy.wait("@roomRequest"); + cy.get("#tab-meeting_summaries").should("be.visible"); + + // Feature disabled, room without summaries + cy.fixture("config.json").then((config) => { + config.data.general.base_url = Cypress.config("baseUrl"); + + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + cy.reload(); + cy.wait("@roomRequest"); + cy.get("#tab-recordings").should("be.visible"); + cy.get("#tab-meeting_summaries").should("not.exist"); + + // Feature disabled, room with summaries + cy.fixture("room.json").then((room) => { + room.data.has_meeting_summaries = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + cy.reload(); + cy.wait("@roomRequest"); + cy.get("#tab-meeting_summaries").should("be.visible"); + }); + + it("load meeting summaries", function () { + const roomMeetingSummariesRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123/meetingSummaries*", + { fixture: "roomMeetingSummaries.json" }, + "roomMeetingSummariesRequest", + ); + + cy.visit("/rooms/abc-def-123"); + + cy.get("#tab-meeting_summaries").click(); + + cy.url().should("include", "/rooms/abc-def-123#tab=meeting_summaries"); + + // Check loading + cy.get('[data-test="overlay"]').should("be.visible"); + cy.get('[data-test="room-meeting-summaries-reload-button"]') + .should("be.disabled") + .then(() => { + roomMeetingSummariesRequest.sendResponse(); + }); + + cy.wait("@roomMeetingSummariesRequest").then((interception) => { + expect(interception.request.query).to.contain({ + page: "1", + sort_direction: "desc", + }); + }); + + cy.get('[data-test="overlay"]').should("not.exist"); + cy.get('[data-test="room-meeting-summaries-reload-button"]').should( + "not.be.disabled", + ); + + cy.get('[data-test="room-meeting-summary-item"]').should("have.length", 2); + + // Summary as a link to a document + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .should("include.text", "08/17/2022, 11:20") + .and("include.text", "20 app.time_formats.minutes") + .and("include.text", "rooms.recordings.access_types.owner") + .within(() => { + cy.get('[data-test="room-meeting-summary-document-hint"]').should( + "have.text", + "rooms.meeting_summaries.document_hint_owner", + ); + cy.get('a[data-test="room-meeting-summaries-open-document-button"]') + .should( + "have.attr", + "href", + "https://docs.example.com/docs/0b6b7c7e-5d3c-4c1e-9a43-3f0c2f6d9a11/", + ) + .and("have.attr", "target", "_blank") + .and("have.attr", "rel", "noopener noreferrer"); + cy.get('[data-test="room-meeting-summaries-download-button"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summaries-edit-button"]').should( + "be.visible", + ); + cy.get('[data-test="room-meeting-summaries-delete-button"]').should( + "be.visible", + ); + }); + + // Summary text stored in the room + cy.get('[data-test="room-meeting-summary-item"]') + .eq(1) + .should("include.text", "08/16/2022, 10:00") + .and( + "include.text", + "1 app.time_formats.hour, 0 app.time_formats.minutes", + ) + .and("include.text", "rooms.recordings.access_types.participant") + .within(() => { + cy.get('[data-test="room-meeting-summary-document-hint"]').should( + "not.exist", + ); + cy.get( + '[data-test="room-meeting-summaries-open-document-button"]', + ).should("not.exist"); + cy.get('[data-test="room-meeting-summaries-download-button"]').should( + "be.visible", + ); + }); + + cy.get('[data-test="retention-period-message"]') + .should("include.text", "rooms.meeting_summaries.retention_period.title") + .and( + "include.text", + "rooms.meeting_summaries.retention_period.unlimited", + ); + + // Sort ascending + cy.get('[data-test="room-meeting-summaries-sort-button"]').click(); + cy.wait("@roomMeetingSummariesRequest").then((interception) => { + expect(interception.request.query).to.contain({ + page: "1", + sort_direction: "asc", + }); + }); + }); + + it("load meeting summaries empty", function () { + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: { + data: [], + meta: { + current_page: 1, + from: null, + last_page: 1, + per_page: 10, + to: null, + total: 0, + total_no_filter: 0, + }, + }, + }).as("roomMeetingSummariesRequest"); + + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summary-item"]').should("not.exist"); + cy.contains("rooms.meeting_summaries.nodata").should("be.visible"); + }); + + it("load meeting summaries as room member", function () { + cy.fixture("room.json").then((room) => { + room.data.owner = { id: 2, name: "Max Doe" }; + room.data.is_member = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="filter-dropdown"]').should("not.exist"); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .should("not.include.text", "rooms.recordings.access_types.owner") + .within(() => { + cy.get('[data-test="room-meeting-summary-document-hint"]').should( + "have.text", + "rooms.meeting_summaries.document_hint", + ); + cy.get('[data-test="room-meeting-summaries-edit-button"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summaries-delete-button"]').should( + "not.exist", + ); + }); + }); + + it("filter meeting summaries", function () { + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="filter-dropdown-items"]').should("not.exist"); + cy.get('[data-test="filter-dropdown"]') + .should("have.text", "rooms.recordings.filter.all") + .click(); + + cy.get('[data-test="filter-dropdown-items"]') + .should("be.visible") + .within(() => { + cy.get("[data-test=filter-dropdown-option]").should("have.length", 5); + cy.get("[data-test=filter-dropdown-option]") + .eq(3) + .should("have.text", "rooms.recordings.filter.moderator_access") + .click(); + }); + + cy.wait("@roomMeetingSummariesRequest").then((interception) => { + expect(interception.request.query).to.contain({ + page: "1", + filter: "moderator_access", + }); + }); + }); + + it("load meeting summaries errors", function () { + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("roomMeetingSummariesRequest"); + + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + + cy.get('[data-test="room-meeting-summary-item"]').should("not.exist"); + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + fixture: "roomMeetingSummaries.json", + }).as("roomMeetingSummariesRequest"); + + cy.get('[data-test="loading-retry-button"]') + .should("be.visible") + .and("have.text", "app.reload") + .click(); + + cy.wait("@roomMeetingSummariesRequest"); + cy.get('[data-test="room-meeting-summary-item"]').should("have.length", 2); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewMeetingSummariesActions.cy.js b/tests/Frontend/e2e/RoomsViewMeetingSummariesActions.cy.js new file mode 100644 index 0000000000..0de1a0d708 --- /dev/null +++ b/tests/Frontend/e2e/RoomsViewMeetingSummariesActions.cy.js @@ -0,0 +1,406 @@ +import { interceptIndefinitely } from "../support/utils/interceptIndefinitely.js"; + +describe("Rooms view meeting summaries actions", function () { + beforeEach(function () { + cy.init(); + cy.interceptRoomViewRequests(); + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + fixture: "roomMeetingSummaries.json", + }).as("roomMeetingSummariesRequest"); + + cy.fixture("config.json").then((config) => { + config.data.general.base_url = Cypress.config("baseUrl"); + config.data.recap = { enabled: true }; + + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + + cy.setValidRememberedParticipantName("Laura Rivera"); + }); + + it("download meeting summary", function () { + const downloadRequest = interceptIndefinitely( + "GET", + "api/v1/rooms/abc-def-123/meetingSummaries/2/download*", + { + statusCode: 200, + headers: { + "content-type": "text/markdown; charset=utf-8", + "content-disposition": + "attachment; filename=meeting-summary-abc-def-123-2022-08-16-1000.md", + }, + body: "# Summary\n\n- Item\n", + }, + "downloadRequest", + ); + + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(1) + .find('[data-test="room-meeting-summaries-download-button"]') + .should( + "have.attr", + "aria-label", + 'rooms.meeting_summaries.download_aria_{"date":"08/16/2022, 10:00"}', + ) + .click(); + + // Check loading + cy.get('[data-test="room-meeting-summary-item"]') + .eq(1) + .find('[data-test="room-meeting-summaries-download-button"]') + .should("be.disabled") + .then(() => { + downloadRequest.sendResponse(); + }); + + cy.wait("@downloadRequest"); + + cy.readFile( + "tests/Frontend/downloads/meeting-summary-abc-def-123-2022-08-16-1000.md", + ).should("eq", "# Summary\n\n- Item\n"); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(1) + .find('[data-test="room-meeting-summaries-download-button"]') + .should("not.be.disabled"); + }); + + it("download meeting summary errors", function () { + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + // Summary was deleted in the meantime + cy.intercept( + "GET", + "api/v1/rooms/abc-def-123/meetingSummaries/2/download*", + { + statusCode: 404, + body: { + message: "model_not_found", + model: "meeting_summary", + ids: [2], + }, + }, + ).as("downloadRequest"); + + cy.fixture("roomMeetingSummaries.json").then((summaries) => { + summaries.data = summaries.data.slice(0, 1); + summaries.meta.to = 1; + summaries.meta.total = 1; + summaries.meta.total_no_filter = 1; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: summaries, + }).as("roomMeetingSummariesRequest"); + }); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(1) + .find('[data-test="room-meeting-summaries-download-button"]') + .click(); + + cy.wait("@downloadRequest"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.checkToastMessage("rooms.meeting_summaries.gone"); + cy.get('[data-test="room-meeting-summary-item"]').should("have.length", 1); + + // Server error + cy.fixture("roomMeetingSummaries.json").then((summaries) => { + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: summaries, + }).as("roomMeetingSummariesRequest"); + }); + cy.get('[data-test="room-meeting-summaries-reload-button"]').click(); + cy.wait("@roomMeetingSummariesRequest"); + + cy.intercept( + "GET", + "api/v1/rooms/abc-def-123/meetingSummaries/2/download*", + { + statusCode: 500, + body: { + message: "Test", + }, + }, + ).as("downloadRequest"); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(1) + .find('[data-test="room-meeting-summaries-download-button"]') + .click(); + + cy.wait("@downloadRequest"); + + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + }); + + it("edit meeting summary access", function () { + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summaries-edit-dialog"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .find('[data-test="room-meeting-summaries-edit-button"]') + .click(); + + const editRequest = interceptIndefinitely( + "PUT", + "api/v1/rooms/abc-def-123/meetingSummaries/1", + { + statusCode: 200, + body: { data: {} }, + }, + "editRequest", + ); + + cy.fixture("roomMeetingSummaries.json").then((summaries) => { + summaries.data[0].access = 2; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: summaries, + }).as("roomMeetingSummariesRequest"); + }); + + cy.get('[data-test="room-meeting-summaries-edit-dialog"]') + .should("be.visible") + .and("include.text", "rooms.meeting_summaries.modals.edit.title") + .within(() => { + cy.get('[data-test="access-field"]') + .should("include.text", "rooms.recordings.access") + .within(() => { + cy.get("#summary-access-3").should("be.checked"); + cy.get('[data-test="access-2-field"]') + .should("include.text", "rooms.recordings.access_types.moderator") + .find("#summary-access-2") + .click(); + }); + + cy.get('[data-test="dialog-save-button"]').click(); + + // Check loading + cy.get('[data-test="dialog-cancel-button"]') + .should("be.disabled") + .then(() => { + editRequest.sendResponse(); + }); + }); + + cy.wait("@editRequest").then((interception) => { + expect(interception.request.body).to.eql({ access: 2 }); + }); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summaries-edit-dialog"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .should("include.text", "rooms.recordings.access_types.moderator"); + }); + + it("edit meeting summary access errors", function () { + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .find('[data-test="room-meeting-summaries-edit-button"]') + .click(); + + // Validation error + cy.intercept("PUT", "api/v1/rooms/abc-def-123/meetingSummaries/1", { + statusCode: 422, + body: { + message: "The access field is required.", + errors: { + access: ["The access field is required."], + }, + }, + }).as("editRequest"); + + cy.get('[data-test="room-meeting-summaries-edit-dialog"]') + .find('[data-test="dialog-save-button"]') + .click(); + cy.wait("@editRequest"); + + cy.get('[data-test="room-meeting-summaries-edit-dialog"]') + .should("be.visible") + .and("include.text", "The access field is required."); + + // Summary was deleted in the meantime + cy.intercept("PUT", "api/v1/rooms/abc-def-123/meetingSummaries/1", { + statusCode: 404, + body: { + message: "model_not_found", + model: "meeting_summary", + ids: [1], + }, + }).as("editRequest"); + + cy.fixture("roomMeetingSummaries.json").then((summaries) => { + summaries.data = summaries.data.slice(1, 2); + summaries.meta.to = 1; + summaries.meta.total = 1; + summaries.meta.total_no_filter = 1; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: summaries, + }).as("roomMeetingSummariesRequest"); + }); + + cy.get('[data-test="room-meeting-summaries-edit-dialog"]') + .find('[data-test="dialog-save-button"]') + .click(); + cy.wait("@editRequest"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.checkToastMessage("rooms.meeting_summaries.gone"); + cy.get('[data-test="room-meeting-summaries-edit-dialog"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summary-item"]').should("have.length", 1); + }); + + it("delete meeting summary", function () { + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summaries-delete-dialog"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .find('[data-test="room-meeting-summaries-delete-button"]') + .click(); + cy.get('[data-test="room-meeting-summaries-delete-dialog"]') + .should("be.visible") + .and("include.text", "rooms.meeting_summaries.modals.delete.title") + .and("include.text", "rooms.meeting_summaries.modals.delete.confirm"); + + const deleteRequest = interceptIndefinitely( + "DELETE", + "api/v1/rooms/abc-def-123/meetingSummaries/1", + { + statusCode: 204, + }, + "deleteRequest", + ); + + cy.fixture("roomMeetingSummaries.json").then((summaries) => { + summaries.data = summaries.data.slice(1, 2); + summaries.meta.to = 1; + summaries.meta.total = 1; + summaries.meta.total_no_filter = 1; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: summaries, + }).as("roomMeetingSummariesRequest"); + }); + + cy.get('[data-test="room-meeting-summaries-delete-dialog"]') + .find('[data-test="dialog-continue-button"]') + .should("have.text", "app.yes") + .click(); + + // Check loading + cy.get('[data-test="room-meeting-summaries-delete-dialog"]') + .find('[data-test="dialog-cancel-button"]') + .should("have.text", "app.no") + .should("be.disabled") + .then(() => { + deleteRequest.sendResponse(); + }); + + cy.wait("@deleteRequest"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summary-item"]').should("have.length", 1); + cy.get('[data-test="room-meeting-summaries-delete-dialog"]').should( + "not.exist", + ); + }); + + it("delete meeting summary errors", function () { + cy.visit("/rooms/abc-def-123#tab=meeting_summaries"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.get('[data-test="room-meeting-summary-item"]') + .eq(0) + .find('[data-test="room-meeting-summaries-delete-button"]') + .click(); + + // Server error + cy.intercept("DELETE", "api/v1/rooms/abc-def-123/meetingSummaries/1", { + statusCode: 500, + body: { + message: "Test", + }, + }).as("deleteRequest"); + + cy.get('[data-test="room-meeting-summaries-delete-dialog"]') + .find('[data-test="dialog-continue-button"]') + .click(); + cy.wait("@deleteRequest"); + + cy.checkToastMessage([ + 'app.flash.server_error.message_{"message":"Test"}', + 'app.flash.server_error.error_code_{"statusCode":500}', + ]); + cy.get('[data-test="room-meeting-summaries-delete-dialog"]').should( + "be.visible", + ); + + // Summary was deleted in the meantime + cy.intercept("DELETE", "api/v1/rooms/abc-def-123/meetingSummaries/1", { + statusCode: 404, + body: { + message: "model_not_found", + model: "meeting_summary", + ids: [1], + }, + }).as("deleteRequest"); + + cy.fixture("roomMeetingSummaries.json").then((summaries) => { + summaries.data = summaries.data.slice(1, 2); + summaries.meta.to = 1; + summaries.meta.total = 1; + summaries.meta.total_no_filter = 1; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/meetingSummaries*", { + statusCode: 200, + body: summaries, + }).as("roomMeetingSummariesRequest"); + }); + + cy.get('[data-test="room-meeting-summaries-delete-dialog"]') + .find('[data-test="dialog-continue-button"]') + .click(); + cy.wait("@deleteRequest"); + cy.wait("@roomMeetingSummariesRequest"); + + cy.checkToastMessage("rooms.meeting_summaries.gone"); + cy.get('[data-test="room-meeting-summaries-delete-dialog"]').should( + "not.exist", + ); + cy.get('[data-test="room-meeting-summary-item"]').should("have.length", 1); + }); +}); diff --git a/tests/Frontend/e2e/RoomsViewMeetings.cy.js b/tests/Frontend/e2e/RoomsViewMeetings.cy.js index d096999bbf..76c97b2a40 100644 --- a/tests/Frontend/e2e/RoomsViewMeetings.cy.js +++ b/tests/Frontend/e2e/RoomsViewMeetings.cy.js @@ -421,6 +421,128 @@ describe("Rooms view meetings", function () { ); }); + it("join running meeting with meeting summary", function () { + cy.fixture("room.json").then((room) => { + room.data.last_meeting = { + start: "2023-08-21T08:18:28.000000Z", + end: null, + }; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.intercept("OPTIONS", "api/v1/rooms/abc-def-123/join", { + statusCode: 200, + body: { + data: { + features: { + recording: false, + recap: true, + attendance_recording: false, + streaming: false, + }, + }, + }, + }).as("preJoinRequest"); + + cy.intercept("POST", "/api/v1/rooms/abc-def-123/join*", { + statusCode: 200, + body: { + url: `${Cypress.expose("redirectBaseUrl")}/bigbluebutton?foo=a&bar=b`, + }, + }).as("joinRequest"); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.get('[data-test="room-join-button"]').click(); + + // Check that the consent for the meeting summary is shown, without the video consent + cy.get('[data-test="room-join-dialog"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.recap_info").should("be.visible"); + cy.contains("rooms.recap_accept").should("be.visible"); + cy.contains("rooms.recording_hint").should("be.visible"); + cy.contains("rooms.recording_info").should("not.exist"); + cy.contains("rooms.recording_video_accept").should("not.exist"); + cy.get("#record-video-agreement").should("not.exist"); + + cy.get("#record-agreement").should("not.be.checked").click(); + cy.get('[data-test="dialog-continue-button"]').click(); + }); + + cy.wait("@preJoinRequest"); + + // Check that correct query is sent + cy.wait("@joinRequest").then((interception) => { + expect(interception.request.body).to.eql({ + name: null, + consent_record_attendance: false, + consent_record: true, + consent_record_video: false, + consent_streaming: false, + dark_mode: false, + }); + }); + + // Check if redirect worked + cy.url().should( + "eq", + `${Cypress.expose("redirectBaseUrl")}/bigbluebutton?foo=a&bar=b`, + ); + }); + + it("join running meeting with recording and meeting summary", function () { + cy.fixture("room.json").then((room) => { + room.data.last_meeting = { + start: "2023-08-21T08:18:28.000000Z", + end: null, + }; + room.data.record = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.intercept("OPTIONS", "api/v1/rooms/abc-def-123/join", { + statusCode: 200, + body: { + data: { + features: { + recording: true, + recap: true, + attendance_recording: false, + streaming: false, + }, + }, + }, + }).as("preJoinRequest"); + + cy.visit("/rooms/abc-def-123"); + + cy.wait("@roomRequest"); + + cy.get('[data-test="room-join-button"]').click(); + + // Check that the combined consent is shown, with the video consent + cy.get('[data-test="room-join-dialog"]') + .should("be.visible") + .within(() => { + cy.contains("rooms.recording_recap_info").should("be.visible"); + cy.contains("rooms.recording_recap_accept").should("be.visible"); + cy.contains("rooms.recording_video_accept").should("be.visible"); + cy.get("#record-agreement").should("not.be.checked"); + cy.get("#record-video-agreement").should("not.be.checked"); + }); + }); + it("join running meeting guests", function () { cy.intercept("GET", "api/v1/currentUser", {}); diff --git a/tests/Frontend/e2e/RoomsViewSettings.cy.js b/tests/Frontend/e2e/RoomsViewSettings.cy.js index fdf99e0595..fa726a1fd3 100644 --- a/tests/Frontend/e2e/RoomsViewSettings.cy.js +++ b/tests/Frontend/e2e/RoomsViewSettings.cy.js @@ -891,6 +891,96 @@ describe("Rooms view settings", function () { .and("not.be.disabled"); }); + it("meeting summary setting", function () { + cy.fixture("config.json").then((config) => { + config.data.general.base_url = Cypress.config("baseUrl"); + config.data.recap = { enabled: true }; + + cy.intercept("GET", "api/v1/config", { + statusCode: 200, + body: config, + }); + }); + + cy.fixture("roomSettings.json").then((roomSettings) => { + roomSettings.data.recap = false; + roomSettings.data.recap_available = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/settings", { + statusCode: 200, + body: roomSettings, + }).as("roomSettingsRequest"); + + cy.visit("/rooms/abc-def-123#tab=settings"); + cy.wait("@roomSettingsRequest"); + + // Room owner can enable the meeting summary + cy.contains("rooms.settings.recap.title").should("be.visible"); + cy.get('[data-test="room-setting-recap"]') + .should("include.text", "rooms.settings.recordings.recap") + .and("not.include.text", "rooms.settings.recordings.recap_unavailable") + .find("#room-setting-recap") + .should("not.be.checked") + .and("not.be.disabled") + .click(); + + const newRoomSettings = structuredClone(roomSettings); + newRoomSettings.data.recap = true; + + cy.intercept("PUT", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: newRoomSettings, + }).as("roomSettingsSaveRequest"); + }); + + cy.get('[data-test="room-settings-save-button"]').click(); + + cy.wait("@roomSettingsSaveRequest").then((interception) => { + expect(interception.request.body.recap).to.be.true; + }); + + cy.get("#room-setting-recap").should("be.checked"); + + // Room owner has not logged in via OpenID Connect yet + cy.fixture("roomSettings.json").then((roomSettings) => { + roomSettings.data.recap = false; + roomSettings.data.recap_available = false; + + cy.intercept("GET", "api/v1/rooms/abc-def-123/settings", { + statusCode: 200, + body: roomSettings, + }).as("roomSettingsRequest"); + }); + + cy.reload(); + cy.wait("@roomSettingsRequest"); + + cy.get('[data-test="room-setting-recap"]') + .should("include.text", "rooms.settings.recordings.recap_unavailable") + .find("#room-setting-recap") + .should("be.disabled"); + + // Co-owners cannot change the setting + cy.fixture("room.json").then((room) => { + room.data.owner = { id: 2, name: "Max Doe" }; + room.data.is_member = true; + room.data.is_co_owner = true; + + cy.intercept("GET", "api/v1/rooms/abc-def-123", { + statusCode: 200, + body: room, + }).as("roomRequest"); + }); + + cy.reload(); + cy.wait("@roomRequest"); + cy.wait("@roomSettingsRequest"); + + cy.get('[data-test="room-setting-allow_guests"]').should("be.visible"); + cy.contains("rooms.settings.recap.title").should("not.exist"); + cy.get('[data-test="room-setting-recap"]').should("not.exist"); + }); + it("change settings", function () { cy.fixture("roomTypesWithSettings.json").then((roomTypes) => { cy.fixture("roomSettings.json").then((roomSettings) => { diff --git a/tests/Frontend/fixtures/roomMeetingSummaries.json b/tests/Frontend/fixtures/roomMeetingSummaries.json new file mode 100644 index 0000000000..bd6cf2b582 --- /dev/null +++ b/tests/Frontend/fixtures/roomMeetingSummaries.json @@ -0,0 +1,33 @@ +{ + "data": [ + { + "id": 1, + "model_name": "MeetingSummary", + "start": "2022-08-17T09:20:35.000000Z", + "end": "2022-08-17T09:40:52.000000Z", + "delivered_at": "2022-08-17T09:55:00.000000Z", + "access": 3, + "type": "document", + "document_url": "https://docs.example.com/docs/0b6b7c7e-5d3c-4c1e-9a43-3f0c2f6d9a11/" + }, + { + "id": 2, + "model_name": "MeetingSummary", + "start": "2022-08-16T08:00:00.000000Z", + "end": "2022-08-16T09:00:00.000000Z", + "delivered_at": "2022-08-16T09:20:00.000000Z", + "access": 1, + "type": "content", + "document_url": null + } + ], + "meta": { + "current_page": 1, + "from": 1, + "last_page": 1, + "per_page": 2, + "to": 2, + "total": 2, + "total_no_filter": 2 + } +} diff --git a/tests/Frontend/fixtures/roomType.json b/tests/Frontend/fixtures/roomType.json index e8f99172a9..ab3d60b3fa 100644 --- a/tests/Frontend/fixtures/roomType.json +++ b/tests/Frontend/fixtures/roomType.json @@ -53,6 +53,10 @@ "record_enforced": false, "auto_start_recording_default": false, "auto_start_recording_enforced": false, + "recap_default": false, + "recap_enforced": false, + "recap_type": null, + "recap_sink": null, "has_access_code_default": true, "has_access_code_enforced": false } From e02ab848e78b1d2fa19580c7beb5b226e0b266e3 Mon Sep 17 00:00:00 2001 From: timo Date: Thu, 12 Nov 2026 17:38:12 +0100 Subject: [PATCH 4/4] Add documentation and changelog entry for meeting summaries --- CHANGELOG.md | 2 + .../08-advanced/10-meeting-summaries.md | 179 ++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 docs/docs/administration/08-advanced/10-meeting-summaries.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f10a2fcf64..4ccde308b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Option to enforce light or dark color mode ([#3557]) - Popover to show dial-in number and pin during a running meeting ([#1143], [#1810]) - Option to disable recordings using the `RECORDING_ENABLED` environment variable ([#3633], [#3635]) +- Experimental AI meeting summaries using an external summary service, opted in by the room owner and configured per room type +- Meeting summaries tab in rooms to open, download, change access to and delete the summaries of past meetings ### Changed diff --git a/docs/docs/administration/08-advanced/10-meeting-summaries.md b/docs/docs/administration/08-advanced/10-meeting-summaries.md new file mode 100644 index 0000000000..1e0c585b09 --- /dev/null +++ b/docs/docs/administration/08-advanced/10-meeting-summaries.md @@ -0,0 +1,179 @@ +--- +title: Meeting summaries +description: Guide to setting up AI meeting summaries with an external summary service +--- + +:::note + +This is a new experimental feature and therefore not enabled by default. + +::: + +## Introduction + +PILOS can ask an external meeting summary service to transcribe and summarize meetings. +An open source summary service with this interface is [bbb-recap](https://github.com/virtUOS/bbb-recap); it also provides the recording exporter for the BigBlueButton servers. +The summary is delivered to the room owner by the summary service, for example as a document in a document editor. +PILOS itself does not process the recording; it only marks the meeting at BigBlueButton and tells the summary service who the owner is. +Meeting summaries do not require the recording setting of the room. + +When a meeting starts in a room with meeting summaries enabled, PILOS: + +1. sends `record=true` to BigBlueButton, even if the recording of the video conference is disabled for the room (BigBlueButton only exports meetings with recording marks), +2. adds the meta parameters `meta_-v=1`, `meta_-enabled=true`, `meta_-type` and `meta_-sink` to the BigBlueButton `create` call, +3. stores the internal meeting ID returned by BigBlueButton (the ID of the later recording), +4. registers the room owner with the summary service in a queued job (`PUT /api/v1/registrations/{internal meeting id}`). + +The BigBlueButton server needs a recording exporter that sends the raw recordings of these meetings to the summary service. +Only meetings with both the meta parameters and a registration are summarized. + +When a room is deleted, PILOS cancels the registrations of its meetings in a queued job (`DELETE /api/v1/registrations/{internal meeting id}`). +A summary that has already been delivered is not withdrawn; it belongs to the owner. +Transferring the room ownership does not change existing registrations: the summary goes to the owner at the time the meeting was started. + +## Requirements + +- The summary service is reachable from PILOS, and a bearer token for this PILOS instance is set up there. +- Users log in via [OpenID Connect](./01-external-authentication.md). The summary service identifies the owner by the OpenID Connect subject (`sub`), which PILOS stores at each OpenID Connect login. + The meeting summary setting is unavailable to a room owner until they have logged in via OpenID Connect once. +- The queue workers (Horizon) are running, as registrations are sent by queued jobs. + +## Setup + +### 1. Configure PILOS + +Enable meeting summaries by adding the following environment variables to the `.env` file: + +```shell +RECAP_ENABLED=true +RECAP_SERVICE_URL=https://recap.domain.tld +RECAP_FRONTEND_TOKEN="token-of-this-pilos-instance" +``` + +- `RECAP_SERVICE_URL` is the base URL of the summary service; if the API is in a subdirectory, include the full path. +- The feature stays disabled unless `RECAP_ENABLED`, `RECAP_SERVICE_URL` and `RECAP_FRONTEND_TOKEN` are all set. +- `RECAP_META_PREFIX` must be the same prefix as configured in the recording exporter on the BigBlueButton servers. + It must be a lowercase letter followed by 1-15 lowercase letters or digits; an invalid prefix disables the feature and logs a warning. + +### 2. Configure room types + +Meeting summaries are configured per room type in the admin UI: + +- **Create a meeting summary (AI)**: Default value of the room setting, and whether it is enforced. A room type can enforce meeting summaries off, but it cannot enforce them on. +- **Meeting type**: Name of the meeting type at the summary service, which selects the summary template (e.g. `meeting-summary`). +- **Summary destination**: Name of the sink profile at the summary service the summaries are delivered to (e.g. `docs-main`). + +Both names consist of lowercase letters, digits and hyphens and must be configured at the summary service. +Meetings in rooms of a room type without meeting type or destination are never summarized. + +Custom create parameters of a room type must not contain `meta_-*` parameters, so a room type cannot opt rooms in. + +### 3. Room setting + +The room owner, and only the room owner, can enable **Create a meeting summary (AI)** in the **Meeting summary (AI)** section of the room settings. +Co-owners and administrators cannot change it. + +A meeting is summarized only if, when it starts: + +- the feature is enabled, +- the room owner has an OpenID Connect subject, +- the room setting is enabled (and not enforced off by the room type), +- the room type has a meeting type and a summary destination. + +The recording setting of the room is not one of these conditions. + +Moderators decide which parts of the meeting are summarized: they start and stop the capture with the record button of BigBlueButton. +**Automatic recording start** keeps the value of the room setting, also in meetings with a summary only. +Without recording marks, BigBlueButton does not export the meeting and no summary is created. + +### Meetings with a summary but without recording + +If the room has meeting summaries enabled but the recording of the video conference disabled: + +- The camera video of the participants is never recorded; PILOS does not ask for the consent to record the own video. +- PILOS does not import the playback recording of the meeting. BigBlueButton still creates it, as the meeting is recorded for the summary service, + but when the recording is imported, PILOS deletes it from the spool directory without storing it and logs one info line with the meeting ID. + Participants never see a recording nobody asked for. + +Meetings with both recording and meeting summary enabled are recorded and imported as before. + +## Consent + +Participants give one consent before starting or joining a meeting with recording or meeting summary; PILOS refuses the request without it. +The text depends on the meeting: + +| Meeting | Texts | Default (English) | +| -------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Summary only | `rooms.recap_info`, `rooms.recap_accept` | An AI may transcribe and summarize the audio of this meeting. No recording is published. / I consent to the transcription and AI summary of the audio. | +| Recording and summary | `rooms.recording_recap_info`, `rooms.recording_recap_accept` | This room may be recorded, and an AI may transcribe and summarize the audio. / I consent to the recording and to the transcription and AI summary of the audio. | +| Recording only (unchanged) | `rooms.recording_info`, `rooms.recording_accept` | This room may be recorded. / I consent to the recording. | + +The hint `rooms.recording_hint` (mute the microphone to avoid being recorded) is shown in all three cases. +The optional consent to record the own video (`rooms.recording_video_accept`) is only asked in meetings with recording. + +Customize the texts as described in [Locales](../09-customisation/02-locales.md), for example to name the summary service or the data protection notice: + +```php +'recap_info' => 'The audio of this meeting may be transcribed and summarized by an AI service of the university. No recording is published.', +``` + +## Meeting summaries tab + +After a meeting with a meeting summary ends, PILOS asks the summary service for the result in a queued job (`GET /api/v1/registrations/{internal meeting id}`). +PILOS notices the end through the signed meeting end callback of BigBlueButton (`meetingEndedURL`) or, if the callback does not arrive, through the server poll within about a minute. +It polls 2, 5, 10 and 30 minutes apart, then hourly, and stops when the result is stored, the registration is not found (404) or cancelled, the job failed or was not delivered, or 24 hours after the meeting end. +Network errors, HTTP 429 and HTTP 5xx count as "not yet" and are polled again on the same schedule; other client errors fail the job. + +The result is stored as one meeting summary per meeting and listed in the room tab **Meeting summaries**, newest first. +The tab is shown when meeting summaries are enabled or the room already has summaries. +Depending on the destination configured at the summary service, an entry is one of: + +- **Link to a document**, for example in [La Suite Docs](https://github.com/suitenumerique/docs). The document is created in the account of the room owner at the document service, and only people the owner shares it with there can open it. + Other room members see the entry, but the link only works for them after the owner has shared the document. The tab shows this hint next to the link; the owner sees a hint that the document opens in their own account. +- **Summary text** (destination type `frontend` at the summary service). PILOS fetches the text (`GET …/summary`), stores it, and then confirms the pickup (`DELETE …/summary`), so the summary service deletes its copy. + The text is available in the room as a Markdown file download (`meeting-summary--.md`); it is not displayed in the page. To read or edit a formatted summary, use a document destination. Texts larger than 2 MiB or not encoded in UTF-8 are not stored; the pickup is still confirmed. + +PILOS stores the first result of a meeting and then stops polling. If an administrator reruns the processing at the summary service after that, the new result is not transferred to PILOS and the stored meeting summary is not updated. + +Access works like for recordings: + +- Each summary has an access setting (everyone with access to the room, participants, moderators, or owner and co-owners). New summaries start with owner and co-owners only. +- The room owner, co-owners and users with the permission to manage all rooms can change the access and delete a summary. Users with the permission to view all rooms see all summaries. +- Summaries are deleted after the [recording retention period](./03-recording.md#max-retention-period) (application settings) by the `cleanup:recordings` command, with the room, or by the owner or a co-owner. + A summary is also deleted together with its meeting record in the meeting history, even before the retention period ends. + +## Data flow and privacy + +| Data | Sent to | Personal data | +| ------------------------------------------------------------------------- | --------------------------------------------- | ---------------------------------------------- | +| `meta_-*` parameters (version, opt-in, meeting type, destination) | BigBlueButton, part of the recording metadata | none; may be visible to meeting participants | +| Registration: meeting ID, internal meeting ID, owner `sub` and email | summary service | owner OpenID Connect subject and email address | +| Cancellation on room deletion: internal meeting ID | summary service | none | +| Result polling: internal meeting ID | summary service | none | +| Result: document link or summary text | from the summary service to PILOS | summary text: names and meeting content | + +- PILOS stores the OpenID Connect subject in the users table, and the meeting summary flag and the internal meeting ID in the meetings table. They are deleted with the user or the meeting. +- PILOS does not store the playback recording of a meeting with a summary but without recording; it deletes the spool file on import. +- The queued jobs contain only model IDs or the internal meeting ID, no subject or email. +- Logs contain only meeting and internal meeting IDs, HTTP status codes and problem types, never the subject, email or token. +- The summary text is stored in the PILOS database (`meeting_summaries` table), available for download according to its access setting, and deleted after the recording retention period, with the room, or by the owner or a co-owner. The document link points to the owner's document; deleting the entry in PILOS does not delete the document. +- The summary text is never written to the logs; logs contain the meeting and summary IDs and the text size only. +- How long the summary service keeps the registration, recording and summary is configured there. + +## Retries + +Registrations and cancellations are retried for up to one day (after 30 seconds, 60 seconds and then every 5 minutes) on network errors, HTTP 429 and HTTP 5xx. +Other client errors (e.g. 400, 401, 409) are logged with status and problem type, and the job fails without retry. +A late registration is accepted by the summary service. +A cancellation answered with 404 or with 409 `already-delivered` is final. + +## Configuration Options + +| Option | Default Value | Description | +| ------------------------------ | ------------- | ------------------------------------------------------------------------------------------------------ | +| `RECAP_ENABLED` | `false` | Enable meeting summaries (also requires `RECAP_SERVICE_URL` and `RECAP_FRONTEND_TOKEN`) | +| `RECAP_META_PREFIX` | `recap` | Prefix of the BigBlueButton meta parameters, must equal the prefix of the recording exporter | +| `RECAP_SERVICE_URL` | `null` | Base URL of the meeting summary service | +| `RECAP_FRONTEND_TOKEN` | `null` | Bearer token of this PILOS instance at the meeting summary service | +| `RECAP_SERVER_CONNECT_TIMEOUT` | `20` | Maximum time to wait to establish a connection to the meeting summary service | +| `RECAP_SERVER_TIMEOUT` | `10` | Maximum time to wait for a response of the meeting summary service, once the connection is established |