TW-5658: fix drafts list timestamps and add drafts list --id flag#110
Merged
Merged
Conversation
The Nylas v3 drafts API omits created_at/updated_at (or sends them as null) and carries the real timestamp in a `date` field, so the CLI rendered every draft's UPDATED column as "56 years ago" (Unix epoch). The full draft ID was also unreachable from the table without --json. - adapters/nylas/drafts: migrate draftResponse timestamps to domain.UnixTime; firstSetTime falls back to `date` when created_at/updated_at are unset (omitted -> zero time, null -> epoch). - cli/common/time: FormatTimeAgo renders "unknown" for an unset timestamp (zero value or exact Unix epoch); pre-1970 times still format. - cli/email/drafts: add `--id` flag to show full draft IDs (matches email list/folders/threads); ID column width and separator scale together; drafts show guards an unset UpdatedAt. - Tests across the changed packages; docs/COMMANDS.md updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nylas email drafts listrendered every draft'sUPDATEDcolumn as "56 years ago". The Nylas v3 drafts API omitscreated_at/updated_at(or sends them asnull) and carries the real timestamp in adatefield (Unix seconds) — the CLI mapped the missing field to the Unix epoch / zero time. There was also no way to read a draft's full ID from the table without falling back to--json.Fixes TW-5658.
Changes
internal/adapters/nylas/drafts.go— migratedraftResponsetimestamp fields todomain.UnixTime; addfirstSetTime(primary, fallback)socreated_at/updated_atfall back to thedatefield when unset (handles both omitted → zero time and null → epoch).internal/cli/common/time.go—FormatTimeAgonow renders"unknown"for an unset timestamp (zero value or exact Unix epoch); a genuine pre-1970 time still formats normally.internal/cli/email/drafts.go— add--idflag todrafts listto show full draft IDs (matches theemail list/folders/threadsconvention); the ID column width and the separator line scale together;drafts showguards an unsetUpdatedAt.docs/COMMANDS.mdupdated.Verification
make cigreen: fmt, vet, lint, unit, race, security scan, govulncheck (0), build.--idmodes.Before / after
Related docs
--idflag--idflag convention this follows