Add rotation ID fallback for ical events

This commit is contained in:
Matias Bordese 2022-09-06 15:33:58 -03:00
parent a8fd2d96e2
commit 1a133d33ff
2 changed files with 11 additions and 0 deletions

View file

@ -367,6 +367,9 @@ def parse_event_uid(string):
match = RE_EVENT_UID_V1.match(string)
if match:
_, _, _, source = match.groups()
else:
# fallback to use the UID string as the rotation ID
pk = string
if source is not None:
source = int(source)

View file

@ -78,3 +78,11 @@ def test_parse_event_uid_v2():
pk, source = parse_event_uid(event_uid)
assert pk == pk_value
assert source == "slack"
def test_parse_event_uid_fallback():
# use ical existing UID for imported events
event_uid = "someid@google.com"
pk, source = parse_event_uid(event_uid)
assert pk == event_uid
assert source is None