Module: Mailmate::ReplyPrefill
Overview
Derive the fields of a reply / reply-all / forward from a parent message: recipients, subject, threading headers, and the quoted original.
This is the ONE place the References chain is constructed. It is exposed as
a library call (not just a CLI behavior) because consumers need the pieces
WITHOUT sending — markdownr's compose popup fills a form from them, and
mm-send --reply-to turns them into emate flags. Two implementations of
"parent's References + parent's Message-ID" is how one of them silently
stops threading; there is only this one.
Rules it encodes (canonical prose: docs/Composing and threading.md):
* In-Reply-To = the parent's Message-ID.
* References = the parent's References (if any) + the parent's
Message-ID appended; the bare Message-ID when the parent is a root.
* A forward does NOT thread. It is a new conversation sent to someone who
was not party to the original, so injecting the original's chain would
graft a stranger into a thread they can't see. Forward derives the
subject and the quoted original only.
Defined Under Namespace
Constant Summary collapse
- MODES =
%w[reply reply-all forward].freeze
Instance Method Summary collapse
-
#build(input, mode: "reply", identities: nil) ⇒ Object
inputis an eml-id or an RFC Message-ID (bracketed or not) — anything EmlLookup.resolve_id accepts.
Instance Method Details
#build(input, mode: "reply", identities: nil) ⇒ Object
input is an eml-id or an RFC Message-ID (bracketed or not) — anything
EmlLookup.resolve_id accepts. identities defaults to the configured
list; pass an explicit array to override (markdownr passes what
mmdiscover reported, which may be broader than config.yml).
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/mailmate/reply_prefill.rb', line 47 def build(input, mode: "reply", identities: nil) mode = mode.to_s raise ArgumentError, "mode must be one of: #{MODES.join(', ')}" unless MODES.include?(mode) mail, eml_id = load_parent(input) idents = normalize_identities(identities) = HeaderValue.(mail.) threading = mode == "forward" ? { in_reply_to: nil, references: nil } : { in_reply_to: presence(), references: build_references(mail, ) } Prefill.new( mode: mode, from: pick_from_identity(mail, idents), to: derive_to(mail, mode), cc: derive_cc(mail, mode, idents), subject: derive_subject(mail, mode), quoted_body: derive_quoted_body(mail, mode), parent_message_id: presence(), parent_eml_id: eml_id, **threading ) end |