Sending encrypted files in unencrypted room
- Lingua principale
- Python
- Stelle
- 754
- Fork
- 69
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
When I run `matrix-commander -i test.png` to send an image to an unencrypted room, some clients such as Nheko fail to display the image. This appears to happen because matrix-commander is sending the image encrypted, even though the room is *not* encrypted.
The Matrix spec is not 100% clear to me on whether or not this is allowed, but it seems at least discouraged by the sentence "When encryption is enabled in a room, files should be uploaded encrypted on the homeserver." (https://spec.matrix.org/v1.17/client-server-api/#sending-encrypted-attachments)
Further, matrix-commander itself isn't very happy about it:
```
root@blue:~# matrix-commander -i test.png
2026-01-20 17:42:35,712: WARNING: nio.events.misc: Error validating event: 'url' is a required property
Failed validating 'required' in schema['properties']['content']:
{'type': 'object',
'properties': {'body': {'type': 'string'},
'url': {'type': 'string'},
'msgtype': {'type': 'string',
'enum': ['m.image',
'm.audio',
'm.video',
'm.file']}},
'required': ['body', 'url', 'msgtype']}
On instance['content']:
{'body': 'drive.jpg',
'info': {'size': 520596,
'mimetype': 'image/jpeg',
'w': 2560,
'h': 1440,
'xyz.amorgan.blurhash': None},
'msgtype': 'm.image',
'file': {'url': 'mxc://',
'key': {'kty': 'oct',
'alg': 'A256CTR',
'ext': True,
'k': '',
'key_ops': ['encrypt', 'decrypt']},
'iv': '9sYw2J7VftwAAAAAAAAAAA',
'hashes': {'sha256': 'rkavhUk/zBs8XJMORwzncQikFWD6L9oYL/FJU0jwRPU'},
'v': 'v2'}}
2026-01-20 17:42:36,277: INFO: matrix-commander: This image file was sent: "stonks.png" to room "" as event "".
```
This validation failure reflects the issue, per the spec `url` is required for unencrypted media while `file` is required for encrypted media (https://spec.matrix.org/v1.17/client-server-api/#mimage).
Adding `--plain` does not change the behavior.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Look at the file upload and room encryption detection logic, likely in the main command handler or a media sending module. Check if the room's encryption state is being read before deciding to encrypt the file. The spec links provided show the difference between 'url' for unencrypted and 'file' for encrypted media. Run the failing command with debug output to trace the decision path.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 65/100