Skip to content

Commit f14e6f3

Browse files
feat: add agendaupdate for conference
Partially implements insanum#522 and insanum#550.
1 parent 719f85b commit f14e6f3

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

gcalcli/details.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
URL_PROPS = OrderedDict([('html_link', 'htmlLink'),
1818
('hangout_link', 'hangoutLink')])
19+
ENTRY_POINT_PROPS = OrderedDict([('conference_entry_point_type', 'entryPointType'),
20+
('conference_uri', 'uri')])
1921

2022

2123
def _valid_title(event):
@@ -156,7 +158,7 @@ def patch(cls, cal, event, fieldname, value):
156158
class Conference(Handler):
157159
"""Handler for videoconference and teleconference details."""
158160

159-
fieldnames = ['conference_entry_point_type', 'conference_uri']
161+
fieldnames = list(ENTRY_POINT_PROPS.keys())
160162

161163
@classmethod
162164
def get(cls, event):
@@ -169,7 +171,23 @@ def get(cls, event):
169171
# https://github.com/insanum/gcalcli/issues/533
170172
entry_point = data['entryPoints'][0]
171173

172-
return [entry_point['entryPointType'], entry_point['uri']]
174+
return [entry_point.get(prop, '')
175+
for prop in ENTRY_POINT_PROPS.values()]
176+
177+
@classmethod
178+
def patch(cls, cal, event, fieldname, value):
179+
if not value:
180+
return
181+
182+
prop = ENTRY_POINT_PROPS[fieldname]
183+
184+
data = event.setdefault('conferenceData', {})
185+
entry_points = data.setdefault('entryPoints', [])
186+
if not entry_points:
187+
entry_points.append({})
188+
189+
entry_point = entry_points[0]
190+
entry_point[prop] = value
173191

174192

175193
class Title(SingleFieldHandler):

gcalcli/gcal.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
EventTitle = namedtuple('EventTitle', ['title', 'color'])
4343

44+
CONFERENCE_DATA_VERSION = 1
4445

4546
class GoogleCalendarInterface:
4647

@@ -1248,6 +1249,7 @@ def AgendaUpdate(self, file=sys.stdin):
12481249
.patch(
12491250
calendarId=cal_id,
12501251
eventId=mod_event['id'],
1252+
conferenceDataVersion=CONFERENCE_DATA_VERSION,
12511253
body=mod_event
12521254
)
12531255
)

0 commit comments

Comments
 (0)