From 481809aaad4d96ee9ac6d4a2dbb558e2b583b4a0 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 21 Jan 2020 12:49:25 +0000 Subject: [PATCH] Fix lint errors --- syncapi/routing/messages.go | 2 +- syncapi/storage/postgres/syncserver.go | 8 +++++--- syncapi/sync/request.go | 17 ----------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/syncapi/routing/messages.go b/syncapi/routing/messages.go index 183efc855..acdda900c 100644 --- a/syncapi/routing/messages.go +++ b/syncapi/routing/messages.go @@ -257,7 +257,7 @@ func (r *messagesReq) retrieveEvents() ( end.PDUPosition = types.StreamPosition(1) } - return + return clientEvents, start, end, err } // handleEmptyEventsSlice handles the case where the initial request to the diff --git a/syncapi/storage/postgres/syncserver.go b/syncapi/storage/postgres/syncserver.go index 68863d91c..3bfb4592c 100644 --- a/syncapi/storage/postgres/syncserver.go +++ b/syncapi/storage/postgres/syncserver.go @@ -116,6 +116,7 @@ func (d *SyncServerDatasource) Events(ctx context.Context, eventIDs []string) ([ // WriteEvent into the database. It is not safe to call this function from multiple goroutines, as it would create races // when generating the sync stream position for this event. Returns the sync stream position for the inserted event. // Returns an error if there was a problem inserting this event. +// nolint: gocyclo func (d *SyncServerDatasource) WriteEvent( ctx context.Context, ev *gomatrixserverlib.Event, @@ -179,7 +180,8 @@ func (d *SyncServerDatasource) WriteEvent( return d.updateRoomState(ctx, txn, removeStateEventIDs, addStateEvents, pduPosition) }) - return + + return pduPosition, returnErr } func (d *SyncServerDatasource) updateRoomState( @@ -838,7 +840,7 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse( types.PaginationTokenTypeTopology, backwardTopologyPos, 0, ).String() // Use the short form of batch token for prev_batch - //jr.Timeline.PrevBatch = strconv.FormatInt(prevPDUPos, 10) + jr.Timeline.PrevBatch = strconv.FormatInt(int64(prevPDUPos), 10) jr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync) jr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true jr.State.Events = gomatrixserverlib.ToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync) @@ -853,7 +855,7 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse( types.PaginationTokenTypeStream, backwardTopologyPos, 0, ).String() // Use the short form of batch token for prev_batch - //lr.Timeline.PrevBatch = strconv.FormatInt(prevPDUPos, 10) + lr.Timeline.PrevBatch = strconv.FormatInt(int64(prevPDUPos), 10) lr.Timeline.Events = gomatrixserverlib.ToClientEvents(recentEvents, gomatrixserverlib.FormatSync) lr.Timeline.Limited = false // TODO: if len(events) >= numRecents + 1 and then set limited:true lr.State.Events = gomatrixserverlib.ToClientEvents(delta.stateEvents, gomatrixserverlib.FormatSync) diff --git a/syncapi/sync/request.go b/syncapi/sync/request.go index a1bce0a6b..4d0bd155d 100644 --- a/syncapi/sync/request.go +++ b/syncapi/sync/request.go @@ -79,23 +79,6 @@ func getTimeout(timeoutMS string) time.Duration { return time.Duration(i) * time.Millisecond } -// getPaginationToken tries to parse a 'since' token taken from the API to a -// pagination token. If the string is empty then (nil, nil) is returned. -// Returns an error if the parsed token's type isn't types.PaginationTokenTypeStream. -func getSyncStreamPosition(since string) (*types.StreamPosition, error) { - if since == "" { - return nil, nil - } - p, err := getPaginationToken(since) - if err != nil { - return nil, err - } - if p.Type != types.PaginationTokenTypeStream { - return nil, ErrNotStreamToken - } - return &(p.PDUPosition), nil -} - // getSyncStreamPosition tries to parse a 'since' token taken from the API to a // types.PaginationToken. If the string is empty then (nil, nil) is returned. // There are two forms of tokens: The full length form containing all PDU and EDU