Use pq.Array
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2021-05-13 11:21:31 +02:00
parent 2a11bc1fc7
commit ac56638664
Signed by: peter
GPG Key ID: 374322D56E5209E8
3 changed files with 5 additions and 3 deletions

View File

@ -9,7 +9,7 @@ services:
- database-data:/var/lib/postgresql/data - database-data:/var/lib/postgresql/data
environment: environment:
POSTGRES_DB: ekster POSTGRES_DB: ekster
POSTGRES_USER: ekster POSTGRES_USER: postgres
POSTGRES_PASSWORD: simple POSTGRES_PASSWORD: simple
POSTGRES_HOST_AUTH_METHOD: trust POSTGRES_HOST_AUTH_METHOD: trust

View File

@ -219,6 +219,8 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return
} }
} else {
log.Println("No uids specified for mark read")
} }
} else { } else {
http.Error(w, fmt.Sprintf("unknown method in timeline %s\n", method), 500) http.Error(w, fmt.Sprintf("unknown method in timeline %s\n", method), 500)

View File

@ -11,7 +11,7 @@ import (
"p83.nl/go/ekster/pkg/microsub" "p83.nl/go/ekster/pkg/microsub"
// load pq for postgres // load pq for postgres
_ "github.com/lib/pq" "github.com/lib/pq"
) )
type postgresStream struct { type postgresStream struct {
@ -223,7 +223,7 @@ func (p *postgresStream) MarkRead(uids []string) error {
return err return err
} }
defer conn.Close() 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 { if err != nil {
return fmt.Errorf("while marking as read: %w", err) return fmt.Errorf("while marking as read: %w", err)
} }