matrix-org / pantalaimon

E2EE aware proxy daemon for matrix clients.
Apache License 2.0
288 stars 41 forks source link

media event is not modified #43

Closed Midek closed 4 years ago

Midek commented 4 years ago

When displaying images, non-e2ee clients expect thumbnail_url and url while apparently pantalaimon sends them file and thumbnail_file instead. Because of that clients fail to display encrypted images.

Pantalaimon should probably modify event content, so clients can request proper image url and display it properly.

Here is example event source from Fractal:

{
  "content": {
    "body": "2020-03-31-205255_940x819_scrot.png",
    "file": {
      "hashes": {
        "sha256": "98y6kJYxxrAZFSDHbarAG1++kkprF66687uVekeRAnM"
      },
      "iv": "WvMBUqn0GfYAAAAAAAAAAA",
      "key": {
        "alg": "A256CTR",
        "ext": true,
        "k": "9lc0B2Di3NZLg_JxAlNigZwjmmGf7h9toryLg19cun4",
        "key_ops": [
          "encrypt",
          "decrypt"
        ],
        "kty": "oct"
      },
      "mimetype": "image/png",
      "url": "mxc://midov.pl/hjvXjEXFjyKCDzTaEcHqALaS",
      "v": "v2"
    },
    "info": {
      "h": 819,
      "mimetype": "image/png",
      "size": 114056,
      "thumbnail_file": {
        "hashes": {
          "sha256": "U+brDr/A/RyQO2sxsgsptcrOagt7o9MY4LAUcWPksSU"
        },
        "iv": "2/GbHBzwhS4AAAAAAAAAAA",
        "key": {
          "alg": "A256CTR",
          "ext": true,
          "k": "V4JVAAu5Jps-Tzk5pEEaK1BY1M76TwuhFyvSRoL7EC4",
          "key_ops": [
            "encrypt",
            "decrypt"
          ],
          "kty": "oct"
        },
        "mimetype": "image/png",
        "url": "mxc://midov.pl/DMSMbyNTzbCiLppnXlCtGpBI",
        "v": "v2"
      },
      "thumbnail_info": {
        "h": 600,
        "mimetype": "image/png",
        "size": 189087,
        "w": 688
      },
      "w": 940
    },
    "msgtype": "m.image"
  },
  "decrypted": true,
  "event_id": "$b-o6x5UDsS7WxjDTiMpode19kCDVA_zO4xjy-OBkGis",
  "origin_server_ts": 1585681036729,
  "room_id": "!SVlZdZFeWcpgmdAfkz:midov.pl",
  "sender": "@ttestowy:midov.pl",
  "type": "m.room.message",
  "unsigned": {
    "age": 1080315
  },
  "verified": false
}

Fractal failed to display this encrypted image, even though when i tried to manually curl http://127.0.0.1:8009/_matrix/media/r0/download/midov.pl/hjvXjEXFjyKCDzTaEcHqALaS, it was decrypted properly.

MRAAGH commented 4 years ago

Anything going on with this? I'd really like to be able to access images in gomuks; it's, like, the number 1 thing that's missing for me in gomuks

poljar commented 4 years ago

Not yet, have to chase bugs in other projects first.

If you want to take a shot at this, it should be relatively straight forward to edit this method and modify the event_dict if the event is a media event.

poljar commented 4 years ago

Closed by https://github.com/matrix-org/pantalaimon/commit/4b6b61c4be6eebf34d0c203e8902f0a8e7d4c20a