Skip to content

Commit e7379f3

Browse files
zerox80guruz
authored andcommitted
Fix: Remove legacy PHP endpoints for thumbnails and avatars
- Update FILE_PREVIEW_URI to use direct native /webdav path. - Use Graph API explicitly for fetching Avatar image, dropping the /index.php/avatar hack & interceptor fallbacks.
1 parent 6c370a5 commit e7379f3

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

opencloudApp/src/main/java/eu/opencloud/android/presentation/thumbnails/ThumbnailsRequester.kt

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object ThumbnailsRequester : KoinComponent {
5353
private val clientManager: ClientManager by inject()
5454

5555
private const val SPACE_SPECIAL_PREVIEW_URI = "%s?scalingup=0&a=1&x=%d&y=%d&c=%s&preview=1"
56-
private const val FILE_PREVIEW_URI = "%s/remote.php/webdav%s?x=%d&y=%d&c=%s&preview=1"
56+
private const val FILE_PREVIEW_URI = "%s/webdav%s?x=%d&y=%d&c=%s&preview=1"
5757

5858
private const val DISK_CACHE_SIZE: Long = 1024 * 1024 * 100 // 100MB
5959

@@ -77,8 +77,7 @@ object ThumbnailsRequester : KoinComponent {
7777
accountManager.getUserData(account, eu.opencloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_BASE_URL)
7878
?.trimEnd('/')
7979
.orEmpty()
80-
val username = AccountUtils.getUsernameOfAccount(account.name)
81-
return "$baseUrl/index.php/avatar/${android.net.Uri.encode(username)}/384"
80+
return "$baseUrl/graph/v1.0/me/photo/\$value"
8281
}
8382

8483
fun getPreviewUriForFile(file: OCFile, account: Account, etag: String? = null, width: Int = 1024, height: Int = 1024): String =
@@ -150,20 +149,6 @@ object ThumbnailsRequester : KoinComponent {
150149

151150
var response = chain.proceed(requestWithHeaders)
152151

153-
val originalUrl = requestWithHeaders.url.toString()
154-
if (
155-
originalUrl.contains("/index.php/avatar/") &&
156-
(!response.isSuccessful || !isProbablyAnImage(response))
157-
) {
158-
response.close()
159-
160-
val baseUrl = originalUrl.substringBefore("/index.php/avatar/").trimEnd('/')
161-
val graphUrl = "$baseUrl/graph/v1.0/me/photo/\$value"
162-
163-
val graphRequest = requestWithHeaders.newBuilder().url(graphUrl).build()
164-
response = chain.proceed(graphRequest)
165-
}
166-
167152
var builder = response.newBuilder()
168153
var changed = false
169154

0 commit comments

Comments
 (0)