Answer the identity a draft sends as, so an edit can't move it to the default sender

Merged
JE
3d ago
+232-43

DraftContent.ActingSenderID zero means the account's default sender, and HEY revises a draft from the whole of what is sent. So every caller that reads a draft back and revises it has to know to send the draft's sender, else its creator: HEY names a sender only when it differs from the creator (Entry#sent_as), so a draft from the person's own address carries a creator and no sender, and that creator need not be the default sender. hey-cli carries this rule twice and the hosted HEY MCP server once, and the hosted server shipped without it until last week.

This puts the rule in the SDK:

  • DraftSentAs(*MessageEditState) Contact: sender, else creator.
  • ReplySentAs(*MessageDraft) Contact: the same for NewReply's prefill, whose Sender is likewise present only when it differs from the acting user's own contact (Creator). Passing prefill.Sender.Id alone sends zero for a reply from the person's own address.
  • DraftContentFromEdit(*MessageEditState) DraftContent: the whole revision from an edit state, the sending identity and the schedule (as its UTC date and hour) included, so an edit changes only what it means to.

The docs on DraftContent.ActingSenderID, UpdateDraft, SendDraft, CreateReply, CreateReplyDraft and NewReply point at them.

Go only, and additive (no public type changes), so a patch release. hey-cli and the hosted server adopt it and delete their copies once it's tagged.

Tests: sender-else-creator for both shapes and nil; DraftContentFromEdit's fields, skipped address-less contacts and UTC schedule; and a GetEdit → UpdateDraft round trip that sends the creator's id rather than the default sender's (fails if the helper reads sender alone). make go-check go-check-drift passes.


Summary by cubic

Adds Go SDK helpers so callers can read a draft back and revise it without moving it to the default sender. HEY revises a draft from the whole of what is sent, and a zero ActingSenderID means the default sender, so every caller had to know to send the draft's sender, else its creator — HEY names a sender only when it differs from the creator. Three consumers duplicated this rule, and one shipped without it.

  • DraftSentAs and ReplySentAs answer sender-else-creator for an edit state and a reply prefill; DraftContentFromEdit builds a full DraftContent from an edit state, including recipients, the sending identity, and the schedule as a UTC date and hour.
  • Docs on DraftContent, UpdateDraft, SendDraft, CreateReply, CreateReplyDraft, and NewReply point to these helpers.
  • The spec and every SDK's schedule docs were corrected to say a schedule's date and hour are read in UTC, as HEY's API reads every JSON request's times.