From c694841cb1ed4b4b86081e3581f501cc91891160 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Tue, 13 Aug 2019 18:57:06 +0400 Subject: [PATCH] refactor: Add function which builds SyncReply model --- internal/models/sync/reply.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/internal/models/sync/reply.go b/internal/models/sync/reply.go index e533871..dbc007c 100644 --- a/internal/models/sync/reply.go +++ b/internal/models/sync/reply.go @@ -4,6 +4,7 @@ import ( "github.com/signaller-matrix/signaller/internal/models/events" ) +// SyncReply is model of sync respond 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. @@ -19,3 +20,29 @@ type RoomsSyncReply struct { 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. } + +// 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), + } +}