From ac56638664b912e0b361015fcb48f5dc3f6fa60d Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Thu, 13 May 2021 11:21:31 +0200 Subject: [PATCH] Use pq.Array --- docker-compose.yml | 2 +- pkg/server/microsub.go | 2 ++ pkg/timeline/postgres.go | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6e39f12..247d5b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: - database-data:/var/lib/postgresql/data environment: POSTGRES_DB: ekster - POSTGRES_USER: ekster + POSTGRES_USER: postgres POSTGRES_PASSWORD: simple POSTGRES_HOST_AUTH_METHOD: trust diff --git a/pkg/server/microsub.go b/pkg/server/microsub.go index b9aaf8e..2ea1537 100644 --- a/pkg/server/microsub.go +++ b/pkg/server/microsub.go @@ -219,6 +219,8 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), 500) return } + } else { + log.Println("No uids specified for mark read") } } else { http.Error(w, fmt.Sprintf("unknown method in timeline %s\n", method), 500) diff --git a/pkg/timeline/postgres.go b/pkg/timeline/postgres.go index 3168c38..44485be 100644 --- a/pkg/timeline/postgres.go +++ b/pkg/timeline/postgres.go @@ -11,7 +11,7 @@ import ( "p83.nl/go/ekster/pkg/microsub" // load pq for postgres - _ "github.com/lib/pq" + "github.com/lib/pq" ) type postgresStream struct { @@ -223,7 +223,7 @@ func (p *postgresStream) MarkRead(uids []string) error { return err } defer conn.Close() - _, err = conn.ExecContext(context.Background(), `UPDATE "items" SET is_read = 1 WHERE "uid" IN ($1)`, uids) + _, err = conn.ExecContext(context.Background(), `UPDATE "items" SET is_read = 1 WHERE "uid" IN ($1)`, pq.Array(uids)) if err != nil { return fmt.Errorf("while marking as read: %w", err) }