# matrix-media-event-decrypt
Decrypt [matrix] media manually using event JSON obtained from a client.
Sometimes decrypting media fails for unknown reasons or your homeserver isn't able
to federate in media from another server. If you were still able to receive the media
event and (if encrypted) see the decrypted JSON, this tool might be able to help you
download and decrypt the content.
[![Demo on asciinema.org](https://asciinema.org/a/673199.svg)](https://asciinema.org/a/673199)
## Building
A simple `cargo run --release --` should be all it takes. If not and on systems with an
implementation of the Nix Package Manager (such as [lix](https://lix.systems)) you can
install any required dependencies (probably only openssl) by running `nix-shell` first.
## Usage
Running the binary without any arguments will prompt you to paste the JSON of the media
event you want to retrieve the contents of. On Element Web / Desktop this is the message
context menu > View Source > Decrypted / Original Event Source.
On other clients you might need to fiddle around with the JSON a little, important is
that it looks something like this:
```json
{
"content": {
"body": "something.jpg",
"msgtype": "m.image",
"m.mentions": {},
"url": "mxc://nwex.de/undefined",
// A bunch more
},
// A bunch more
}
```
Confirm by hitting Ctrl+D or Enter and wait for the magic to
happen. You might be prompted to enter an access token if the server requires authentication
to fetch the media. For convenience, this tool ignores the [matrix] specification and doesn't
always use authenticated endpoints if support is advertised, instead just trying if it can get
away without a token.
You can customize the server to download media from by passing `--server matrix.org`, for example.
## Contributing
For convenience this project is hosted on my personal git server without public registrations
enabled. If you want to contribute feel free to reach out via the various platforms listed on
[my website](https://nwex.de/).