Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Send ical Notifications (Version 2) #623

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

paulandm
Copy link
Contributor

@paulandm paulandm commented Oct 1, 2024

A refactored / cleaned up version of the original PR for the Send ical notifications task.

  • The notifications are now based on the zoom event record (instead of the zoom record).

  • Was able to incorporate the 'zoom_helper_icalendar_event' function in the creation of the ical event.

  • The buffer of 10 minutes before sending out invites remain in place. The idea is still that an ical invite should only be sent once per Zoom event. Since we don't have access to the participants' calendars, we can't actually update already sent ical invites. So if we change the code to send ical invites for a Zoom activity edit action (after the 10 minute buffer period), it will send an additional ical invite instead of actually changing the previous one sent. This might be appropriate behavior for some, but it is not applicable in our use case. @jrchamp I'm happy to discuss some ideas around this 'update' scenario further if required.

  • The buffer period of 10 minutes could also potentially move out to a setting if preferred?

Add initial send ical notification changes.
Corrected Moodle styling errors.
Corrected function documentation.
Remove registration validation feature from this branch
Revert file to original state
Code cleanup of send_ical_notifications task
Base ical notifications task on zoom event ids
Move the ical invite buffer back to 10 minutes
Fix Moodle Code and PHPDoc Checker errors
Fix Moodle Code Checker warning
Add missing messageprovider string
Moodle 3.9 compatibility: Removed 'MESSAGE_DEFAULT_ENABLED' constant
Moodle 3.9 compatibility fixes.
db/upgrade.php Outdated Show resolved Hide resolved
@smbader smbader requested a review from jrchamp October 3, 2024 15:39
Move ical notifications table to new savepoint block
Update version number to match upgrade save point
Fix descriptions of zoom_ical_notifications table in the install file.
@jrchamp jrchamp added the enhancement Adds new functionality label Oct 10, 2024
Copy link
Collaborator

@jrchamp jrchamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @paulandm! Thank you for all your work on this. I had a few ideas that took a while to collect. I may have missed some things, so apologies if I have more comments later on items that were already present in this version of the code.

lang/en/zoom.php Show resolved Hide resolved
db/upgrade.php Outdated Show resolved Hide resolved
db/tasks.php Show resolved Hide resolved
db/install.xml Show resolved Hide resolved
classes/task/send_ical_notifications.php Outdated Show resolved Hide resolved
classes/task/send_ical_notifications.php Outdated Show resolved Hide resolved
classes/task/send_ical_notifications.php Outdated Show resolved Hide resolved
classes/task/send_ical_notifications.php Outdated Show resolved Hide resolved
classes/task/send_ical_notifications.php Outdated Show resolved Hide resolved
Comment on lines 205 to 214
if ($zoom->registration == ZOOM_REGISTRATION_OFF) {
$icalevent->add_property('location', $zoom->join_url);
} else {
$registrantjoinurl = zoom_get_registrant_join_url($user->email, $zoom->meeting_id, $zoom->webinar);
if ($registrantjoinurl) {
$icalevent->add_property('location', $registrantjoinurl);
} else {
$icalevent->add_property('location', $zoom->join_url);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of providing the stored join_url, it's probably better to send the user to the Moodle site's join URL. That way they won't circumvent the authentication/logging mechanisms or be left with an outdated/cached version of the URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrchamp Would it be a good idea if we maybe add a feature to the mod/zoom/view.php page to include a optional parameter like 'autojoin', so that the authenticated user is automatically forwarded to the zoom url?

Implement PR feedback
@paulandm
Copy link
Contributor Author

Implemented the PR feedback.

Implemented PR feedback
Copy link
Collaborator

@jrchamp jrchamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @paulandm! We'll take a closer look at this updated version during our next meeting. There are a few comments from last time, like the MySQL-specific SQL that will need to be addressed before it can be merged, but I'm excited to see the progress.

db/upgrade.php Outdated Show resolved Hide resolved
@@ -184,5 +184,17 @@
<KEY NAME="fk_breakoutroomid" TYPE="foreign" FIELDS="breakoutroomid" REFTABLE="zoom_meeting_breakout_rooms" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="zoom_ical_notifications" COMMENT="Identifies the zoom event for which ical notifications have been emailed.">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Generate this using XMLDB and export it using XMLDB. Check for differences.

Implemented PR Feedback related to DB
@paulandm
Copy link
Contributor Author

Thanks @jrchamp I've implemented some improvements related to DB compatibility and have simplified the keys of the table.

Comment on lines +173 to +177
$messagedata->subject = $zoomevent->name;
$messagedata->fullmessage = $zoomevent->description;
$messagedata->fullmessageformat = FORMAT_HTML;
$messagedata->fullmessagehtml = $zoomevent->description;
$messagedata->smallmessage = $zoomevent->name . ' - ' . $zoomevent->description;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to tester: Do we need to apply filters like in #615 so the messages reflect the displayed values for the activities? Do the event names and descriptions already have the post-processed value or do they need to have the filter applied? There is a helper function for the activity name, but testing would be needed to determine if the description gets automatically passed through filters or not or if we need to supply the context.

Comment on lines +168 to +169
$messagedata = new \core\message\message();
$messagedata->component = 'mod_zoom';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Compare to core Moodle to see if this is the recommended pattern for initializing the object.

Comment on lines +151 to +156
'contextid' => \context_user::instance($user->id)->id,
'component' => 'user',
'filearea' => 'draft',
'itemid' => file_get_unused_draft_itemid(),
'filepath' => '/',
'filename' => clean_filename('icalexport.ics'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: Determine if these is a concern about unique filenames. Do/should these files get cleaned up after use?

Comment on lines +143 to +146
// Check if user has "Disable notifications" set.
if ($user->emailstop) {
continue;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: Is emailstop intended to stop all messages or only emails? Are we supposed to be doing this check, or is this supposed to be handled by the messaging system itself?

Comment on lines +115 to +117
* @param string $zoomeventid The zoom event id.
*/
private function set_notification_executiontime(string $zoomeventid) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: I would fully expect this to be an integer. Maybe it depends on the database and PHP versions, but that would mean this will break on some systems. Probably best to cast as (int) before passing to this function and update the parameter types.

Comment on lines +100 to +103
* @param string $zoomeventid The zoom event id.
* @return string The timestamp of the last execution.
*/
private function get_notification_executiontime(string $zoomeventid) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: Same concern about parameter types (should probably cast to `(int)``)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds new functionality
Projects
Status: Testing needed
Status: No status
Development

Successfully merging this pull request may close these issues.

5 participants