telegram icon indicating copy to clipboard operation
telegram copied to clipboard

Use direct Telegram media storage instead of copying attachments to local Matrix storage

Open MurzNN opened this issue 4 years ago • 2 comments

At now bridge do copy of all Telegram media to local Matrix server instance as local media files, so those files waste space on local Matrix homeserver.

But all Telegram media files always available in Telegram media storage at any time, so better way will only cache requested media on Matrix homeserver side, like this done now in Synapse for media files from other homeservers that can be cleaned-up at any time with on-demand re-downloading.

So, can we implement Telegram media storage as separate Matrix media storage, that will use native Telegram storage as source, and store only recently required files in local cache?

On Synapse side it will work like media on federated homeserver with url on separate subdomain like mxc://telegram.myhomeserver.org/pGRtwfXYPZUuNYnHTJBTZAlg (instead of mxc://myhomeserver.org/pGRtwfXYPZUuNYnHTJBTZAlg for native Matrix media in this homeserver) that will be processed natively like any other Matrix federated media.

For implement this feature, as I understand, we must implement separate light Matrix media server (maybe based on Dendrite?), that will receive Matrix media queries (media download and upload) from Matrix client, convert them to Telegram media queries, proxies to Telegram server, and transfer result to Matrix client, right? And maybe same way of media proxy service can be reused for other bridge types (Facebook, Skype)?

If yes, how hard is implementing this feature?

MurzNN avatar Jul 15 '19 09:07 MurzNN

Does the client need to be authorized when using mxc protocol? If not this could cause the server be fulled by free-riders.

uetcis avatar Jan 26 '21 06:01 uetcis

https://github.com/nktknshn/tgmount could be a nice start ;D

@CaptainYukinoshitaHachiman its only about download from telegram, not upload to media server, IMO matrix sent media should stay as matrix media Also it would need some db with relation between telegram based media and mxc url, so It shouldnt be easy nor especially useful to invade in my opinion

BTW. It's pretty good idea, I had to blacklist some telegrams channels with big amount of files being sent to not make my media repo explode

JuniorJPDJ avatar Jan 29 '21 02:01 JuniorJPDJ