Repository navigation
feat: the direct sends and contact update find or import the person given by their fields - #29
Conversation
The five direct sends took only --contact-id, so a send to someone Reply did
not hold yet needed an add command first. They now take the contact flags the
add commands take. A person given by their fields is looked up by the address
the send reaches them at (the email for send-email, the LinkedIn URL for the
four LinkedIn sends) and imported, as the add commands import one, only when
Reply holds nobody under it. The answer names the contact the send went to and
says whether the command created it.
When --contact - and --message - both read stdin, it holds one object,
{"contact": {...}, "message": {...}}, so neither the person nor the text ever
sits in the argument list. A lost answer to the import says nothing was sent.
contact update took only a contact id, so changing the fields of someone Reply
did not hold yet needed an add command first. It now also takes the contact
flags the add commands take. A person given by their fields is looked up as
the add commands look one up and imported only when Reply holds nobody under
the address; the id argument keeps working and counts as one of the ways.
The fields that name the person only find or import them: on a contact Reply
holds, the PATCH carries exactly what --fields names, never the address the
contact was found by. Custom fields are read before the person is found or
imported, so an unknown name still changes nothing. With --contact - and
--fields - both, stdin holds one object, {"contact": {...}, "fields": {...}}.
…er from the argument list A send to a person Reply does not hold and an update of one it holds, run as reply runs them: the argument list carries no personal data, the requests carry the person and the text, and the update's PATCH carries only its fields.
… person The table names the sends and contact update by <contact>, the paragraph on imports says which commands look first, by which address a send looks, and that each answers the contact id it acted on; a new paragraph shows stdin holding the person and the text together.
…s given When the person is given by fields and nobody is found by the LinkedIn URL, the import is matched by the email and may return a contact Reply already holds. That contact is now read before the send: a different LinkedIn profile refuses the send with contact.channel_conflict (exit 1, nothing sent or changed, the contact in ids); an empty one is given the profile, and only that field, before the send; the same profile (compared ignoring the scheme and www) goes ahead. A contact found by the URL or created by the import is not read. The hint after a lost answer to any step before the send says the send was never made.
… the import matched --help of the four LinkedIn sends and the README state the contact.channel_conflict refusal, the profile set on a contact that holds none, and that --email alone is refused; the exit 3 line says "unless the hint says nothing was sent"; the name flags of the commands that look a contact up first say they are used only if it is imported; the README no longer implies sequence remove-contact answers contact_created.
The import runs before the read, so it may already have filled the held contact's empty fields. The refusal now says nothing is sent and the contact's LinkedIn profile is not changed, names the contact as one Reply already holds, and adds "if it is a different person" to the hint.
|
Approved at ca8a237 — first reader. Read: the body, the find-or-import path in |
|
Approved at ca8a237 — second reader, independent. The first read at 2bb812c asked for one change: a LinkedIn send given an email as well could reach a contact Reply holds under that email with a different LinkedIn profile, and report success. At b9c4bca the contact an import matched is read before the send: another profile is refused ( |
Pull request was converted to draft
Reply does not refuse a direct send to a contact it holds as opted out, so the only guard on that opt-out is a caller that reads the contact before it sends. Given a person's fields, the five sends now act only on a contact the command created: when the lookup finds a contact, or the import matches one Reply already holds, nothing is sent and the answer is the new contact.already_held (exit 1), with the contact in ids.contact_id and a hint to read it and send with --contact-id. contact update and --contact-id are unchanged. A matched contact is now refused before anything else, so the read of an import-matched contact before a LinkedIn send (contact.channel_conflict, and the PATCH of an empty LinkedIn URL) could no longer be reached; it is removed with its tests. The hint after a lost import answer says a re-run answers contact.already_held if that import did create the contact.
…contact it creates The paragraph on the LinkedIn profile check gives way to the rule: a direct send given a person's fields refuses a contact Reply already holds with contact.already_held, naming it, so the caller reads it and sends with --contact-id. The note on exit 3 names the import as the only step before a send whose answer can be lost.
…ess it was given A send looked the person up only by the address it reaches them at, so a contact Reply held under the other address (the LinkedIn URL for an email send, the email for a LinkedIn send) was neither read nor refused, and a second contact was created beside it. The lookups now run in a fixed order, the address the send reaches them at first and the other when it was given. A hit under either is refused with contact.already_held naming the first contact found, and nothing is imported or sent. The help of the five sends and the README say so, and say that contact_created is kept on a send for consistency with the add commands and is always true when something was sent.
…t's unused channel contact_created is always true when a send was given a person's fields and always false with --contact-id; in both cases a successful answer says the send was made. The help, the README and the test that pins the sentence now say so. find_or_import no longer takes a channel, since the sends look a person up themselves.
|
Approved at cabd40a — first reader (supersedes the approval at ca8a237). Read the rounds after ca8a237: a send given a person's fields now acts only on a contact it creates. It looks the person up by every address given, the one the send reaches first; any hit, or an import that lands on a contact Reply already held, is refused with |
|
Approved at cabd40a — second reader, independent (supersedes the approval at ca8a237). Since ca8a237: the refusal holds before any send on both paths (a lookup hit; an import that matched) for all five sends, by every address given; created → sent; |
What changed
contact send-email,contact linkedin-connect,contact linkedin-message,contact linkedin-inmail,contact linkedin-voiceandcontact updatenow take the same contact flags assequence add-contact:--contact-id,--emailwith its name flags, or--contact <json>|@file|-.--contact-idworks as before: one call, no lookup.them at first (the email for
send-email, the LinkedIn URL for the four LinkedIn sends) and then theother when the person has one.
contact updatelooks up by the email, or by the LinkedIn URL whenthere is no email; unlike the add commands, which import a person given by email straight away.
the same
POST /v3/contacts/importcall, keyed by the email when there is one and by the LinkedIn URLotherwise, carrying the first name the caller gave. Reply requires a first name on an import, so a
person it does not hold yet needs one;
contact updateof a person it holds does not, because thelookup comes first.
contact updatemakes itsPATCHon the contact it found or imported. A send acts only on acontact it created (next point).
was given finds a contact (so a contact held under the LinkedIn URL is refused for an email send too),
or its import matches one Reply already holds (by the email, say, or a teammate's contact), nothing is
sent: the answer is the new
contact.already_held, exit 1, with that contact's id inids.contact_id.Its hint says to read the contact (
reply contact get <id>) and to send to it with--contact-idif itis the one to reach. If two different contacts are held, one under each address, the answer names the
first one found, the one under the address the send reaches them at, and the second is not looked up.
When the import creates the contact, the send goes to it.
--contact-idisunchanged, and so is
contact update, which acts on a contact it finds or the import matches: an updatesends nothing.
without a LinkedIn URL) is refused before any call:
usage.contact, exit 2.contact_idandcontact_created; on a sendcontact_createdis kept for consistency with the add commands: given aperson's fields it is always
true, and with--contact-idit is alwaysfalse; in both cases asuccessful answer says the send was made. A failure after the contact was found or created carries its id in
ids.contact.not_unique,contact.invalid_email,contact.invalid_linkedin_url,account.contact_limit_reached, andreply.refusedfor an item theimport failed. Each is exit 1, and nothing is sent or changed.
PATCH) is exit 3 (outcome.unknown). When theimport's answer is lost, the hint says nothing was sent and a re-run is safe; that re-run answers
contact.already_heldif the import did create the contact. When the send's answer is lost, the hintsays a re-run may send it twice. A lost answer to a read (the lookup) is
reply.unavailable, exit 1,nothing written.
--contact -and the command's own input(
--message -or--fields -) both read stdin, it holds one object with each under its flag's name,{"contact": {...}, "message": {...}}or{"contact": {...}, "fields": {...}}, read once. When onlyone flag reads stdin, nothing changes. A malformed object is
usage.stdin, exit 2, nothing repeated.contact updatekeeps its id argument (contact update 456iscontact update --contact-id 456);the argument together with a contact flag is
usage.contact. Custom field names are still checkedbefore anything is written, and now before the contact is imported too. The fields that name the
person only find or import them: the
PATCHcarries exactly what--fieldsnames.contact opt-outnow goes through the same shared find-or-import function; its behaviour is unchanged.--helpof the six commands and the README describe all of the above.Why
A send or an update to a person Reply did not hold yet needed a separate add command first, only to make
the contact exist. That was two commands for one act, two places where an answer could be lost, and a
list or sequence touched for no reason of its own. Now one command finds the person, creates them only
when Reply has nobody under the address, and acts.
A send is held to a contact it created because Reply does not refuse a direct send to a contact it holds
as opted out. The only guard on that opt-out is a caller that reads a contact Reply already holds before
sending to it, so a send given a person's fields never sends to such a contact on its own: it names it,
and the caller reads it and sends by id. A contact this command has just created was not held by Reply
before, so there is no opt-out on it to miss.
How it was verified
npm run buildandnpm test: 57 files, 853 passed, 5 skipped (824 passed before the change). Thesuite is offline; every test stubs
fetch.direct-send.test.ts,contact-record.test.ts,commands.test.tsandprogram.test.tsread each request and its body in order (lookup, import, act), and each asserts that the argument list
carries none of the person's text. Three run the whole program from its argument list with the
combined object on stdin.
given (the LinkedIn URL for
send-email, the email for each LinkedIn send) is refused, with only the twolookups made; two contacts held, one under each address, name the first and ask only once; the lookup finds a contact (refused with
contact.already_held, exit 1, the contact's id inids, only the lookup made); the import matches one,answered
updatedorskipped(refused the same way, only the lookup and the import made); the importcreates it (sent to it, after both lookups found nobody).
contact updateacts on a contact it found or the import matched, as its owntests assert.
red); a hit on the second lookup not refused (1 test red).
refusal skipped on a lookup hit; the refusal skipped on an import match; the refusal built but not
thrown;
contact updaterefusing a contact it found.contact updateimporting before it checks custom field names;contact updatewriting the contact'saddress into the
PATCH; the first name dropped from the import; a LinkedIn send looking the person upby email; a lost import answer hinted as a possible double send.
Two properties checked on purpose
{"items":[{"linkedInUrl":…,"firstName":…}],"options":{"keys":{"linkedInUrl":true}}}when there is noemail, the same path
sequence add-contactalready uses for such a person. Reply's publishedreference for
POST /v3/contacts/importagrees: onlyfirstNameis required per item and the otherfields are optional,
skipWithoutEmailsdefaults tofalse,keys.linkedInUrlmakes the LinkedIn URLa deduplication key, and the per-item
"Invalid data"error names a missingfirstNameor amalformed email, not a missing email. This PR does not exercise it against a live account.
contact updatenever changes the address of a contact Reply holds. Tests give the person with anemail and a different LinkedIn URL and assert that the
PATCHbody is exactly the--fieldsobject,in a unit test and through the whole program; a
linkedin_urlchanges only when--fieldsnames one.The mutant that copies the person's address into the
PATCHturns four tests red.