我添加了与我的应用程序事件同步谷歌日历的功能。但问题是,每当活动参与者对谷歌日历事件做出回应时,活动组织者/创建者就会收到来自谷歌的电子邮件。我只想收到事件的创建/更新的电子邮件通知。我添加了notification_settings,并将event_response方法保留到空白中,但它没有工作。
CALENDAR_ID = 'primary'
CALENDAR_NOTIFIER = 'externalOnly'
gcal_event = client.insert_event(
CALENDAR_ID,
Google::Apis::CalendarV3::Event.new(gcal_event_params(gcal_event_attendees)),
send_updates: CALENDAR_NOTIFIER
)
-----------------------
// added notification_settings later so that the organizer should not receive event response, but no luck so far.
def gcal_event_params(gcal_event_attendees)
{
summary: event.name,
description: event.description,
location: event.location,
start: { date_time: event.start.to_datetime.to_s, time_zone: org_timezone },
end: { date_time: event.ends.to_datetime.to_s, time_zone: org_timezone },
attendees: gcal_event_attendees,
reminders: { use_default: true },
notification_settings: {
notifications: [
{type: 'event_creation', method: 'email'},
{type: 'event_change', method: 'email'},
{type: 'event_cancellation', method: 'email'},
{type: 'event_response', method: ''}
]
} }
end发布于 2020-01-21 11:31:26
答案:
事件创建、更改、取消和响应的通知设置是日历本身的设置,而不是日历的单个事件。notification_settings参数Events: insert不存在,这就是为什么它不能工作的原因。
更多资料:
我不太清楚您链接的博客作者是从哪里获取信息的,但是Calendar API的Events: insert方法没有这个参数。
在calendar.google.com的用户界面中,您可以在整个日历的设置页面中看到所引用的通知设置,而不是单个事件的通知设置:

对于单个事件,在创建事件时,可以使用sendUpdates参数指定在创建事件时应该通知的人(如果有人)。相同的参数作为Events: update方法的一部分存在,该方法允许您设置谁得到通知有关特定更改的信息。
如果希望为事件的创建、更改和取消设置通知,但不希望设置事件响应,则需要为日历本身设置此通知。然而,不幸的是,这并不是可以用API完成的,需要在用户界面本身中设置。
不幸的是,这意味着通过Calendar API您所要做的事情是不可能的。
特征请求:
如果您对此感兴趣,那么您可以让Google知道这是一个对Calendar API很重要的特性,并且您希望请求他们实现它。谷歌的问题跟踪器是开发人员报告问题和为他们的开发服务提出功能请求的地方。要为Calendar API提交特性请求的页面是这里。
参考文献:
https://stackoverflow.com/questions/59825132
复制相似问题