2019-07-19 15:52:03 +00:00
package sync
import (
2019-08-10 07:48:55 +00:00
"github.com/signaller-matrix/signaller/internal/models/events"
2019-07-19 15:52:03 +00:00
)
2019-08-13 14:57:06 +00:00
// SyncReply is model of sync respond
2019-07-19 15:52:03 +00:00
type SyncReply struct {
NextBatch string ` json:"next_batch" ` // Required. The batch token to supply in the since param of the next /sync request.
Rooms RoomsSyncReply ` json:"rooms" ` // Updates to rooms.
2019-08-10 07:48:55 +00:00
Presence events . Presence ` json:"presence" ` // The updates to the presence status of other users.
AccountData events . AccountData ` json:"account_data" ` // The global private data created by this user.
ToDevice events . ToDevice ` json:"to_device" ` // Information on the send-to-device messages for the client device, as defined in Send-to-Device messaging.
DeviceLists events . DeviceLists ` json:"device_lists" ` // Information on end-to-end device updates, as specified in End-to-end encryption.
2019-07-19 15:52:03 +00:00
DeviceOneTimeKeysCount map [ string ] int ` json:"device_one_time_keys_count" ` // Information on end-to-end encryption keys, as specified in End-to-end encryption.
}
type RoomsSyncReply struct {
2019-08-10 07:48:55 +00:00
Join map [ string ] events . JoinedRoom ` json:"join" ` // The rooms that the user has joined.
Invite map [ string ] events . InvitedRoom ` json:"invite" ` // The rooms that the user has been invited to.
Leave map [ string ] events . LeftRoom ` json:"leave" ` // The rooms that the user has left or been banned from.
2019-07-19 15:52:03 +00:00
}
2019-08-13 14:57:06 +00:00
// BuildEmptySyncReply is function which builds empty SyncReply model
func BuildEmptySyncReply ( ) * SyncReply {
return & SyncReply {
NextBatch : "" ,
Rooms : RoomsSyncReply {
Join : make ( map [ string ] events . JoinedRoom ) ,
Invite : make ( map [ string ] events . InvitedRoom ) ,
Leave : make ( map [ string ] events . LeftRoom ) ,
} ,
Presence : events . Presence {
Events : nil ,
} ,
AccountData : events . AccountData {
Events : nil ,
} ,
ToDevice : events . ToDevice {
Events : nil ,
} ,
DeviceLists : events . DeviceLists {
Changed : nil ,
Left : nil ,
} ,
DeviceOneTimeKeysCount : make ( map [ string ] int ) ,
}
}