poljar / weechat-matrix

Weechat Matrix protocol script written in python
Other
958 stars 120 forks source link

MXC to HTTP URI transformation is wrong if the origin homeserver differs from our own. #57

Closed poljar closed 5 years ago

poljar commented 5 years ago

Matrix Content (MXC) URIs are currently transformed to HTTP URIs solely based on the origin home-server of the content.

This ends up creating HTTP URIs that return a 404 error.

r3k2 commented 5 years ago

Since you are on this, I know there are terminals on linux like "terminator" etc that will show images, anyway that the plugin can support image preview if terminal allows it? or have some sort of weechat trigger etc.. just and idea.

poljar commented 5 years ago

I don't think that this would be possible, we can't even hack around and add the URL escape code, it gets filtered out by Weechat or ncurses. The rule of thumb is if ncurses doesn't support it it's probably near impossible to do it.

r3k2 commented 5 years ago

I know ranger allows this, and I think(not sure) it used ncurses I tent to use only TUI apps and sometimes adding external hooks also you can get it working like https://wiki.vifm.info/index.php/How_to_preview_images worth to check

poljar commented 5 years ago

Ranger as well as vifm use w3imgdisplay. I'm not sure if it's possible to incorporate that into weechat from a script. If someone figures out a way to do this I'm all for it.

r3k2 commented 5 years ago

@poljar I will look into this see what I can get working..

poljar commented 5 years ago

So to get this working the room buffer class should know the homeserver url and the mxc_to_http() function in the nio Api class should take a homeserver argument. The same thing should happen to the encrypted_mxt_to_plumb() function.

Later on there will be some big RoomBuffer class refactoring and change how room events are processed which will make all of this more organic.