Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ public final class io/getstream/chat/android/client/ChatClient$Builder : io/gets
public final fun okHttpClient (Lokhttp3/OkHttpClient;)Lio/getstream/chat/android/client/ChatClient$Builder;
public final fun retryPolicy (Lio/getstream/result/call/retry/RetryPolicy;)Lio/getstream/chat/android/client/ChatClient$Builder;
public final fun sendMessageInterceptor (Lio/getstream/chat/android/client/interceptor/SendMessageInterceptor;)Lio/getstream/chat/android/client/ChatClient$Builder;
public final fun shareFileDownloadRequestInterceptor (Lokhttp3/Interceptor;)Lio/getstream/chat/android/client/ChatClient$Builder;
public final fun uploadAttachmentsNetworkType (Lio/getstream/chat/android/models/UploadAttachmentsNetworkType;)Lio/getstream/chat/android/client/ChatClient$Builder;
public final fun withApiModelTransformer (Lio/getstream/chat/android/client/transformer/ApiModelTransformers;)Lio/getstream/chat/android/client/ChatClient$Builder;
}
Expand Down Expand Up @@ -805,7 +804,7 @@ public final class io/getstream/chat/android/client/api/state/ChannelsStateData$

public final class io/getstream/chat/android/client/api/state/ChatClientExtensions {
public static final fun cancelEphemeralMessage (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/Message;)Lio/getstream/result/call/Call;
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;
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;
public static final fun getGlobalState (Lio/getstream/chat/android/client/ChatClient;)Lio/getstream/chat/android/client/api/state/GlobalState;
public static final fun getGlobalStateFlow (Lio/getstream/chat/android/client/ChatClient;)Lkotlinx/coroutines/flow/Flow;
public static final fun getMessageUsingCache (Lio/getstream/chat/android/client/ChatClient;Ljava/lang/String;)Lio/getstream/result/call/Call;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.withTimeoutOrNull
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.ResponseBody
import java.io.File
Expand Down Expand Up @@ -4628,7 +4627,6 @@ internal constructor(
private var notificationConfig: NotificationConfig = NotificationConfig(pushNotificationsEnabled = false)
private var fileUploader: FileUploader? = null
private var sendMessageInterceptor: SendMessageInterceptor? = null
private var shareFileDownloadRequestInterceptor: Interceptor? = null
private val tokenManager: TokenManager = TokenManagerImpl()
private var customOkHttpClient: OkHttpClient? = null
private var userCredentialStorage: UserCredentialStorage? = null
Expand Down Expand Up @@ -4761,23 +4759,6 @@ internal constructor(
return this
}

/**
* Sets a custom [Interceptor] that will be used to intercept file download requests for the purpose of sharing
* the file.
* Use this to add custom headers or modify the request in any way.
*
* @param shareFileDownloadRequestInterceptor Your [Interceptor] implementation for the share file download
* call.
* @deprecated Use [io.getstream.chat.android.client.cdn.CDN] instead. Configure a custom CDN via
* [io.getstream.chat.android.client.ChatClient.Builder.cdn] to provide headers and transform URLs
* for all image, file, and download requests.
*/
@Deprecated("Use CDN instead. Configure via ChatClient.Builder.cdn().")
public fun shareFileDownloadRequestInterceptor(shareFileDownloadRequestInterceptor: Interceptor): Builder {
this.shareFileDownloadRequestInterceptor = shareFileDownloadRequestInterceptor
return this
}

/**
* By default, ChatClient performs a dummy HTTP call to the Stream API
* when a user is set to initialize the HTTP connection and make subsequent
Expand Down Expand Up @@ -4991,7 +4972,6 @@ internal constructor(
fileTransformer = fileTransformer,
fileUploader = fileUploader,
sendMessageInterceptor = sendMessageInterceptor,
shareFileDownloadRequestInterceptor = shareFileDownloadRequestInterceptor,
cdn = cdn,
tokenManager = tokenManager,
customOkHttpClient = customOkHttpClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public fun ChatClient.watchChannelAsState(
}

/**
* Performs [ChatClient.queryThreadsResult] under the hood and returns [QueryThreadsState].
* Performs [ChatClient.queryThreads] under the hood and returns [QueryThreadsState].
* The [QueryThreadsState] cannot be created before connecting the user therefore, the method returns a StateFlow
* that emits a null when the user has not been connected yet and the new value every time the user changes.
*
Expand Down Expand Up @@ -295,6 +295,7 @@ public fun ChatClient.setMessageForReply(cid: String, message: Message?): Call<U
}
Result.Success(Unit)
}

is Result.Failure -> cidValidationResult
}
}
Expand All @@ -306,13 +307,10 @@ public fun ChatClient.setMessageForReply(cid: String, message: Message?): Call<U
* If a [CDN][io.getstream.chat.android.client.cdn.CDN] is configured on this [ChatClient], the download URL
* and headers are transformed via [CDN.imageRequest][io.getstream.chat.android.client.cdn.CDN.imageRequest] (for
* images) or [CDN.fileRequest][io.getstream.chat.android.client.cdn.CDN.fileRequest] (for other files) before
* the download is enqueued. CDN transformations are applied after [generateDownloadUri] and before
* [interceptRequest], so custom interceptors can override CDN headers.
* the download is enqueued.
*
* @param context The context used to access the [DownloadManager].
* @param attachment The attachment to download.
* @param generateDownloadUri The function that generates the download URI for the attachment.
* @param interceptRequest The function that intercepts the [DownloadManager.Request] before it's enqueued.
*
* @return Executable async [Call] downloading attachment.
*/
Expand All @@ -321,15 +319,13 @@ public fun ChatClient.setMessageForReply(cid: String, message: Message?): Call<U
public fun ChatClient.downloadAttachment(
context: Context,
attachment: Attachment,
generateDownloadUri: (Attachment) -> Uri,
interceptRequest: DownloadManager.Request.() -> Unit,
): Call<Unit> {
return CoroutineCall(inheritScope { Job(it) }) {
val logger by taggedLogger("Chat:DownloadAttachment")

try {
val downloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
val uri = generateDownloadUri(attachment)
val uri = Uri.parse(attachment.assetUrl ?: attachment.imageUrl)
val subPath = attachment.name ?: attachment.title ?: attachment.parseAttachmentNameFromUrl()
?: createAttachmentFallbackName()

Expand All @@ -355,8 +351,7 @@ public fun ChatClient.downloadAttachment(
cdnRequest?.headers?.forEach { (key, value) ->
addRequestHeader(key, value)
}
}
.apply(interceptRequest),
},
)
Result.Success(Unit)
} catch (exception: Exception) {
Expand All @@ -383,6 +378,7 @@ public fun ChatClient.loadOlderMessages(cid: String, messageLimit: Int): Call<Ch
logic.channel(channelType = channelType, channelId = channelId)
.loadBefore(messageId = null, limit = messageLimit)
}

is Result.Failure -> cidValidationResult
}
}
Expand All @@ -404,6 +400,7 @@ public fun ChatClient.loadNewerMessages(
logic.channel(channelType = channelType, channelId = channelId)
.loadAfter(messageId = baseMessageId, limit = messageLimit)
}

