Repository navigation
Added suggest_recipients, search_chat and chat_message - #45
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.
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, likem.dia.search_chat(chat_id, query, top=25, scan=200): Graph can't limit a search to one chat, so this looks through up toscanresults across all chats and keeps that chat's. It isn't an exact search: a word that's common elsewhere can use upscanfirst.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 GraphOn the tested account,
chats/{id}/messages/{id}andme/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
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.