From 54fb54a6952b7655b687718505c41c1cda2bff23 Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 3 Oct 2018 19:00:02 +0200 Subject: [PATCH] Sync : add sync response model --- .../matrix/core/internal/sync/SyncAPI.kt | 15 ++++++ .../core/internal/sync/data/DeviceInfo.kt | 53 +++++++++++++++++++ .../internal/sync/data/DeviceListResponse.kt | 29 ++++++++++ .../DeviceOneTimeKeysCountSyncResponse.kt | 9 ++++ .../internal/sync/data/DevicesListResponse.kt | 26 +++++++++ .../internal/sync/data/InvitedRoomSync.kt | 32 +++++++++++ .../sync/data/PresenceSyncResponse.kt | 14 +++++ .../internal/sync/data/RoomInviteState.kt | 30 +++++++++++ .../core/internal/sync/data/RoomResponse.kt | 41 ++++++++++++++ .../core/internal/sync/data/RoomSync.kt | 48 +++++++++++++++++ .../internal/sync/data/RoomSyncAccountData.kt | 12 +++++ .../internal/sync/data/RoomSyncEphemeral.kt | 14 +++++ .../core/internal/sync/data/RoomSyncState.kt | 29 ++++++++++ .../internal/sync/data/RoomSyncTimeline.kt | 25 +++++++++ .../sync/data/RoomSyncUnreadNotifications.kt | 25 +++++++++ .../internal/sync/data/RoomsSyncResponse.kt | 36 +++++++++++++ .../core/internal/sync/data/SyncResponse.kt | 44 +++++++++++++++ .../sync/data/ToDeviceSyncResponse.kt | 15 ++++++ .../internal/sync/data/TokensChunkResponse.kt | 9 ++++ 19 files changed, 506 insertions(+) create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt create mode 100644 matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt new file mode 100644 index 00000000..d96de314 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/SyncAPI.kt @@ -0,0 +1,15 @@ +package im.vector.matrix.core.internal.sync + +import im.vector.matrix.core.internal.network.NetworkConstants +import im.vector.matrix.core.internal.sync.data.SyncResponse +import kotlinx.coroutines.Deferred +import retrofit2.Response +import retrofit2.http.GET +import retrofit2.http.QueryMap + +interface SyncAPI { + + @GET(NetworkConstants.URI_API_PREFIX_PATH_R0 + "sync") + fun sync(@QueryMap params: Map): Deferred> + +} \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt new file mode 100644 index 00000000..257fc4e2 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceInfo.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2014 OpenMarket Ltd + * Copyright 2017 Vector Creations Ltd + * Copyright 2018 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + + +/** + * This class describes the device information + */ +@JsonClass(generateAdapter = true) +data class DeviceInfo( + /** + * The owner user id + */ + var user_id: String? = null, + + /** + * The device id + */ + var device_id: String? = null, + + /** + * The device display name + */ + var display_name: String? = null, + + /** + * The last time this device has been seen. + */ + var last_seen_ts: Long = 0, + + /** + * The last ip address + */ + var last_seen_ip: String? = null + +) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt new file mode 100644 index 00000000..6e789322 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceListResponse.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2017 Vector Creations Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +/** + * This class describes the device list response from a sync request + */ +@JsonClass(generateAdapter = true) +data class DeviceListResponse( + // user ids list which have new crypto devices + val changed: List? = null, + // List of user ids who are no more tracked. + val left: List? = null) + diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt new file mode 100644 index 00000000..31a81834 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DeviceOneTimeKeysCountSyncResponse.kt @@ -0,0 +1,9 @@ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class DeviceOneTimeKeysCountSyncResponse( + var signed_curve25519: Int? = null + +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt new file mode 100644 index 00000000..a1276d7f --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/DevicesListResponse.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2014 OpenMarket Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +/** + * This class describes the + */ +@JsonClass(generateAdapter = true) +data class DevicesListResponse( + var devices: List? = null +) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt new file mode 100644 index 00000000..83d66fb3 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/InvitedRoomSync.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2016 OpenMarket Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +// InvitedRoomSync represents a room invitation during server sync v2. +@JsonClass(generateAdapter = true) +data class InvitedRoomSync( + + /** + * The state of a room that the user has been invited to. These state events may only have the 'sender', 'type', 'state_key' + * and 'content' keys present. These events do not replace any state that the client already has for the room, for example if + * the client has archived the room. Instead the client should keep two separate copies of the state: the one from the 'invite_state' + * and one from the archived 'state'. If the client joins the room then the current state will be given as a delta against the + * archived 'state' not the 'invite_state'. + */ + var inviteState: RoomInviteState? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt new file mode 100644 index 00000000..2785ca0b --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/PresenceSyncResponse.kt @@ -0,0 +1,14 @@ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +// PresenceSyncResponse represents the updates to the presence status of other users during server sync v2. +@JsonClass(generateAdapter = true) +data class PresenceSyncResponse( + + /** + * List of presence events (array of Event with type m.presence). + */ + var events: List? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt new file mode 100644 index 00000000..c3e87554 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomInviteState.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2016 OpenMarket Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +// RoomInviteState represents the state of a room that the user has been invited to. +@JsonClass(generateAdapter = true) +data class RoomInviteState( + + /** + * List of state events (array of MXEvent). + */ + var events: List? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt new file mode 100644 index 00000000..d3844f56 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomResponse.kt @@ -0,0 +1,41 @@ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +/** + * Class representing a room from a JSON response from room or global initial sync. + */ +@JsonClass(generateAdapter = true) +data class RoomResponse( + // The room identifier. + var roomId: String? = null, + + // The last recent messages of the room. + var messages: TokensChunkResponse? = null, + + // The state events. + var state: List? = null, + + // The private data that this user has attached to this room. + var accountData: List? = null, + + // The current user membership in this room. + var membership: String? = null, + + // The room visibility (public/private). + var visibility: String? = null, + + // The matrix id of the inviter in case of pending invitation. + var inviter: String? = null, + + // The invite event if membership is invite. + var invite: Event? = null, + + // The presence status of other users (Provided in case of room initial sync @see http://matrix.org/docs/api/client-server/#!/-rooms/get_room_sync_data)). + var presence: List? = null, + + // The read receipts (Provided in case of room initial sync). + var receipts: List? = null +) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt new file mode 100644 index 00000000..e713b48b --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSync.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2016 OpenMarket Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +// RoomSync represents the response for a room during server sync v2. +@JsonClass(generateAdapter = true) +data class RoomSync( + /** + * The state updates for the room. + */ + var state: RoomSyncState? = null, + + /** + * The timeline of messages and state changes in the room. + */ + var timeline: RoomSyncTimeline? = null, + + /** + * The ephemeral events in the room that aren't recorded in the timeline or state of the room (e.g. typing, receipts). + */ + var ephemeral: RoomSyncEphemeral? = null, + + /** + * The account data events for the room (e.g. tags). + */ + var accountData: RoomSyncAccountData? = null, + + /** + * The notification counts for the room. + */ + var unreadNotifications: RoomSyncUnreadNotifications? = null + +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt new file mode 100644 index 00000000..de998ec4 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncAccountData.kt @@ -0,0 +1,12 @@ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +@JsonClass(generateAdapter = true) +data class RoomSyncAccountData( + /** + * List of account data events (array of Event). + */ + var events: List? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt new file mode 100644 index 00000000..84218bd2 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncEphemeral.kt @@ -0,0 +1,14 @@ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +// RoomSyncEphemeral represents the ephemeral events in the room that aren't recorded in the timeline or state of the room (e.g. typing). +@JsonClass(generateAdapter = true) +data class RoomSyncEphemeral( + /** + * List of ephemeral events (array of Event). + */ + var events: List? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt new file mode 100644 index 00000000..db287b53 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncState.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2016 OpenMarket Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +// RoomSyncState represents the state updates for a room during server sync v2. +@JsonClass(generateAdapter = true) +data class RoomSyncState( + + /** + * List of state events (array of Event). The resulting state corresponds to the *start* of the timeline. + */ + val events: List? = null) diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt new file mode 100644 index 00000000..993d5715 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncTimeline.kt @@ -0,0 +1,25 @@ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +// RoomSyncTimeline represents the timeline of messages and state changes for a room during server sync v2. +@JsonClass(generateAdapter = true) +data class RoomSyncTimeline( + + /** + * List of events (array of Event). + */ + var events: List? = null, + + /** + * Boolean which tells whether there are more events on the server + */ + var limited: Boolean = false, + + /** + * If the batch was limited then this is a token that can be supplied to the server to retrieve more events + */ + var prevBatch: String? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt new file mode 100644 index 00000000..252ea118 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomSyncUnreadNotifications.kt @@ -0,0 +1,25 @@ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +/** + * `MXRoomSyncUnreadNotifications` represents the unread counts for a room. + */ +@JsonClass(generateAdapter = true) +data class RoomSyncUnreadNotifications( + /** + * List of account data events (array of Event). + */ + val events: List? = null, + + /** + * The number of unread messages that match the push notification rules. + */ + val notificationCount: Int? = null, + + /** + * The number of highlighted unread messages (subset of notifications). + */ + val highlightCount: Int? = null) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt new file mode 100644 index 00000000..fc7d7ea0 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/RoomsSyncResponse.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2016 OpenMarket Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +// RoomsSyncResponse represents the rooms list in server sync v2 response. +@JsonClass(generateAdapter = true) +data class RoomsSyncResponse( + /** + * Joined rooms: keys are rooms ids. + */ + var join: Map? = null, + + /** + * Invitations. The rooms that the user has been invited to: keys are rooms ids. + */ + var invite: Map? = null, + + /** + * Left rooms. The rooms that the user has left or been banned from: keys are rooms ids. + */ + var leave: Map? = null) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt new file mode 100644 index 00000000..1fc83b0e --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/SyncResponse.kt @@ -0,0 +1,44 @@ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +// SyncResponse represents the request response for server sync v2. +@JsonClass(generateAdapter = true) +data class SyncResponse( + + /** + * The user private data. + */ + var accountData: Map? = null, + + /** + * The opaque token for the end. + */ + var nextBatch: String? = null, + + /** + * The updates to the presence status of other users. + */ + var presence: PresenceSyncResponse? = null, + + /* + * Data directly sent to one of user's devices. + */ + var toDevice: ToDeviceSyncResponse? = null, + + /** + * List of rooms. + */ + var rooms: RoomsSyncResponse? = null, + + /** + * Devices list update + */ + var deviceLists: DeviceListResponse? = null, + + /** + * One time keys management + */ + var deviceOneTimeKeysCount: DeviceOneTimeKeysCountSyncResponse? = null + +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt new file mode 100644 index 00000000..c71b4e2e --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/ToDeviceSyncResponse.kt @@ -0,0 +1,15 @@ +package im.vector.matrix.core.internal.sync.data + + +import com.squareup.moshi.JsonClass +import im.vector.matrix.core.api.events.Event + +// ToDeviceSyncResponse represents the data directly sent to one of user's devices. +@JsonClass(generateAdapter = true) +data class ToDeviceSyncResponse( + + /** + * List of direct-to-device events. + */ + var events: List? = null +) \ No newline at end of file diff --git a/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt new file mode 100644 index 00000000..e6745de3 --- /dev/null +++ b/matrix-sdk-core/src/main/java/im/vector/matrix/core/internal/sync/data/TokensChunkResponse.kt @@ -0,0 +1,9 @@ +package im.vector.matrix.core.internal.sync.data + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class TokensChunkResponse( + var start: String? = null, + var end: String? = null, + var chunk: List? = null)