Repository navigation
feat(platform): find a conversation by its message text - #3084
Merged
Merged
Conversation
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.
Chat can now find a conversation by a word in one of its messages, not only by its subject or who it is with.
Why
An email arrives with a CV attached. The attachment is searchable; the covering note that explains what the sender wants is not. Asking about an order number, a serial, or a name that appears only in the body of a message found nothing, so the only route to a conversation was remembering its subject line.
The file already said this was the missing leg, and that the index it needed existed.
What changed
One bounded pre-pass over
conversationMessages, walkingby_organizationId_and_deliveredAtnewest-first, turning the term into a set of conversation ids — the same shape the contact-name leg already uses. A conversation then matches on its subject, on being with a matching contact, or on one of its messages containing the term.HTML is stripped before matching. Bodies arrive as whatever the sender's mail client produced, so matching raw would make a search for "table" hit every
<table>.htmlToTextis the existing stripper, and the cheap<test keeps a plain-text body from paying for it.MESSAGE_SCAN_CAPis 400 andBODY_MATCH_CAPis 50, both separate from the conversation walk's own cap. Messages outnumber conversations several times over, and this walk pays a strip per row rather than an assignment decision.Risk
The body walk reads text the caller may not be allowed to see. That is safe only because it returns conversation ids and nothing else — every id still faces
conversationAssignmentAllowsin the main walk, so an unreadable conversation's body match is collected and then discarded. A test asserts a member outside the assignment gets nothing from a body that plainly matches.Truncation from the body walk makes the whole answer partial, not just that leg, so it is folded into the returned
truncated. A caller told "no matches" would otherwise read it as complete when the walk stopped at 400 messages.It is keyword matching. A question phrased by meaning rather than by words that appear in the mail will not match, and neither will anything past either cap. Nothing here embeds or stores anything, which is the trade: no third-party processing, no backfill, and it works on existing mail immediately.
Tests
Six cases: a body-only match, a body match refused for the wrong caller, matching through HTML, not matching a word that exists only in markup, truncation surfacing from the body walk, and a listing skipping the walk entirely.
Five deliberate breakages, all caught: the leg switched off, the HTML strip removed, truncation dropped, the cap raised, and the assignment check disabled.
Scope
Does not index anything. Email bodies still have no presence in the search index, which is #3015 — a different trade, and one that owes an erasure cascade.
Gate: repo-wide typecheck,
oxlint --type-aware, oxfmt, knip, SAST 0 findings, platform suite 75,801 passing.