Skip to content

Commit 0a55c38

Browse files
authored
Remove deprecated CDN customisation options (#6326)
* Remove deprecated CDN customisation APIs * Api dump.
1 parent 9de79c4 commit 0a55c38

38 files changed

Lines changed: 251 additions & 1518 deletions

File tree

stream-chat-android-client/api/stream-chat-android-client.api

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ public final class io/getstream/chat/android/client/ChatClient$Builder : io/gets
285285
public final fun okHttpClient (Lokhttp3/OkHttpClient;)Lio/getstream/chat/android/client/ChatClient$Builder;
286286
public final fun retryPolicy (Lio/getstream/result/call/retry/RetryPolicy;)Lio/getstream/chat/android/client/ChatClient$Builder;
287287
public final fun sendMessageInterceptor (Lio/getstream/chat/android/client/interceptor/SendMessageInterceptor;)Lio/getstream/chat/android/client/ChatClient$Builder;
288-
public final fun shareFileDownloadRequestInterceptor (Lokhttp3/Interceptor;)Lio/getstream/chat/android/client/ChatClient$Builder;
289288
public final fun uploadAttachmentsNetworkType (Lio/getstream/chat/android/models/UploadAttachmentsNetworkType;)Lio/getstream/chat/android/client/ChatClient$Builder;
290289
public final fun withApiModelTransformer (Lio/getstream/chat/android/client/transformer/ApiModelTransformers;)Lio/getstream/chat/android/client/ChatClient$Builder;
291290
}
@@ -805,7 +804,7 @@ public final class io/getstream/chat/android/client/api/state/ChannelsStateData$
805804

