Fix issue with media path (Fixes #1227)

This commit is contained in:
Benoit Marty 2020-04-15 18:03:20 +02:00
parent cc94b6cf7d
commit e97c95f40a
2 changed files with 5 additions and 5 deletions

View file

@ -7,7 +7,6 @@ Features ✨:
- Cross-Signing | Verify new session from existing session (#1134) - Cross-Signing | Verify new session from existing session (#1134)
- Cross-Signing | Bootstraping cross signing with 4S from mobile (#985) - Cross-Signing | Bootstraping cross signing with 4S from mobile (#985)
Improvements 🙌: Improvements 🙌:
- Verification DM / Handle concurrent .start after .ready (#794) - Verification DM / Handle concurrent .start after .ready (#794)
- Reimplementation of multiple attachment picker - Reimplementation of multiple attachment picker
@ -34,6 +33,7 @@ Bugfix 🐛:
- Fix crash when trying to download file without internet connection (#1229) - Fix crash when trying to download file without internet connection (#1229)
- Local echo are not updated in timeline (for failed & encrypted states) - Local echo are not updated in timeline (for failed & encrypted states)
- Render image event even if thumbnail_info does not have mimetype defined (#1209) - Render image event even if thumbnail_info does not have mimetype defined (#1209)
- Fix issue with media path (#1227)
Translations 🗣: Translations 🗣:
- -

View file

@ -18,10 +18,10 @@ package im.vector.matrix.android.internal.session.content
import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig import im.vector.matrix.android.api.auth.data.HomeServerConnectionConfig
import im.vector.matrix.android.api.session.content.ContentUrlResolver import im.vector.matrix.android.api.session.content.ContentUrlResolver
import im.vector.matrix.android.internal.network.NetworkConstants
import javax.inject.Inject import javax.inject.Inject
private const val MATRIX_CONTENT_URI_SCHEME = "mxc://" private const val MATRIX_CONTENT_URI_SCHEME = "mxc://"
private const val URI_PREFIX_CONTENT_API = "_matrix/media/v1/"
internal class DefaultContentUrlResolver @Inject constructor(private val homeServerConnectionConfig: HomeServerConnectionConfig) : ContentUrlResolver { internal class DefaultContentUrlResolver @Inject constructor(private val homeServerConnectionConfig: HomeServerConnectionConfig) : ContentUrlResolver {
@ -30,14 +30,14 @@ internal class DefaultContentUrlResolver @Inject constructor(private val homeSer
val baseUrl = homeServerConnectionConfig.homeServerUri.toString() val baseUrl = homeServerConnectionConfig.homeServerUri.toString()
val sep = if (baseUrl.endsWith("/")) "" else "/" val sep = if (baseUrl.endsWith("/")) "" else "/"
return baseUrl + sep + URI_PREFIX_CONTENT_API + "upload" return baseUrl + sep + NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "upload"
} }
} }
override fun resolveFullSize(contentUrl: String?): String? { override fun resolveFullSize(contentUrl: String?): String? {
if (contentUrl?.isValidMatrixContentUrl() == true) { if (contentUrl?.isValidMatrixContentUrl() == true) {
val baseUrl = homeServerConnectionConfig.homeServerUri.toString() val baseUrl = homeServerConnectionConfig.homeServerUri.toString()
val prefix = URI_PREFIX_CONTENT_API + "download/" val prefix = NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "download/"
return resolve(baseUrl, contentUrl, prefix) return resolve(baseUrl, contentUrl, prefix)
} }
return null return null
@ -46,7 +46,7 @@ internal class DefaultContentUrlResolver @Inject constructor(private val homeSer
override fun resolveThumbnail(contentUrl: String?, width: Int, height: Int, method: ContentUrlResolver.ThumbnailMethod): String? { override fun resolveThumbnail(contentUrl: String?, width: Int, height: Int, method: ContentUrlResolver.ThumbnailMethod): String? {
if (contentUrl?.isValidMatrixContentUrl() == true) { if (contentUrl?.isValidMatrixContentUrl() == true) {
val baseUrl = homeServerConnectionConfig.homeServerUri.toString() val baseUrl = homeServerConnectionConfig.homeServerUri.toString()
val prefix = URI_PREFIX_CONTENT_API + "thumbnail/" val prefix = NetworkConstants.URI_API_MEDIA_PREFIX_PATH_R0 + "thumbnail/"
val params = "?width=$width&height=$height&method=${method.value}" val params = "?width=$width&height=$height&method=${method.value}"
return resolve(baseUrl, contentUrl, prefix, params) return resolve(baseUrl, contentUrl, prefix, params)
} }