is Result.Failure -> cidValidationResult
}
}
Expand All @@ -429,6 +426,7 @@ public fun ChatClient.loadMessagesAroundId(
logic.channel(channelType = channelType, channelId = channelId)
.loadAround(messageId)
}

is Result.Failure -> cidValidationResult
}
}
Expand Down Expand Up @@ -464,6 +462,7 @@ public fun ChatClient.cancelEphemeralMessage(message: Message): Call<Boolean> {
)
}
}

is Result.Failure -> cidValidationResult
}
}
Expand Down Expand Up @@ -536,6 +535,7 @@ private suspend fun ChatClient.loadMessageByIdInternal(
Result.Failure(Error.GenericError("The message could not be found."))
}
}

is Result.Failure -> Result.Failure(
Error.GenericError("Error while fetching messages from backend. Messages around id: $messageId"),
)
Expand Down Expand Up @@ -566,6 +566,7 @@ public fun ChatClient.loadNewestMessages(
logic.channel(channelType = channelType, channelId = channelId)
.watch(messageLimit, userPresence)
}

is Result.Failure -> Result.Failure(cidValidationResult.value)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ import java.util.concurrent.TimeUnit
* @param fileUploader Optional custom [FileUploader]; if null, a default [StreamFileUploader] is used.
* @param sendMessageInterceptor Interceptor allowing to override the logic for sending messages with your own custom
* logic.
* @param shareFileDownloadRequestInterceptor Optional interceptor to customize file download requests done for the
* purpose of sharing the file.
* @param cdn Optional [CDN] implementation for transforming file download URLs and injecting headers.
* @param tokenManager Manager that provides and refreshes auth tokens for authenticated requests.
* @param customOkHttpClient Optional base [OkHttpClient] to reuse threads/connection pools and customize networking.
Expand All @@ -134,7 +132,6 @@ constructor(
private val fileTransformer: FileTransformer,
private val fileUploader: FileUploader?,
private val sendMessageInterceptor: SendMessageInterceptor?,
private val shareFileDownloadRequestInterceptor: Interceptor?,
private val cdn: CDN?,
private val tokenManager: TokenManager,
private val customOkHttpClient: OkHttpClient?,
Expand Down Expand Up @@ -393,7 +390,6 @@ constructor(
val okHttpClient = baseClientBuilder(BASE_TIMEOUT)
.apply {
cdn?.let { addInterceptor(CDNOkHttpInterceptor(it)) }
shareFileDownloadRequestInterceptor?.let { addInterceptor(it) }
}
.build()
return Retrofit.Builder()
Expand Down
Loading
Loading