Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@araa47
Copy link
Contributor

@araa47 araa47 commented Jan 25, 2026

Summary

Fixes encrypted media (images, audio recordings, files) not being decrypted in Matrix E2EE rooms.

Previously, when users sent images or audio recordings in encrypted Matrix rooms, the bot would fail to decrypt them. Text messages worked fine, but media attachments were broken.

Root Cause

The decryptMedia function from matrix-bot-sdk's CryptoClient was being called with incorrect parameters:

// Before (broken) - passing 2 args
const decrypted = await params.client.crypto.decryptMedia(
  Buffer.from(encryptedBuffer),
  params.file,
);

However, according to the matrix-bot-sdk documentation, decryptMedia takes only a single EncryptedFile parameter and handles the download internally:

// Correct signature
public async decryptMedia(file: EncryptedFile): Promise<Buffer>

Fix

  • Call decryptMedia(file) with just the EncryptedFile object
  • Remove redundant manual download (the SDK handles it internally)
  • Move size check to after decryption

Testing

  • Unit tests updated and passing
  • Tested on live Matrix E2EE room with encrypted image attachments

🤖 Generated with Claude Code

Claude Sandbox added 2 commits January 25, 2026 16:27
…ments

The matrix-bot-sdk CryptoClient.decryptMedia() method takes only a single
EncryptedFile parameter and handles the download internally. The previous
code incorrectly passed both a downloaded buffer and the file object.

This fix:
- Removes redundant manual download (decryptMedia handles it)
- Passes only the EncryptedFile to decryptMedia as expected
- Moves size check to after decryption
@steipete steipete self-assigned this Jan 25, 2026
steipete added a commit that referenced this pull request Jan 25, 2026
@steipete
Copy link
Contributor

Landed via squash on main: 026def6.

  • Matrix: use crypto.decryptMedia(file), preflight size guard from info.size, add oversize test.

Tests:

  • pnpm lint (fails: no-redundant-type-constituents in src/line/*)
  • pnpm build (fails: missing @line/bot-sdk types)
  • pnpm test (timed out; existing failures in telegram + memory-lancedb suites)

Thanks @araa47!

@steipete steipete closed this Jan 25, 2026
steipete added a commit to orlyjamie/clawdbot that referenced this pull request Jan 25, 2026
mcinteerj pushed a commit to mcinteerj/moltbot that referenced this pull request Jan 25, 2026
rodrigouroz pushed a commit to rodrigouroz/moltbot that referenced this pull request Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants