Skip to content

Added suggest_recipients, search_chat and chat_message - #45

Merged
PianoNic merged 2 commits into
mainfrom
feature/search-and-suggest
Nov 3, 2026
Merged

PianoNic merged 2 commits into
mainfrom
feature/search-and-suggest

Conversation

@PianoNic

@PianoNic PianoNic commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Adds address autocomplete, search inside one chat, and a way to read one chat message that avoids Graph's throttling.

What changed

  • suggest_recipients(text, top=5): email suggestions as someone types, from /me/people?$search, so contacts you use most come first. It fills up from the directory if there are too few. Matches the start of an address too, like m.dia.
  • search_chat(chat_id, query, top=25, scan=200): Graph can't limit a search to one chat, so this looks through up to scan results across all chats and keeps that chat's. It isn't an exact search: a word that's common elsewhere can use up scan first.
  • chat_message(chat_id, message_id): one message with its attachments, using Teams' chat service and falling back to Graph.

Why chat_message() doesn't just use Graph

On the tested account, chats/{id}/messages/{id} and me/chats/{id}/messages/{id} kept returning 429 on the Office client, and other clients got 403. The chat service route answered in about 90 ms with attachments. Why those Graph routes are limited is unknown. The chat service is undocumented, hence the fallback.

Testing

  • 184 tests pass, and Ruff and mypy are clean.
  • On a real tenant:
    • suggest_recipients() put a frequent contact first in every test by name prefix, and an address prefix found the right person first from three characters on.
    • search_chat() only returned that chat's messages.
    • chat_message() matched the chat list on 30 of 30 messages. None of those 30 had files, though the route's attachments were seen in an earlier check.

Known gap: an unknown message id falls back to Graph, which can report a 429 instead of "not found" while that route is throttled.

@PianoNic PianoNic added the enhancement New feature or request label Nov 3, 2026
@PianoNic
PianoNic merged commit 7ffff2c into main Nov 3, 2026
3 checks passed
@PianoNic
PianoNic deleted the feature/search-and-suggest branch November 6, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant