WPB-27553: add tzid to meetings - #5391
Conversation
ae662ab to
1f859e9
Compare
| {{- if .legacyTimeZone }} | ||
| legacyTimeZone: {{ .legacyTimeZone }} | ||
| {{- end }} |
There was a problem hiding this comment.
| {{- if .legacyTimeZone }} | |
| legacyTimeZone: {{ .legacyTimeZone }} | |
| {{- end }} | |
| legacyTimeZone: {{ .legacyTimeZone }} |
There is a default in the helm chart, so no need for this code.
| let startTime = addUTCTime 3600 now | ||
| endTime = addUTCTime 7200 now | ||
| newMeeting = defaultMeetingJson "MLS Meeting" startTime endTime [] | ||
| newMeeting = defaultMeetingJson "MLS Meeting" startTime "3600000000us" [] |
| durationToText :: Duration -> Text | ||
| durationToText (Duration d) = Text.pack (show (diffTimeToPicoseconds d `div` 1000000)) <> "us" |
There was a problem hiding this comment.
I think we should do better, most of the time this is going to be something like 1h, 30m, '5s' etc. So we should try to find the biggest unit that can represent the duration in a whole number.
| canonicalMeetingDuration :: Duration -> MeetingDuration | ||
| canonicalMeetingDuration d = unsafeMeetingDuration d (durationToText d) |
There was a problem hiding this comment.
Either we should unsafe to the name or add the check for positivity here.
| -- | A meeting duration that preserves the client-supplied literal alongside its | ||
| -- parsed value. 'parsed' drives equality/ordering/arithmetic; 'original' drives | ||
| -- serialization so a value read as @"1h"@ is shown/sent back as @"1h"@. | ||
| data MeetingDuration = MeetingDuration | ||
| { parsed :: Duration, | ||
| original :: Text | ||
| } | ||
| deriving stock (Generic) | ||
| deriving (ToJSON, FromJSON, S.ToSchema) via (Schema MeetingDuration) |
There was a problem hiding this comment.
Perhaps we can use DurationLiteral instead of this?
| schema = Versioned <$> unVersioned .= meetingWithConversationSchema (Just V15) | ||
| -- | Legacy meeting shape (V15/V16). Keeps the deprecated @end_time@ field and | ||
| -- the always-false @trial@ field. | ||
| data MeetingLegacy = MeetingLegacy |
There was a problem hiding this comment.
This would ideally get named MeetingV16 so we know when this can be deleted.
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2026 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. |
There was a problem hiding this comment.
The other files don't have tihs, maybe we can keep this notice out of the sql files?
| ALTER TABLE meetings ADD COLUMN eff_end timestamptz; | ||
|
|
||
| -- Backfill the new columns from the discontinued end_time. | ||
| UPDATE meetings SET duration = end_time - start_time WHERE duration IS NULL; |
There was a problem hiding this comment.
I think its better to keep the end_time around and always infer the duration in haskell part. This way we don't have to do this migration and we can get rid of the eff_end field.
|
|
||
| -- Backfill the new columns from the discontinued end_time. | ||
| UPDATE meetings SET duration = end_time - start_time WHERE duration IS NULL; | ||
| UPDATE meetings SET tzid = 'Europe/Berlin' WHERE tzid IS NULL; |
There was a problem hiding this comment.
Updating timezone for old meetings to make it Europe/Berlin but still giving an option to operator to specify the default timezone in V16 APi is not very consistent. IMO we shouldn't backfill this data and always make up the meeting id on the fly, i.e. read this as a Maybe and replace it with the default timezone from the config.
| ALTER TABLE meetings ALTER COLUMN tzid SET DEFAULT 'Europe/Berlin'; | ||
| ALTER TABLE meetings ALTER COLUMN tzid SET NOT NULL; |
There was a problem hiding this comment.
We don't need to do this if we infer meaning of null timezone at runtime.
akshaymankar
left a comment
There was a problem hiding this comment.
For types which change with verison numbers we either:
- copy-paste the type to create the older version.
- or define the
ToSchemainstance forVersioned v aand deal with the differences there.
The Era thing is interesting, but I think it adds more complexity than we need. And more importantly a third way of doing the same thing. Do we have a good reason for not going with already established patterns here?
Another thing I noticed is that you use RespondVersioned with an already versioned type, think we don't really need this, if we create a new type we can just use Respond. The RespondVersioned thing is to make servant use the ToSchema from Versioned v a.
(I'm on vacation starting this evening so please feel free to merge if other team-mates approve)
Introduce an IANA `tzid` (TimeZone) field on the V17 meetings API: - NewMeeting/Meeting/MeetingWithConversation carry `tzid`; the V15/V16 shapes keep the deprecated `trial:false` field and have no `tzid`, for backward compatibility. - `end_time` is the single source of truth (no `duration` field). - `tzid` is persisted NOT NULL and backfilled to the configured `meetings.legacyTimeZone` (Europe/Berlin by default). - The V17 and V15/V16 shapes are concrete, copy-pasted records (Meeting/MeetingV16, MeetingWithConversation/V16, NewMeeting/V16) with plain `Respond` routes -- one established pattern, per the PR #5391 review (reviewer's option 1). - toLegacy/fromLegacy bridge the V17 and V16 shapes in the interpreter. The V15/V16 wire shape (trial:false, no tzid) and the V17 wire shape (tzid, no trial) are unchanged.
356db39 to
0fa66d2
Compare
https://wearezeta.atlassian.net/browse/WPB-27553
Checklist
changelog.d