mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-21 08:55:42 +03:00
Sync : add sync response model
This commit is contained in:
parent
d69b2ba930
commit
54fb54a695
19 changed files with 506 additions and 0 deletions
|
@ -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<String, Any>): Deferred<Response<SyncResponse>>
|
||||
|
||||
}
|
|
@ -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
|
||||
|
||||
)
|
|
@ -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<String>? = null,
|
||||
// List of user ids who are no more tracked.
|
||||
val left: List<String>? = null)
|
||||
|
|
@ -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
|
||||
|
||||
)
|
|
@ -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<DeviceInfo>? = null
|
||||
)
|
|
@ -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
|
||||
)
|
|
@ -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<Event>? = null
|
||||
)
|
|
@ -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<Event>? = null
|
||||
)
|
|
@ -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<Event>? = null,
|
||||
|
||||
// The state events.
|
||||
var state: List<Event>? = null,
|
||||
|
||||
// The private data that this user has attached to this room.
|
||||
var accountData: List<Event>? = 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<Event>? = null,
|
||||
|
||||
// The read receipts (Provided in case of room initial sync).
|
||||
var receipts: List<Event>? = null
|
||||
)
|
|
@ -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
|
||||
|
||||
)
|
|
@ -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<Event>? = null
|
||||
)
|
|
@ -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<Event>? = null
|
||||
)
|
|
@ -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<Event>? = null)
|
|
@ -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<Event>? = 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
|
||||
)
|
|
@ -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<Event>? = 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)
|
|
@ -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<String, RoomSync>? = null,
|
||||
|
||||
/**
|
||||
* Invitations. The rooms that the user has been invited to: keys are rooms ids.
|
||||
*/
|
||||
var invite: Map<String, InvitedRoomSync>? = null,
|
||||
|
||||
/**
|
||||
* Left rooms. The rooms that the user has left or been banned from: keys are rooms ids.
|
||||
*/
|
||||
var leave: Map<String, RoomSync>? = null)
|
|
@ -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<String, Any>? = 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
|
||||
|
||||
)
|
|
@ -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<Event>? = null
|
||||
)
|
|
@ -0,0 +1,9 @@
|
|||
package im.vector.matrix.core.internal.sync.data
|
||||
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class TokensChunkResponse<T>(
|
||||
var start: String? = null,
|
||||
var end: String? = null,
|
||||
var chunk: List<T>? = null)
|
Loading…
Reference in a new issue