From 247b89875b7646fba625ee631d6528cc02e6365b Mon Sep 17 00:00:00 2001 From: Josh Oldenburg Date: Sun, 8 Sep 2024 13:49:54 -0400 Subject: [PATCH 1/3] Add Google Form support to RALs --- app/Models/RemoteAttendanceLink.php | 5 ++--- app/Nova/Actions/CreateRemoteAttendanceLink.php | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Models/RemoteAttendanceLink.php b/app/Models/RemoteAttendanceLink.php index 31217539d..14fdd4cfc 100644 --- a/app/Models/RemoteAttendanceLink.php +++ b/app/Models/RemoteAttendanceLink.php @@ -76,12 +76,13 @@ class RemoteAttendanceLink extends Model * https://meet.google.com/ * https://teams.microsoft.com/l/meetup-join// * https://gatech.zoom.us/j/ + * https://forms.gle/ * but nothing else, to avoid users redirecting to surprising things. * * @phan-suppress PhanReadOnlyPublicProperty */ public static string $redirectRegex = '/^(https?:\/\/)?(meet\.google\.com\/[-a-z]+|teams\.microsoft\.com\/l\/' - .'meetup-join\/[-a-zA-Z0-9%\._]+\/[0-9]+|gatech\.zoom\.us\/j\/[0-9]+)(\?[^@]*)?$/'; + .'meetup-join\/[-a-zA-Z0-9%\._]+\/[0-9]+|gatech\.zoom\.us\/j\/[0-9]+|forms\.gle\/[a-zA-Z0-9])(\?[^@]*)?$/'; /** * Get the attributes that should be cast. @@ -100,8 +101,6 @@ protected function casts(): array */ public static function normalizeRedirectUrl(string $url): string { - $url = Str::lower($url); - if (Str::startsWith($url, 'https://')) { return $url; } diff --git a/app/Nova/Actions/CreateRemoteAttendanceLink.php b/app/Nova/Actions/CreateRemoteAttendanceLink.php index 342ed438d..b77eedce7 100644 --- a/app/Nova/Actions/CreateRemoteAttendanceLink.php +++ b/app/Nova/Actions/CreateRemoteAttendanceLink.php @@ -87,11 +87,11 @@ public function fields(NovaRequest $request): array Text::make('Redirect URL') ->required(false) ->rules('nullable', 'regex:'.RemoteAttendanceLink::$redirectRegex, 'max:1023') - ->help('If you put a link to a Google Meet, Zoom, or Microsoft Teams meeting here, '. - 'everyone who clicks the attendance link will be redirected to that meeting after their '. + ->help('If you put a link to a Google Meet, Zoom, or Microsoft Teams meeting or a Google Forms short URL '. + 'here, everyone who clicks the attendance link will be redirected to that meeting after their '. 'attendance is recorded. If you add a redirect URL, do not share that URL directly. Only Google '. - 'Meet, Zoom, and Microsoft Teams calls are supported currently. Ask in #it-helpdesk for'. - ' other redirect URLs.'), + 'Meet, Zoom, and Microsoft Teams calls and Google Forms are supported currently. Ask in '. + '#it-helpdesk for other redirect URLs.'), Select::make('Purpose') ->required(true) From 8a855422dcda24a900d7a80ed23418724ba4093f Mon Sep 17 00:00:00 2001 From: Josh Oldenburg Date: Sun, 8 Sep 2024 13:53:02 -0400 Subject: [PATCH 2/3] Style --- app/Nova/Actions/CreateRemoteAttendanceLink.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Nova/Actions/CreateRemoteAttendanceLink.php b/app/Nova/Actions/CreateRemoteAttendanceLink.php index b77eedce7..55bed543e 100644 --- a/app/Nova/Actions/CreateRemoteAttendanceLink.php +++ b/app/Nova/Actions/CreateRemoteAttendanceLink.php @@ -87,8 +87,8 @@ public function fields(NovaRequest $request): array Text::make('Redirect URL') ->required(false) ->rules('nullable', 'regex:'.RemoteAttendanceLink::$redirectRegex, 'max:1023') - ->help('If you put a link to a Google Meet, Zoom, or Microsoft Teams meeting or a Google Forms short URL '. - 'here, everyone who clicks the attendance link will be redirected to that meeting after their '. + ->help('If you put a link to a Google Meet, Zoom, or Microsoft Teams meeting or a Google Forms short '. + 'URL here, everyone who clicks the attendance link will be redirected to that meeting after their '. 'attendance is recorded. If you add a redirect URL, do not share that URL directly. Only Google '. 'Meet, Zoom, and Microsoft Teams calls and Google Forms are supported currently. Ask in '. '#it-helpdesk for other redirect URLs.'), From 9af1690094ad4e9141547f5a1f54b80d1a680e05 Mon Sep 17 00:00:00 2001 From: Josh Oldenburg Date: Sun, 8 Sep 2024 13:56:11 -0400 Subject: [PATCH 3/3] Add gform test case --- tests/Unit/RemoteAttendanceLinkTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Unit/RemoteAttendanceLinkTest.php b/tests/Unit/RemoteAttendanceLinkTest.php index 4d47f4b18..a4188512a 100644 --- a/tests/Unit/RemoteAttendanceLinkTest.php +++ b/tests/Unit/RemoteAttendanceLinkTest.php @@ -63,6 +63,16 @@ public function testRedirectRegexZoom(): void $this->redirectRegexTestCase('gatech.zoom.us/j/12345?query@query', false); } + /** + * Test Google Form links. + */ + public function testRedirectRegexGoogleForm(): void + { + $this->redirectRegexTestCase('forms.gle/4PfXD3rUh8', true); + + $this->redirectRegexTestCase('forms.gle/4PfXD3rU&h8-', false); + } + private function redirectRegexTestCase(string $url, bool $expected): void { if ($expected) {