-
Notifications
You must be signed in to change notification settings - Fork 954
feat: support google meet video conferencing in calendar +insert #506
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
base: main
Are you sure you want to change the base?
Changes from all commits
346d692
1536057
7fd9916
8349a66
40f41d1
b57e843
22f54c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@googleworkspace/cli": minor | ||
| --- | ||
|
|
||
| feat: support google meet video conferencing in calendar +insert |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,14 +80,21 @@ impl Helper for CalendarHelper { | |
| .value_name("EMAIL") | ||
| .action(ArgAction::Append), | ||
| ) | ||
| .arg( | ||
| Arg::new("meet") | ||
| .long("meet") | ||
| .help("Add a Google Meet video conference link") | ||
| .action(ArgAction::SetTrue), | ||
| ) | ||
| .after_help("\ | ||
| EXAMPLES: | ||
| gws calendar +insert --summary 'Standup' --start '2026-06-17T09:00:00-07:00' --end '2026-06-17T09:30:00-07:00' | ||
| gws calendar +insert --summary 'Review' --start ... --end ... --attendee alice@example.com | ||
| gws calendar +insert --summary 'Meet' --start ... --end ... --meet | ||
|
|
||
| TIPS: | ||
| Use RFC3339 format for times (e.g. 2026-06-17T09:00:00-07:00). | ||
| For recurring events or conference links, use the raw API instead."), | ||
| The --meet flag automatically adds a Google Meet link to the event."), | ||
| ); | ||
| cmd = cmd.subcommand( | ||
| Command::new("+agenda") | ||
|
|
@@ -453,13 +460,28 @@ fn build_insert_request( | |
| body["attendees"] = json!(attendees_list); | ||
| } | ||
|
|
||
| let mut params = json!({ | ||
| "calendarId": calendar_id | ||
| }); | ||
|
|
||
| if matches.get_flag("meet") { | ||
| let namespace = uuid::Uuid::NAMESPACE_DNS; | ||
| let seed_data = format!("{}:{}:{}", summary, start, end); | ||
| let request_id = uuid::Uuid::new_v5(&namespace, seed_data.as_bytes()).to_string(); | ||
|
|
||
| body["conferenceData"] = json!({ | ||
| "createRequest": { | ||
| "requestId": request_id, | ||
| "conferenceSolutionKey": { "type": "hangoutsMeet" } | ||
| } | ||
| }); | ||
| params["conferenceDataVersion"] = json!(1); | ||
| } | ||
|
Comment on lines
+467
to
+479
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this PR successfully adds the To make this operation idempotent, generating a deterministic However, to avoid introducing changes outside the primary goal of this pull request and prevent scope creep, I recommend addressing this idempotency improvement in a separate, follow-up PR. This would involve updating the References
|
||
|
|
||
| let body_str = body.to_string(); | ||
| let scopes: Vec<String> = insert_method.scopes.iter().map(|s| s.to_string()).collect(); | ||
|
|
||
| // events.insert requires 'calendarId' path parameter | ||
| let params = json!({ | ||
| "calendarId": calendar_id | ||
| }); | ||
| let params_str = params.to_string(); | ||
|
|
||
| Ok((params_str, body_str, scopes)) | ||
|
|
@@ -497,7 +519,8 @@ mod tests { | |
| Arg::new("attendee") | ||
| .long("attendee") | ||
| .action(ArgAction::Append), | ||
| ); | ||
| ) | ||
| .arg(Arg::new("meet").long("meet").action(ArgAction::SetTrue)); | ||
| cmd.try_get_matches_from(args).unwrap() | ||
| } | ||
|
|
||
|
|
@@ -521,6 +544,59 @@ mod tests { | |
| assert_eq!(scopes[0], "https://scope"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_build_insert_request_with_meet() { | ||
| let doc = make_mock_doc(); | ||
| let matches = make_matches_insert(&[ | ||
| "test", | ||
| "--summary", | ||
| "Meeting", | ||
| "--start", | ||
| "2024-01-01T10:00:00Z", | ||
| "--end", | ||
| "2024-01-01T11:00:00Z", | ||
| "--meet", | ||
| ]); | ||
| let (params, body, _) = build_insert_request(&matches, &doc).unwrap(); | ||
|
|
||
| let params_json: serde_json::Value = serde_json::from_str(¶ms).unwrap(); | ||
| assert_eq!(params_json["conferenceDataVersion"], 1); | ||
|
|
||
| let body_json: serde_json::Value = serde_json::from_str(&body).unwrap(); | ||
| let create_req = &body_json["conferenceData"]["createRequest"]; | ||
| assert_eq!(create_req["conferenceSolutionKey"]["type"], "hangoutsMeet"); | ||
| assert!(uuid::Uuid::parse_str(create_req["requestId"].as_str().unwrap()).is_ok()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_build_insert_request_with_meet_is_idempotent() { | ||
| let doc = make_mock_doc(); | ||
| let args = &[ | ||
| "test", | ||
| "--summary", | ||
| "Idempotent Meeting", | ||
| "--start", | ||
| "2024-01-01T10:00:00Z", | ||
| "--end", | ||
| "2024-01-01T11:00:00Z", | ||
| "--meet", | ||
| ]; | ||
| let matches1 = make_matches_insert(args); | ||
| let (_, body1, _) = build_insert_request(&matches1, &doc).unwrap(); | ||
|
|
||
| let matches2 = make_matches_insert(args); | ||
| let (_, body2, _) = build_insert_request(&matches2, &doc).unwrap(); | ||
|
|
||
| let b1: serde_json::Value = serde_json::from_str(&body1).unwrap(); | ||
| let b2: serde_json::Value = serde_json::from_str(&body2).unwrap(); | ||
|
|
||
| assert_eq!( | ||
| b1["conferenceData"]["createRequest"]["requestId"], | ||
| b2["conferenceData"]["createRequest"]["requestId"], | ||
| "requestId should be deterministic for the same event details" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_build_insert_request_with_optional_fields() { | ||
| let doc = make_mock_doc(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The seed for the idempotent
requestIdonly includessummary,start, andend. This means that two different events with the same summary and time but different attendees, description, or location will generate the samerequestId. To ensure true idempotency and avoid potential collisions, it's better to include all relevant event details in the seed. I recommend includinglocation,description, and a sorted list ofattendeesin theseed_dataif they are provided.