element-hq / element-hq/element-android
Support direct download where file size is too large for homeserver
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
#### Is your feature request related to a problem? Please describe.
As discussed in [this](https://matrix.to/#/!hFdiidJUHZOsUlmhcn:matrix.org/$v5yKMoqeP3bs5yRdfAZ-1FBQyiTS5IUd4E1rDMtLSP8?via=an-atom-in.space&via=matrix.org&via=tchncs.de) conversation, sometimes your homeserver has a file size limit lower than someone else's, but you still wish to receive a file they sent. To do this, you can manually download directly from their homeserver, but it would be great if Element could instead detect that the file is too large for your homeserver and offer an automatic direct download from the origin homeserver instead (in fact, for any file federation failures).
#### Describe the solution you'd like.
I know it's possible to get a homeserver's max upload limit, and also media/file events have a "size" key. Hence, this information can be used to determine if the file will be downloaded by the homeserver. In cases where it is not downloaded by the homeserver due to the limit, but where the user explicitly requested to download a file (for example, using the "save" option), Element could show a dialogue asking whether the file should be fetched directly from the origin homeserver and warning that this will disclose the user's IP to that homeserver. This behaviour could also be editable in settings with options like "prompt" (default), "always yes" and "always no".
This can also be extended further to any file federation errors, although this will require some consideration as not all download errors should trigger this (for instance, a connection timeout due to lack of internet connection should not trigger this). This would additionally help in situations where the "size" key is wrong.
#### Security considerations
Although it seems unlikely this error would be made, better safe than sorry:
- Under no circumstances should the `Authorization` header be sent along with the request as this would disclose a valid session token for the current user to a potentially malicious homeserver.
Otherwise this is quite safe, as any potentially malicious action performed by the origin homeserver can also be performed when the file is downloaded by another homeserver, and this has been considered and mitigated by the spec. Furthermore, the user is warned about the IP address being disclosed.
#### Describe alternatives you've considered.
- Manual downloading - while possible, it's quite inconvenient and some users would not know how to do this
#### Additional context
- [Aforementioned conversation leading to this idea](https://matrix.to/#/!hFdiidJUHZOsUlmhcn:matrix.org/$v5yKMoqeP3bs5yRdfAZ-1FBQyiTS5IUd4E1rDMtLSP8?via=an-atom-in.space&via=matrix.org&via=tchncs.de)
Contributor guide
Assessment
This issue has not been assessed yet.