Repository navigation
feat(direct-send): send-email --follows sends a follow-up in an earlier direct email's thread - #42
Merged
Merged
Conversation
…er direct email's thread
contact send-email --follows <reference> sends the email through Reply's
send-direct-email-follow-up route instead of send-direct-email, as a
follow-up in the thread of the earlier direct email the reference names.
- The reference is checked before any call: email-<n>, n from 1 with no
leading zero and at most ten digits, as Reply spells it and as
direct-send get takes it. Anything else is usage.reference, exit 2.
- The message is {body} alone, since the follow-up goes under its
thread's subject. A message carrying a subject is usage.message,
exit 2, and says why; nothing is sent.
- The other flags, the way the contact is found or imported, and the
result are those of a plain send-email.
- Reply's refusals of the email it follows map to follows.not_found,
not_owned, other_contact, other_mailbox, never_sent, not_sent,
too_early and not_placed, each read only under the status Reply
publishes it with and only on this route. Every other refusal maps as
on a plain send, and reply_code keeps Reply's code.
- A 404 with no code of Reply's is follows.not_available: that Reply has
no follow-up route. Nothing was sent, and nothing else is called.
direct-send get and cancel add Reply's follows, the reference of the
email a follow-up went in the thread of, or null, only when Reply gives
it, so an older Reply prints as before. The failure codes a follow-up
can end with are passed on as given, like every failure_code.
The README and the reply-api skill say how to send a follow-up and what
follows.not_available means.
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.
What
reply contact send-emailtakes--follows <reference>. With it, the email goes as a follow-up in the thread of an earlier direct email, through Reply'sPOST /v3/contacts/{id}/send-direct-email-follow-upinstead ofsend-direct-email.reply direct-send get(anddirect-send cancel, which prints the same record) adds Reply'sfollowsto the send it prints.Why
A second direct email to the same person should read as part of the first conversation: an answer in the first email's thread, under its subject, rather than a new thread. Reply's new follow-up route sends exactly that, and this change gives the CLI a way to call it.
The design makes sure an older version on either side can never turn a follow-up into a plain new-thread email:
--followsby itself, as an unknown option (error: unknown option '--follows', exit 2), before it calls Reply. This was checked against a build ofmain.follows.not_available(exit 1, nothing sent) and calls nothing else after it, a plain send included. A 404 that does carry a code (contact.notFound,contact.followedSendNotFound,contact.scheduleNotFound) is Reply's own answer and maps as such.How it works
--followstakes the earlier send's reference as Reply spells it and asdirect-send gettakes it:email-<n>,nfrom 1, no leading zero, at most ten digits. Anything else isusage.reference(exit 2), refused before stdin is read or any call is made.--message -) is{body}alone. A message carryingsubjectisusage.message(exit 2) with a sentence saying why, and nothing is sent.read_stdin_objectgains an optionalrefusedmap for this, so the refusal does not read as a generic unknown field.{emailAccountId, body, follows}plus the usual optional fields.--email-account-id,--send-after,--schedule-id,--idempotency-key(sent as a header),--track-links,--track-opensand the time-zone flags work as they do on a plain send. The contact is found or imported the same way, and the result has the same shape (reference,state,send_after,message_id, plus the rendered text when Reply sends the email within the request).send-email. As on every CLI refusal,reply_codekeeps Reply's code.direct-send get/canceladdfollows(a string, or null for a send that follows none) only when Reply gives it in that shape. The CLI does the same for every field added to that record after its first ones (estimated_send_at, the rendered text, the bounce members), so an older Reply's answer prints exactly as before. Reply's three new failure codes for a follow-up (contact.followedSendNotSent,contact.followedSendNeverSent,contact.followUpNotPlaced) pass throughfailure_codeuntranslated, as every failure code does.--helpgains the flag, an example and the new codes in its code list. The README and thereply-apiskill (1.6.0) describe the flag in a few sentences.Codes
Each one sends nothing.
contact.followedSendNotFoundfollows.not_foundcontact.followedSendNotOwnedfollows.not_ownedcontact.followedSendOtherContactfollows.other_contactcontact.followedSendOtherMailboxfollows.other_mailboxcontact.followedSendNeverSentfollows.never_sentcontact.followedSendNotSentfollows.not_sentcontact.followUpBeforeFollowedSendfollows.too_earlycontact.followUpNotPlacedfollows.not_placedcode)follows.not_availableThe new flag and output field are additive, so this is a minor release (
feat:).How it was verified
npm test: 66 files, 1088 passed, 5 skipped. The 5 skips are the existing platform-specific ones (POSIX file modes, case-sensitive filesystems). The suite is offline, as always, withfetchstubbed. New tests cover:{contact, message}stdin pairsubject,followspresent, plus the other flags and theIdempotency-Keyheaderdirect-send get/cancelprintingfollows, and leaving it out when Reply gives no such field or one of another shapenpm run build(tsc) is clean, and commitlint passes on the commit.