hifi / heisenbridge

a bouncer-style Matrix IRC bridge
MIT License
241 stars 32 forks source link

Feature request: Add ability to completely rewrite media URLs #266

Closed hashworks closed 1 year ago

hashworks commented 1 year ago

I try to hide the matrix bridge from IRC users as much as possible. However, sending attachments breaks the illusion atm, since it is a matrix URL: https://example.net/_matrix/media/r0/download/example.net/dbWPYNbBQVdkWqCVWZzvFADD/foo.jpg

While I can adjust the domain with MEDIA_URL, the rest remains unchanged. It would be great if one could provide a template that adjusts https://github.com/hifi/heisenbridge/blob/master/heisenbridge/__main__.py#L343. The default would be:

https:/${MEDIA_URL}/_matrix/media/r0/download/${NETLOC}${PATH}${FILENAME}

With a properly configured reverse proxy one could reduce it to:

https:/irc.example.net/${PATH}${FILENAME}

Which would result in:

https://irc.example.net/dbWPYNbBQVdkWqCVWZzvFADD/foo.jpg

This would work since the netloc never changes with the bridge.

hashworks commented 1 year ago

I think this would help with #257, since ATM one needs to adjust the reverse proxy to Content-Disposition: inline anyway.