Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Add method for new API endpoint users.requestDataDownload #247

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions compat/src/main/kotlin/chat/rocket/core/compat/Server.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import chat.rocket.core.RocketChatClient
import chat.rocket.core.compat.internal.callback
import chat.rocket.core.internal.rest.serverInfo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.InternalCoroutinesApi

/**
* Returns the current logged server information.
* Must be used with a coroutine context (async, launch, etc)
*/
@ExperimentalCoroutinesApi
@InternalCoroutinesApi
fun RocketChatClient.serverInfo(future: Callback<ServerInfo>): Call = callback(Dispatchers.IO, future) { serverInfo() }
4 changes: 4 additions & 0 deletions compat/src/main/kotlin/chat/rocket/core/compat/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import chat.rocket.core.compat.internal.callback
import chat.rocket.core.internal.rest.me
import chat.rocket.core.model.Myself
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.InternalCoroutinesApi

/**
* Returns the current logged user information, useful to check if the Token from TokenProvider
* is still valid. Must be used with a coroutine context (async, launch, etc)
*/
@ExperimentalCoroutinesApi
@InternalCoroutinesApi
fun RocketChatClient.me(future: Callback<Myself>): Call = callback(Dispatchers.IO, future) { me() }
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import chat.rocket.core.compat.Callback
import kotlinx.coroutines.AbstractCoroutine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.InternalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.newCoroutineContext
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.startCoroutine

@ExperimentalCoroutinesApi
@InternalCoroutinesApi
@JvmOverloads
fun <T> callback(
context: CoroutineContext = Dispatchers.Default,
Expand All @@ -26,7 +29,7 @@ fun <T> callback(
return Call(job)
}

@UseExperimental(InternalCoroutinesApi::class)
@InternalCoroutinesApi
private class CallbackCoroutine<in T>(
parentContext: CoroutineContext,
private val callback: Callback<T>
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/kotlin/chat/rocket/core/RocketChatClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import chat.rocket.core.internal.SettingsAdapter
import chat.rocket.core.internal.AttachmentAdapterFactory
import chat.rocket.core.internal.RoomListAdapterFactory
import chat.rocket.core.internal.CoreJsonAdapterFactory
import chat.rocket.core.internal.MessageListAdapterFactory
import chat.rocket.core.internal.ReactionsAdapter
import chat.rocket.core.internal.model.Subscription
import chat.rocket.core.internal.realtime.socket.Socket
Expand Down Expand Up @@ -53,6 +54,7 @@ class RocketChatClient private constructor(
.add(SettingsAdapter())
.add(AttachmentAdapterFactory(logger))
.add(RoomListAdapterFactory(logger))
.add(MessageListAdapterFactory(logger))
.add(MetaJsonAdapter.ADAPTER_FACTORY)
.add(java.lang.Long::class.java, ISO8601Date::class.java, TimestampAdapter(CalendarISO8601Converter()))
.add(Long::class.java, ISO8601Date::class.java, TimestampAdapter(CalendarISO8601Converter()))
Expand Down
Loading