feat: add ooo-chat-app and schedule-meetings#387
feat: add ooo-chat-app and schedule-meetings#387PierrickVoulet merged 1 commit intogoogleworkspace:mainfrom
Conversation
Summary of ChangesHello @PierrickVoulet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the functionality of Google Chat by adding two new applications. The first app streamlines out-of-office management, allowing users to automate common OOO tasks like calendar blocking and auto-replies. The second app simplifies meeting scheduling, providing an intuitive interface to create calendar events directly from chat conversations. These additions enhance productivity by bringing essential calendar and email management tools into the chat environment. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces two new Google Chat apps: ooo-chat-app and schedule-meetings. The implementation is a good starting point, but I've identified several high-severity issues that need to be addressed. These include a significant correctness bug in meeting cancellation logic, use of magic numbers, a UI formatting bug due to a typo, use of a deprecated API field, and some dead code that could be misleading. Please see the detailed comments for suggestions on how to fix these issues.
| switch (message.slashCommand.commandId) { | ||
| case 1: // Help command | ||
| return createHelpCard(); | ||
| case 2: // Block out day command | ||
| return blockDayOut(); | ||
| case 3: // Cancel all meetings command | ||
| return cancelAllMeetings(); | ||
| case 4: // Set auto reply command | ||
| return setAutoReply(); | ||
| } |
There was a problem hiding this comment.
The switch statement uses magic numbers (1, 2, 3, 4) for commandId. This makes the code harder to read, maintain, and debug. It's better to define these as named constants.
For example, you could define an object for the commands at the top of the file:
const SLASH_COMMANDS = {
HELP: 1,
BLOCK_DAY_OUT: 2,
CANCEL_MEETINGS: 3,
SET_AUTO_REPLY: 4,
};And then use SLASH_COMMANDS.HELP, etc. in your switch statement. This pattern is already used in the schedule-meetings app and should be applied here for consistency and clarity.
| function cancelMeetings() { | ||
| const events = CalendarApp.getEventsForDay(new Date()); | ||
|
|
||
| for (const event of events) { | ||
| if (event.getGuestList().length > 0) { | ||
| event.setMyStatus(CalendarApp.GuestStatus.NO); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The function cancelMeetings is misleading. It only declines the user's attendance (setMyStatus(CalendarApp.GuestStatus.NO)), even for meetings they organize. This will not 'cancel' the meeting for other attendees; it will just show the organizer as not attending, which can be confusing.
To correctly 'cancel' a meeting the user owns, you should delete the event. For meetings where they are just an attendee, declining is the correct action. I suggest checking if the user is the event owner.
function cancelMeetings() {
const events = CalendarApp.getEventsForDay(new Date());
for (const event of events) {
if (event.getGuestList().length > 0) {
if (event.isOwnedByMe()) {
// If the user is the organizer, cancel the event for everyone.
event.deleteEvent();
} else {
// If the user is an attendee, just decline the invitation.
event.setMyStatus(CalendarApp.GuestStatus.NO);
}
}
}
}| } | ||
|
|
||
| // Lets users know what they can do and how they can get help. | ||
| message = `${message}/nI can quickly schedule a meeting for you with just a few clicks.Try me out by typing */schedule_Meeting*. /nTo learn what else I can do, type */help*.`; |
There was a problem hiding this comment.
There's a typo in the welcome message. You're using /n for newlines, which will be rendered literally in the chat message. To create a newline, you should use \n.
| message = `${message}/nI can quickly schedule a meeting for you with just a few clicks.Try me out by typing */schedule_Meeting*. /nTo learn what else I can do, type */help*.`; | |
| message = `${message}\nI can quickly schedule a meeting for you with just a few clicks.Try me out by typing */schedule_Meeting*. \nTo learn what else I can do, type */help*.`; |
| dialog_action: { | ||
| actionStatus: "OK", | ||
| }, |
There was a problem hiding this comment.
The dialog_action field is deprecated. You should use dialogAction instead to ensure future compatibility. The rest of the code in Dialog.js already uses the correct dialogAction field, so this change will also make the code consistent.
| dialog_action: { | |
| actionStatus: "OK", | |
| }, | |
| dialogAction: { | |
| actionStatus: "OK", | |
| }, |
| const [month, day, year] = parts[0].split("/").map(Number); | ||
| const [hour, minute] = parts[1].split(":").map(Number); | ||
|
|
||
| Session.getScriptTimeZone(); |
No description provided.