aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-03-01 16:59:11 +0000
committerGitHub <noreply@github.com>2022-03-01 16:59:11 +0000
commit726529fe996519c93f4f329c03a968a432b0bb0e (patch)
treea4b0c624a5586f83bd2f4613c3142e18b44b998e
parentcda2452ba00afffa9a73870ca09047ce52dd28c7 (diff)
Hopefully fix read receipts (#2241)
-rw-r--r--syncapi/storage/postgres/receipt_table.go2
-rw-r--r--syncapi/storage/sqlite3/receipt_table.go2
-rw-r--r--syncapi/streams/stream_receipt.go5
3 files changed, 4 insertions, 5 deletions
diff --git a/syncapi/storage/postgres/receipt_table.go b/syncapi/storage/postgres/receipt_table.go
index f93081e1..474d0c02 100644
--- a/syncapi/storage/postgres/receipt_table.go
+++ b/syncapi/storage/postgres/receipt_table.go
@@ -96,7 +96,7 @@ func (r *receiptStatements) UpsertReceipt(ctx context.Context, txn *sql.Tx, room
}
func (r *receiptStatements) SelectRoomReceiptsAfter(ctx context.Context, roomIDs []string, streamPos types.StreamPosition) (types.StreamPosition, []api.OutputReceiptEvent, error) {
- lastPos := streamPos
+ var lastPos types.StreamPosition
rows, err := r.selectRoomReceipts.QueryContext(ctx, pq.Array(roomIDs), streamPos)
if err != nil {
return 0, nil, fmt.Errorf("unable to query room receipts: %w", err)
diff --git a/syncapi/storage/sqlite3/receipt_table.go b/syncapi/storage/sqlite3/receipt_table.go
index 6b39ee87..9111a39f 100644
--- a/syncapi/storage/sqlite3/receipt_table.go
+++ b/syncapi/storage/sqlite3/receipt_table.go
@@ -101,7 +101,7 @@ func (r *receiptStatements) UpsertReceipt(ctx context.Context, txn *sql.Tx, room
// SelectRoomReceiptsAfter select all receipts for a given room after a specific timestamp
func (r *receiptStatements) SelectRoomReceiptsAfter(ctx context.Context, roomIDs []string, streamPos types.StreamPosition) (types.StreamPosition, []api.OutputReceiptEvent, error) {
selectSQL := strings.Replace(selectRoomReceipts, "($2)", sqlutil.QueryVariadicOffset(len(roomIDs), 1), 1)
- lastPos := streamPos
+ var lastPos types.StreamPosition
params := make([]interface{}, len(roomIDs)+1)
params[0] = streamPos
for k, v := range roomIDs {
diff --git a/syncapi/streams/stream_receipt.go b/syncapi/streams/stream_receipt.go
index cccadb52..35ffd3a1 100644
--- a/syncapi/streams/stream_receipt.go
+++ b/syncapi/streams/stream_receipt.go
@@ -63,7 +63,6 @@ func (p *ReceiptStreamProvider) IncrementalSync(
if existing, ok := req.Response.Rooms.Join[roomID]; ok {
jr = existing
}
- var ok bool
ev := gomatrixserverlib.ClientEvent{
Type: gomatrixserverlib.MReceipt,
@@ -71,8 +70,8 @@ func (p *ReceiptStreamProvider) IncrementalSync(
}
content := make(map[string]eduAPI.ReceiptMRead)
for _, receipt := range receipts {
- var read eduAPI.ReceiptMRead
- if read, ok = content[receipt.EventID]; !ok {
+ read, ok := content[receipt.EventID]
+ if !ok {
read = eduAPI.ReceiptMRead{
User: make(map[string]eduAPI.ReceiptTS),
}