806805
public final class io/getstream/chat/android/client/api/state/ChatClientExtensions {
807806
public static final fun cancelEphemeralMessage (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call;
808-
public static final fun downloadAttachment (Lio/getstream/chat/android/client/ChatClient;Landroid/content/Context;Lio/getstream/chat/android/models/Attachment;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lio/getstream/result/call/Call;
807+
public static final fun downloadAttachment (Lio/getstream/chat/android/client/ChatClient;Landroid/content/Context;Lio/getstream/chat/android/models/Attachment;)Lio/getstream/result/call/Call;
809808
public static final fun getGlobalState (Lio/getstream/chat/android/client/ChatClient;)Lio/getstream/chat/android/client/api/state/GlobalState;
810809
public static final fun getGlobalStateFlow (Lio/getstream/chat/android/client/ChatClient;)Lkotlinx/coroutines/flow/Flow;
811810
public static final fun getMessageUsingCache (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;)Lio/getstream/result/call/Call;

stream-chat-android-client/src/main/java/io/getstream/chat/android/client/ChatClient.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ import kotlinx.coroutines.sync.Mutex
253253
import kotlinx.coroutines.sync.withLock
254254
import kotlinx.coroutines.withTimeout
255255
import kotlinx.coroutines.withTimeoutOrNull
256-
import okhttp3.Interceptor
257256
import okhttp3.OkHttpClient
258257
import okhttp3.ResponseBody
259258
import java.io.File
@@ -4628,7 +4627,6 @@ internal constructor(
46284627
private var notificationConfig: NotificationConfig = NotificationConfig(pushNotificationsEnabled = false)
46294628
private var fileUploader: FileUploader? = null
46304629
private var sendMessageInterceptor: SendMessageInterceptor? = null
4631-
private var shareFileDownloadRequestInterceptor: Interceptor? = null
46324630
private val tokenManager: TokenManager = TokenManagerImpl()
46334631
private var customOkHttpClient: OkHttpClient? = null
46344632
private var userCredentialStorage: UserCredentialStorage? = null
@@ -4761,23 +4759,6 @@ internal constructor(
47614759
return this
47624760
}
47634761

4764-
/**
4765-
* Sets a custom [Interceptor] that will be used to intercept file download requests for the purpose of sharing
4766-
* the file.
4767-
* Use this to add custom headers or modify the request in any way.
4768-
*
4769-
* @param shareFileDownloadRequestInterceptor Your [Interceptor] implementation for the share file download
4770-
* call.
4771-
* @deprecated Use [io.getstream.chat.android.client.cdn.CDN] instead. Configure a custom CDN via
4772-
* [io.getstream.chat.android.client.ChatClient.Builder.cdn] to provide headers and transform URLs
4773-
* for all image, file, and download requests.
4774-
*/
4775-
@Deprecated("Use CDN instead. Configure via ChatClient.Builder.cdn().")
4776-
public fun shareFileDownloadRequestInterceptor(shareFileDownloadRequestInterceptor: Interceptor): Builder {
4777-
this.shareFileDownloadRequestInterceptor = shareFileDownloadRequestInterceptor
4778-
return this
4779-
}
4780-
47814762
/**
47824763
* By default, ChatClient performs a dummy HTTP call to the Stream API
47834764
* when a user is set to initialize the HTTP connection and make subsequent
@@ -4991,7 +4972,6 @@ internal constructor(
49914972
fileTransformer = fileTransformer,
49924973
fileUploader = fileUploader,
49934974
sendMessageInterceptor = sendMessageInterceptor,
4994-
shareFileDownloadRequestInterceptor = shareFileDownloadRequestInterceptor,
49954975
cdn = cdn,
49964976
tokenManager = tokenManager,
49974977
customOkHttpClient = customOkHttpClient,

stream-chat-android-client/src/main/java/io/getstream/chat/android/client/api/state/ChatClientStateExtensions.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public fun ChatClient.watchChannelAsState(
190190
}
191191

192192
/**
193-
* Performs [ChatClient.queryThreadsResult] under the hood and returns [QueryThreadsState].
193+
* Performs [ChatClient.queryThreads] under the hood and returns [QueryThreadsState].
194194
* The [QueryThreadsState] cannot be created before connecting the user therefore, the method returns a StateFlow
195195
* that emits a null when the user has not been connected yet and the new value every time the user changes.
196196
*
@@ -295,6 +295,7 @@ public fun ChatClient.setMessageForReply(cid: String, message: Message?): Call<U
295295
}
296296
Result.Success(Unit)
297297
}
298+
298299
is Result.Failure -> cidValidationResult
299300
}
300301
}
@@ -306,13 +307,10 @@ public fun ChatClient.setMessageForReply(cid: String, message: Message?): Call<U
306307
* If a [CDN][io.getstream.chat.android.client.cdn.CDN] is configured on this [ChatClient], the download URL
307308
* and headers are transformed via [CDN.imageRequest][io.getstream.chat.android.client.cdn.CDN.imageRequest] (for
308309
* images) or [CDN.fileRequest][io.getstream.chat.android.client.cdn.CDN.fileRequest] (for other files) before
309-
* the download is enqueued. CDN transformations are applied after [generateDownloadUri] and before
310-
* [interceptRequest], so custom interceptors can override CDN headers.
310+
* the download is enqueued.
311311
*
312312
* @param context The context used to access the [DownloadManager].
313313
* @param attachment The attachment to download.
314-
* @param generateDownloadUri The function that generates the download URI for the attachment.
315-
* @param interceptRequest The function that intercepts the [DownloadManager.Request] before it's enqueued.
316314
*
317315
* @return Executable async [Call] downloading attachment.
318316
*/
@@ -321,15 +319,13 @@ public fun ChatClient.setMessageForReply(cid: String, message: Message?): Call<U
321319
public fun ChatClient.downloadAttachment(
322320
context: Context,
323321
attachment: Attachment,
324-
generateDownloadUri: (Attachment) -> Uri,
325-
interceptRequest: DownloadManager.Request.() -> Unit,
326322
): Call<Unit> {
327323
return CoroutineCall(inheritScope { Job(it) }) {
328324
val logger by taggedLogger("Chat:DownloadAttachment")
329325

330326
try {
331327
val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
332-
val uri = generateDownloadUri(attachment)
328+
val uri = Uri.parse(attachment.assetUrl ?: attachment.imageUrl)
333329
val subPath = attachment.name ?: attachment.title ?: attachment.parseAttachmentNameFromUrl()
334330
?: createAttachmentFallbackName()
335331

@@ -355,8 +351,7 @@ public fun ChatClient.downloadAttachment(
355351
cdnRequest?.headers?.forEach { (key, value) ->
356352
addRequestHeader(key, value)
357353
}
358-
}
359-
.apply(interceptRequest),
354+
},
360355
)
361356
Result.Success(Unit)
362357
} catch (exception: Exception) {
@@ -383,6 +378,7 @@ public fun ChatClient.loadOlderMessages(cid: String, messageLimit: Int): Call<Ch
383378
logic.channel(channelType = channelType, channelId = channelId)
384379
.loadBefore(messageId = null, limit = messageLimit)
385380
}
381+
386382
is Result.Failure -> cidValidationResult
387383
}
388384
}
@@ -404,6 +400,7 @@ public fun ChatClient.loadNewerMessages(
404400
logic.channel(channelType = channelType, channelId = channelId)
405401
.loadAfter(messageId = baseMessageId, limit = messageLimit)
406402
}
403+
407404
is Result.Failure -> cidValidationResult
408405
}
409406
}
@@ -429,6 +426,7 @@ public fun ChatClient.loadMessagesAroundId(
429426
logic.channel(channelType = channelType, channelId = channelId)
430427
.loadAround(messageId)
431428
}
429+
432430
is Result.Failure -> cidValidationResult
433431
}
434432
}
@@ -464,6 +462,7 @@ public fun ChatClient.cancelEphemeralMessage(message: Message): Call<Boolean> {
464462
)
465463
}
466464
}
465+
467466
is Result.Failure -> cidValidationResult
468467
}
469468
}
@@ -536,6 +535,7 @@ private suspend fun ChatClient.loadMessageByIdInternal(
536535
Result.Failure(Error.GenericError("The message could not be found."))
537536
}
538537
}
538+
539539
is Result.Failure -> Result.Failure(
540540
Error.GenericError("Error while fetching messages from backend. Messages around id: $messageId"),
541541
)
@@ -566,6 +566,7 @@ public fun ChatClient.loadNewestMessages(
566566
logic.channel(channelType = channelType, channelId = channelId)
567567
.watch(messageLimit, userPresence)
568568
}
569+
569570
is Result.Failure -> Result.Failure(cidValidationResult.value)
570571
}
571572
}

