Conversation
1. sms.py: Replace per-send aiohttp.ClientSession with a persistent
session created in connect() and closed in disconnect(). Each
outbound SMS no longer pays the TCP+TLS handshake cost. Falls back
to a temporary session if the persistent one isn't available.
2. matrix.py: Use proper MIME types (image/png, audio/ogg, video/mp4)
instead of bare category words (image, audio, video). The gateway's
media processing checks startswith('image/') and startswith('audio/')
so bare words caused Matrix images to skip vision enrichment and
Matrix audio to skip transcription. Now extracts the actual MIME
type from the nio event's content info when available.
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.
Summary
1. SMS adapter: persistent HTTP session (sms.py)
Each outbound SMS created and destroyed a new
aiohttp.ClientSession, paying TCP+TLS handshake costs every time. Now uses a persistent session created inconnect()and closed indisconnect(), matching the pattern used by Mattermost and HomeAssistant adapters.2. Matrix adapter: MIME-type media types (matrix.py)
Media types were set to bare category words (
"image","audio","video") instead of proper MIME types. The gateway's media processing inrun.pychecksmtype.startswith("image/")andmtype.startswith("audio/"), so bare words caused:MessageType.PHOTOfallback saved it, but only for the image path)Now extracts the actual MIME type from the nio event's
content.info.mimetypefield when available, falling back to sensible defaults (image/png,audio/ogg,video/mp4).Test plan
python -m pytest tests/gateway/test_sms.py tests/gateway/test_matrix.py -n0 -q→ 61 passed ✔