diff --git a/common/src/main/kotlin/chat/rocket/common/model/Email.kt b/common/src/main/kotlin/chat/rocket/common/model/Email.kt deleted file mode 100644 index a940d9b0..00000000 --- a/common/src/main/kotlin/chat/rocket/common/model/Email.kt +++ /dev/null @@ -1,10 +0,0 @@ -package chat.rocket.common.model - -import se.ansman.kotshi.JsonDefaultValueBoolean -import se.ansman.kotshi.JsonSerializable - -@JsonSerializable -data class Email(val address: String, - @JsonDefaultValueBoolean(false) - val verified: Boolean -) \ No newline at end of file diff --git a/common/src/main/kotlin/chat/rocket/common/model/User.kt b/common/src/main/kotlin/chat/rocket/common/model/User.kt deleted file mode 100644 index 1a7e4a37..00000000 --- a/common/src/main/kotlin/chat/rocket/common/model/User.kt +++ /dev/null @@ -1,15 +0,0 @@ -package chat.rocket.common.model - -import com.squareup.moshi.Json -import se.ansman.kotshi.JsonSerializable - -@JsonSerializable -data class User( - @Json(name = "_id") val id: String, - override val username: String? = null, - override val name: String? = null, - val status: UserStatus? = null, - val utcOffset: Float? = null, - val emails: List? = null, - val roles: List? = null -) : BaseUser \ No newline at end of file diff --git a/compat/src/main/kotlin/chat/rocket/core/compat/User.kt b/compat/src/main/kotlin/chat/rocket/core/compat/User.kt index 4b96a963..7cddffe2 100644 --- a/compat/src/main/kotlin/chat/rocket/core/compat/User.kt +++ b/compat/src/main/kotlin/chat/rocket/core/compat/User.kt @@ -3,7 +3,7 @@ package chat.rocket.core.compat import chat.rocket.core.RocketChatClient import chat.rocket.core.compat.internal.callback import chat.rocket.core.internal.rest.me -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import kotlinx.coroutines.experimental.CommonPool /** @@ -14,7 +14,7 @@ import kotlinx.coroutines.experimental.CommonPool * @see * @see RocketChatException */ -fun RocketChatClient.me(future: Callback): Call = +fun RocketChatClient.me(future: Callback): Call = callback(CommonPool, future) { me() } \ No newline at end of file diff --git a/core/src/main/kotlin/chat/rocket/core/RocketChatClient.kt b/core/src/main/kotlin/chat/rocket/core/RocketChatClient.kt index e282c3a7..153355bd 100644 --- a/core/src/main/kotlin/chat/rocket/core/RocketChatClient.kt +++ b/core/src/main/kotlin/chat/rocket/core/RocketChatClient.kt @@ -4,7 +4,6 @@ import chat.rocket.common.CommonJsonAdapterFactory import chat.rocket.common.internal.FallbackSealedClassJsonAdapter import chat.rocket.common.internal.ISO8601Date import chat.rocket.common.model.TimestampAdapter -import chat.rocket.common.model.User import chat.rocket.common.util.CalendarISO8601Converter import chat.rocket.common.util.Logger import chat.rocket.common.util.NoOpLogger @@ -23,7 +22,7 @@ import chat.rocket.core.internal.realtime.socket.Socket import chat.rocket.core.internal.realtime.socket.model.State import chat.rocket.core.internal.realtime.socket.model.StreamMessage import chat.rocket.core.model.Message -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import chat.rocket.core.model.Room import chat.rocket.core.model.url.MetaJsonAdapter import com.squareup.moshi.Moshi @@ -62,7 +61,7 @@ class RocketChatClient private constructor( val roomsChannel = Channel>(Channel.UNLIMITED) val subscriptionsChannel = Channel>(Channel.UNLIMITED) val messagesChannel = Channel(Channel.UNLIMITED) - val userDataChannel = Channel(Channel.UNLIMITED) + val userDataChannel = Channel(Channel.UNLIMITED) val activeUsersChannel = Channel(Channel.UNLIMITED) val typingStatusChannel = Channel>(Channel.UNLIMITED) internal val socket: Socket diff --git a/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/Socket.kt b/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/Socket.kt index 9dd5be32..d16433fd 100644 --- a/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/Socket.kt +++ b/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/Socket.kt @@ -1,6 +1,5 @@ package chat.rocket.core.internal.realtime.socket -import chat.rocket.common.model.User import chat.rocket.core.RocketChatClient import chat.rocket.core.internal.model.Subscription import chat.rocket.core.internal.realtime.message.CONNECT_MESSAGE @@ -12,7 +11,7 @@ import chat.rocket.core.internal.realtime.socket.model.ReconnectionStrategy import chat.rocket.core.internal.realtime.socket.model.State import chat.rocket.core.internal.realtime.socket.model.StreamMessage import chat.rocket.core.model.Message -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import chat.rocket.core.model.Room import com.squareup.moshi.JsonAdapter import kotlinx.coroutines.experimental.Job @@ -39,7 +38,7 @@ class Socket( internal val roomsChannel: SendChannel>, internal val subscriptionsChannel: SendChannel>, internal val messagesChannel: SendChannel, - internal val userDataChannel: SendChannel, + internal val userDataChannel: SendChannel, internal val activeUsersChannel: SendChannel, internal val typingStatusChannel: SendChannel> ) : WebSocketListener() { diff --git a/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/message/collection/Users.kt b/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/message/collection/Users.kt index 65086d9b..4e54c150 100644 --- a/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/message/collection/Users.kt +++ b/core/src/main/kotlin/chat/rocket/core/internal/realtime/socket/message/collection/Users.kt @@ -1,8 +1,7 @@ package chat.rocket.core.internal.realtime.socket.message.collection -import chat.rocket.common.model.User import chat.rocket.core.internal.realtime.socket.Socket -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import kotlinx.coroutines.experimental.launch import org.json.JSONObject @@ -29,7 +28,7 @@ private fun Socket.processUserDataStream(json: JSONObject, id: String) { val fields = json.optJSONObject("fields") fields.put("_id", id) - val adapter = moshi.adapter(Myself::class.java) + val adapter = moshi.adapter(User::class.java) val myself = adapter.fromJson(fields.toString()) myself?.let { if (parentJob == null || !parentJob!!.isActive) { diff --git a/core/src/main/kotlin/chat/rocket/core/internal/rest/ChatRoom.kt b/core/src/main/kotlin/chat/rocket/core/internal/rest/ChatRoom.kt index c7ba2a78..d5babb6b 100644 --- a/core/src/main/kotlin/chat/rocket/core/internal/rest/ChatRoom.kt +++ b/core/src/main/kotlin/chat/rocket/core/internal/rest/ChatRoom.kt @@ -2,7 +2,6 @@ package chat.rocket.core.internal.rest import chat.rocket.common.model.BaseResult import chat.rocket.common.model.RoomType -import chat.rocket.common.model.User import chat.rocket.core.RocketChatClient import chat.rocket.core.internal.model.ChatRoomAnnouncementPayload import chat.rocket.core.internal.model.ChatRoomDescriptionPayload @@ -16,10 +15,7 @@ import chat.rocket.core.internal.model.ChatRoomTypePayload import chat.rocket.core.internal.model.ChatRoomFavoritePayload import chat.rocket.core.internal.RestResult import chat.rocket.core.internal.model.RoomIdPayload -import chat.rocket.core.model.ChatRoomRole -import chat.rocket.core.model.Message -import chat.rocket.core.model.Room -import chat.rocket.core.model.PagedResult +import chat.rocket.core.model.* import chat.rocket.core.model.attachment.GenericAttachment import com.squareup.moshi.Types import kotlinx.coroutines.experimental.CommonPool diff --git a/core/src/main/kotlin/chat/rocket/core/internal/rest/Login.kt b/core/src/main/kotlin/chat/rocket/core/internal/rest/Login.kt index 5be58564..af547004 100644 --- a/core/src/main/kotlin/chat/rocket/core/internal/rest/Login.kt +++ b/core/src/main/kotlin/chat/rocket/core/internal/rest/Login.kt @@ -3,7 +3,6 @@ package chat.rocket.core.internal.rest import chat.rocket.common.RocketChatException import chat.rocket.common.model.BaseResult import chat.rocket.common.model.Token -import chat.rocket.common.model.User import chat.rocket.core.RocketChatClient import chat.rocket.core.internal.RestResult import chat.rocket.core.internal.model.CasLoginPayload @@ -16,6 +15,7 @@ import chat.rocket.core.internal.model.SignUpPayload import chat.rocket.core.internal.model.ForgotPasswordPayload import chat.rocket.core.internal.model.CasData import chat.rocket.core.internal.model.OauthData +import chat.rocket.core.model.User import com.squareup.moshi.Types import kotlinx.coroutines.experimental.CommonPool import kotlinx.coroutines.experimental.withContext diff --git a/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt b/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt index 969ca0e8..6dc3ee87 100644 --- a/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt +++ b/core/src/main/kotlin/chat/rocket/core/internal/rest/User.kt @@ -3,7 +3,6 @@ package chat.rocket.core.internal.rest import chat.rocket.common.RocketChatException import chat.rocket.common.model.BaseResult import chat.rocket.common.model.RoomType -import chat.rocket.common.model.User import chat.rocket.common.util.CalendarISO8601Converter import chat.rocket.core.RocketChatClient import chat.rocket.core.internal.RestMultiResult @@ -15,7 +14,7 @@ import chat.rocket.core.internal.model.OwnBasicInformationPayload import chat.rocket.core.internal.model.OwnBasicInformationPayloadData import chat.rocket.core.internal.model.PasswordPayload import chat.rocket.core.model.ChatRoom -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import chat.rocket.core.model.Removed import chat.rocket.core.model.UserRole import chat.rocket.core.model.Room @@ -32,14 +31,14 @@ import java.io.InputStream * Returns the current logged user information, useful to check if the Token from TokenProvider * is still valid. * - * @see Myself + * @see User * @see RocketChatException */ -suspend fun RocketChatClient.me(): Myself { +suspend fun RocketChatClient.me(): User { val httpUrl = requestUrl(restUrl, "me").build() val request = requestBuilderForAuthenticatedMethods(httpUrl).get().build() - return handleRestCall(request, Myself::class.java) + return handleRestCall(request, User::class.java) } /** diff --git a/core/src/main/kotlin/chat/rocket/core/model/SpotlightResult.kt b/core/src/main/kotlin/chat/rocket/core/model/SpotlightResult.kt index f8161b3d..634282a9 100644 --- a/core/src/main/kotlin/chat/rocket/core/model/SpotlightResult.kt +++ b/core/src/main/kotlin/chat/rocket/core/model/SpotlightResult.kt @@ -1,6 +1,5 @@ package chat.rocket.core.model -import chat.rocket.common.model.User import se.ansman.kotshi.JsonSerializable @JsonSerializable diff --git a/core/src/main/kotlin/chat/rocket/core/model/Myself.kt b/core/src/main/kotlin/chat/rocket/core/model/User.kt similarity index 96% rename from core/src/main/kotlin/chat/rocket/core/model/Myself.kt rename to core/src/main/kotlin/chat/rocket/core/model/User.kt index a49bf9e5..1485bd4d 100644 --- a/core/src/main/kotlin/chat/rocket/core/model/Myself.kt +++ b/core/src/main/kotlin/chat/rocket/core/model/User.kt @@ -6,7 +6,7 @@ import com.squareup.moshi.Json import se.ansman.kotshi.JsonSerializable @JsonSerializable -data class Myself( +data class User( @Json(name = "_id") val id: String, val active: Boolean?, override val username: String?, diff --git a/rxjava/src/main/kotlin/chat/rocket/core/rxjava/Login.kt b/rxjava/src/main/kotlin/chat/rocket/core/rxjava/Login.kt index 1cffbdb2..fadbd313 100644 --- a/rxjava/src/main/kotlin/chat/rocket/core/rxjava/Login.kt +++ b/rxjava/src/main/kotlin/chat/rocket/core/rxjava/Login.kt @@ -1,10 +1,10 @@ package chat.rocket.core.rxjava import chat.rocket.common.model.Token -import chat.rocket.common.model.User import chat.rocket.core.RocketChatClient import chat.rocket.core.internal.rest.login import chat.rocket.core.internal.rest.signup +import chat.rocket.core.model.User import io.reactivex.Single import kotlinx.coroutines.experimental.rx2.rxSingle diff --git a/rxjava/src/main/kotlin/chat/rocket/core/rxjava/User.kt b/rxjava/src/main/kotlin/chat/rocket/core/rxjava/User.kt index dff1f930..b6b8004a 100644 --- a/rxjava/src/main/kotlin/chat/rocket/core/rxjava/User.kt +++ b/rxjava/src/main/kotlin/chat/rocket/core/rxjava/User.kt @@ -2,11 +2,11 @@ package chat.rocket.core.rxjava import chat.rocket.core.RocketChatClient import chat.rocket.core.internal.rest.me -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import io.reactivex.Single import kotlinx.coroutines.experimental.rx2.rxSingle -fun RocketChatClient.me(): Single = +fun RocketChatClient.me(): Single = rxSingle { me() } \ No newline at end of file diff --git a/sample/src/main/kotlin/rocket/chat/kotlin/sample/Sample.kt b/sample/src/main/kotlin/rocket/chat/kotlin/sample/Sample.kt index 9ee34815..2aed7e60 100644 --- a/sample/src/main/kotlin/rocket/chat/kotlin/sample/Sample.kt +++ b/sample/src/main/kotlin/rocket/chat/kotlin/sample/Sample.kt @@ -4,7 +4,6 @@ import chat.rocket.common.RocketChatException import chat.rocket.common.model.RoomType import chat.rocket.common.model.ServerInfo import chat.rocket.common.model.Token -import chat.rocket.common.model.UserStatus import chat.rocket.common.util.PlatformLogger import chat.rocket.core.RocketChatClient import chat.rocket.core.TokenRepository @@ -17,7 +16,7 @@ import chat.rocket.core.internal.rest.chatRooms import chat.rocket.core.internal.rest.getFavoriteMessages import chat.rocket.core.internal.rest.getFiles import chat.rocket.core.internal.rest.login -import chat.rocket.core.model.Myself +import chat.rocket.core.model.User import chat.rocket.core.model.history import chat.rocket.core.model.messages import chat.rocket.core.rxjava.me @@ -25,10 +24,8 @@ import io.reactivex.Single import io.reactivex.schedulers.Schedulers import kotlinx.coroutines.experimental.CommonPool import kotlinx.coroutines.experimental.channels.Channel -import kotlinx.coroutines.experimental.delay import kotlinx.coroutines.experimental.launch import kotlinx.coroutines.experimental.runBlocking -import kotlinx.coroutines.experimental.suspendCancellableCoroutine import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import java.util.concurrent.TimeUnit @@ -180,8 +177,8 @@ fun main(args: Array) { fun getMeInfoByRx(client: RocketChatClient) { // using RxJava2 - val myself: Single = client.me() - myself + val user: Single = client.me() + user .subscribeOn(Schedulers.io()) .observeOn(Schedulers.newThread()) .subscribe { self ->