stream-chat-android-client/src/main/java/io/getstream/chat/android/client/di/ChatModule.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ import java.util.concurrent.TimeUnit
110110
* @param fileUploader Optional custom [FileUploader]; if null, a default [StreamFileUploader] is used.
111111
* @param sendMessageInterceptor Interceptor allowing to override the logic for sending messages with your own custom
112112
* logic.
113-
* @param shareFileDownloadRequestInterceptor Optional interceptor to customize file download requests done for the
114-
* purpose of sharing the file.
115113
* @param cdn Optional [CDN] implementation for transforming file download URLs and injecting headers.
116114
* @param tokenManager Manager that provides and refreshes auth tokens for authenticated requests.
117115
* @param customOkHttpClient Optional base [OkHttpClient] to reuse threads/connection pools and customize networking.
@@ -134,7 +132,6 @@ constructor(
134132
private val fileTransformer: FileTransformer,
135133
private val fileUploader: FileUploader?,
136134
private val sendMessageInterceptor: SendMessageInterceptor?,
137-
private val shareFileDownloadRequestInterceptor: Interceptor?,
138135
private val cdn: CDN?,
139136
private val tokenManager: TokenManager,
140137
private val customOkHttpClient: OkHttpClient?,
@@ -393,7 +390,6 @@ constructor(
393390
val okHttpClient = baseClientBuilder(BASE_TIMEOUT)
394391
.apply {
395392
cdn?.let { addInterceptor(CDNOkHttpInterceptor(it)) }
396-
shareFileDownloadRequestInterceptor?.let { addInterceptor(it) }
397393
}
398394
.build()
399395
return Retrofit.Builder()

0 commit comments

Comments
 (0)