Fix invitations for Gmail and number their updates properly
package / package (push) Successful in 1m45s

Gmail showed "Unable to load event", with no Yes / No / Maybe buttons,
for invitations to events with a Jitsi conference, and Google Calendar
wouldn't import them. The cause was the FEATURE=AUDIO,VIDEO parameter on
the CONFERENCE property: a bare CONFERENCE;VALUE=URI:<link> imports, so
that's all we write now. The LABEL parameter goes too.

The event's setters committed EDS's sequence after every change, so
moving an event's time around in the editor raised SEQUENCE each time,
and a new event's first invitation could go out at SEQUENCE 7. DTSTAMP
was never updated, so two updates with the same SEQUENCE looked alike
to the people invited.

gcal_event_prepare_to_save(), called by the manager just before creating
or updating an event, now starts new events at SEQUENCE 0, raises an
updated event's SEQUENCE at most once when its date, time or recurrence
changed, and sets DTSTAMP to the time of saving.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 08:59:35 -07:00
co-authored by Claude Opus 5.5
parent 9f16d1e3d1
commit 02975fa3f5
9 changed files with 141 additions and 41 deletions
+81 -5
View File
@@ -697,10 +697,10 @@ event_add_conference (void)
g_assert_null (gcal_event_dup_conference_url (event));
gcal_event_add_conference (event, ROOM_URL, "Jitsi");
gcal_event_add_conference (event, ROOM_URL);
/* Adding the same conference again doesn't duplicate it */
gcal_event_add_conference (event, ROOM_URL, "Jitsi");
gcal_event_add_conference (event, ROOM_URL);
url = gcal_event_dup_conference_url (event);
g_assert_cmpstr (url, ==, ROOM_URL);
@@ -717,8 +717,9 @@ event_add_conference (void)
g_assert_nonnull (strstr (string, "CONFERENCE;"));
g_assert_nonnull (strstr (string, "VALUE=URI"));
g_assert_nonnull (strstr (string, "FEATURE=AUDIO,VIDEO"));
g_assert_nonnull (strstr (string, "LABEL=Jitsi"));
/* Gmail can't load invitations with these */
g_assert_null (strstr (string, "FEATURE="));
g_assert_null (strstr (string, "LABEL="));
g_assert_nonnull (strstr (string, ":" ROOM_URL));
g_assert_null (strstr (strstr (string, "CONFERENCE;") + 1, "CONFERENCE;"));
@@ -781,7 +782,7 @@ event_copy_conferences (void)
event = create_event_for_string (STUB_EVENT, &error);
g_assert_no_error (error);
gcal_event_add_conference (event, ROOM_URL, "Jitsi");
gcal_event_add_conference (event, ROOM_URL);
g_assert_false (gcal_event_conferences_equal (event, with_conference));
/* Copying replaces the conferences, rather than adding to them */
@@ -798,6 +799,80 @@ event_copy_conferences (void)
/*********************************************************************************************************************/
#define STUB_EVENT_SEQUENCE "BEGIN:VEVENT\n" \
"SUMMARY:Stub event\n" \
"UID:example@uid\n" \
"DTSTAMP:19970114T170000Z\n" \
"SEQUENCE:3\n" \
"DTSTART:20180714T170000Z\n" \
"DTEND:20180715T035959Z\n" \
"END:VEVENT\n"
static gint64
get_dtstamp_unix (GcalEvent *event)
{
g_autoptr (ICalTime) dtstamp = NULL;
dtstamp = e_cal_component_get_dtstamp (gcal_event_get_component (event));
g_assert_nonnull (dtstamp);
return i_cal_time_as_timet (dtstamp);
}
static void
move_event (GcalEvent *event,
gint hours)
{
g_autoptr (GDateTime) start = g_date_time_add_hours (gcal_event_get_date_start (event), hours);
g_autoptr (GDateTime) end = g_date_time_add_hours (gcal_event_get_date_end (event), hours);
gcal_event_set_date_start (event, start);
gcal_event_set_date_end (event, end);
}
static void
event_prepare_to_save (void)
{
g_autoptr (GcalEvent) original = NULL;
g_autoptr (GcalEvent) edited = NULL;
g_autoptr (GcalEvent) renamed = NULL;
g_autoptr (GcalEvent) created = NULL;
g_autoptr (GError) error = NULL;
gint64 before;
original = create_event_for_string (STUB_EVENT_SEQUENCE, &error);
g_assert_no_error (error);
before = g_get_real_time () / G_USEC_PER_SEC;
/* Moving the time around in the editor only counts once */
edited = gcal_event_new_from_event (original);
move_event (edited, 1);
move_event (edited, 1);
move_event (edited, 1);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (edited)), ==, 3);
gcal_event_prepare_to_save (edited, FALSE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (edited)), ==, 4);
g_assert_cmpint (get_dtstamp_unix (edited), >=, before);
/* Renaming isn't a significant change, but the event is stamped anew */
renamed = gcal_event_new_from_event (original);
gcal_event_set_summary (renamed, "Renamed");
gcal_event_prepare_to_save (renamed, FALSE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (renamed)), ==, 3);
g_assert_cmpint (get_dtstamp_unix (renamed), >=, before);
/* A new event starts at 0, however much it was edited before saving */
created = gcal_event_new_from_event (original);
move_event (created, 2);
move_event (created, 2);
gcal_event_prepare_to_save (created, TRUE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (created)), ==, 0);
g_assert_cmpint (get_dtstamp_unix (created), >=, before);
}
/*********************************************************************************************************************/
gint
main (gint argc,
gchar *argv[])
@@ -825,6 +900,7 @@ main (gint argc,
g_test_add_func ("/event/conference/add", event_add_conference);
g_test_add_func ("/event/conference/remove", event_remove_conference);
g_test_add_func ("/event/conference/copy", event_copy_conferences);
g_test_add_func ("/event/prepare-to-save", event_prepare_to_save);
return g_test_run ();
}