我有一个可以在 Google 日历中正确生成事件的应用程序,现在我希望能够通过为其生成 Google 会议链接来修改任何事件。理想情况下,我想生成没有任何日历事件的 Google 会议链接,但据我研究,目前唯一的方法是将其创建为 Google 日历事件的一部分。
我已按照https://developers.google.com/calendar/create-events?hl=en_US#java中的步骤进行操作,并提出了以下功能:
(defn add-meet-link-to-calendar-event
"Adds a meet link to a calendar event."
[google-ctx calendarId input-event]
(if input-event
(let [calendar-service (build-calendar-service google-ctx)
events (doto (.events ^Calendar calendar-service)
assert)
conf-req-data (doto (CreateConferenceRequest.)
(.setRequestId (generate-random-string))
(.setConferenceSolutionKey (.setType (ConferenceSolutionKey.)
"hangoutsMeet")))
conference-data (doto (ConferenceData.)
(.setCreateRequest conf-req-data)
)
event (doto input-event
(.setConferenceData conference-data)
(.set "conferenceDataVersion" 1)
(.set "sendNotifications" true)
)
eventId (get event "id")
adding-link (.patch events calendarId eventId event)]
(prn "Before executing at add-meet-link-to-calendar-event" calendarId eventId event events)
(.execute adding-link))))
作为此函数的输入事件的一部分,我将从另一个函数传递以下输出,该函数从 Google 日历中检索事件对象:
{"attendees" [{"email" "jjj@company.com",
"responseStatus" "needsAction"}
{"email" "main@company.com",
"organizer" true,
"responseStatus" "accepted",
"self" true}],
"created" #object[com.google.api.client.util.DateTime 0x686d6e12 "2020-10-26T15:27:49.000Z"],
"creator" {"email" "main@company.com",
"self" true},
"end" {"dateTime" #object[com.google.api.client.util.DateTime 0x5a909950 "2020-10-24T22:30:00.000+02:00"]},
"etag" "\"3207454201190000\"",
"htmlLink" "https://www.google.com/calendar/event?eid=M25wb2RtbnNsNWN2N3E3MGVsc2RvYTQwc2ogbmFpaGFAdWJpa2FyZSAAAA",
"iCalUID" "3npodmnsl5cv7q70elsdoaAAAA@google.com",
"id" "3npodmnsl5cv7q70elsdoaAAAA",
"kind" "calendar#event",
"organizer" {"email" "main@company.com", "self" true},
"reminders" {"useDefault" true},
"sequence" 0,
"start" {"dateTime" #object[com.google.api.client.util.DateTime 0x7bcdfc0e "2020-10-24T22:00:00.000+02:00"]},
"status" "confirmed",
"summary" "Another meet test",
"updated" #object[com.google.api.client.util.DateTime 0xd4057 "2020-10-26T15:45:00.595Z"]}
我已经测试过summary
可以更新类似的值,因此patch
调用似乎有效。但即使添加conferenceDataVersion
和conferenceData
似乎也不会改变事件。
如果我手动更改 Google 日历中的事件,我可以看到会议详细信息已添加到事件中。