Skip to content

Commit

Permalink
Merge pull request #4800 from RoboJackets/josh/ral-surveys
Browse files Browse the repository at this point in the history
Add Google Form support to RALs
  • Loading branch information
JoshOldenburg authored Sep 8, 2024
2 parents 0951e7e + 9af1690 commit 7be74a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 2 additions & 3 deletions app/Models/RemoteAttendanceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ class RemoteAttendanceLink extends Model
* https://meet.google.com/<alpha and dashes>
* https://teams.microsoft.com/l/meetup-join/<alphanumeric, -, %, .>/<digits>
* https://gatech.zoom.us/j/<digits>
* https://forms.gle/<alphanumeric>
* 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.
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions app/Nova/Actions/CreateRemoteAttendanceLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tests/Unit/RemoteAttendanceLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7be74a0

Please sign in to comment.