mirror of
https://github.com/acaloiaro/garbagespeak.com
synced 2026-07-21 18:29:08 +00:00
Fix upleveling previously upleveled garbage
This commit is contained in:
parent
620a14f6eb
commit
3529599a18
3 changed files with 11 additions and 1 deletions
2
go.mod
2
go.mod
|
|
@ -13,6 +13,7 @@ require (
|
||||||
github.com/golang-migrate/migrate/v4 v4.16.2
|
github.com/golang-migrate/migrate/v4 v4.16.2
|
||||||
github.com/jackc/pgx-gofrs-uuid v0.0.0-20230224015001-1d428863c2e2
|
github.com/jackc/pgx-gofrs-uuid v0.0.0-20230224015001-1d428863c2e2
|
||||||
github.com/jackc/pgx/v5 v5.4.2
|
github.com/jackc/pgx/v5 v5.4.2
|
||||||
|
github.com/yuin/goldmark v1.5.5
|
||||||
golang.org/x/crypto v0.9.0
|
golang.org/x/crypto v0.9.0
|
||||||
golang.org/x/net v0.10.0
|
golang.org/x/net v0.10.0
|
||||||
)
|
)
|
||||||
|
|
@ -29,7 +30,6 @@ require (
|
||||||
github.com/jsuar/go-cron-descriptor v0.1.0 // indirect
|
github.com/jsuar/go-cron-descriptor v0.1.0 // indirect
|
||||||
github.com/lib/pq v1.10.2 // indirect
|
github.com/lib/pq v1.10.2 // indirect
|
||||||
github.com/robfig/cron v1.2.0 // indirect
|
github.com/robfig/cron v1.2.0 // indirect
|
||||||
github.com/yuin/goldmark v1.5.5 // indirect
|
|
||||||
go.uber.org/atomic v1.10.0 // indirect
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
go.uber.org/multierr v1.9.0 // indirect
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
go.uber.org/zap v1.24.0 // indirect
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import (
|
||||||
"github.com/golang-migrate/migrate/v4/source/iofs"
|
"github.com/golang-migrate/migrate/v4/source/iofs"
|
||||||
pgxuuid "github.com/jackc/pgx-gofrs-uuid"
|
pgxuuid "github.com/jackc/pgx-gofrs-uuid"
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
|
"github.com/jackc/pgx/v5/pgconn"
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
"github.com/yuin/goldmark"
|
"github.com/yuin/goldmark"
|
||||||
"github.com/yuin/goldmark/extension"
|
"github.com/yuin/goldmark/extension"
|
||||||
|
|
@ -257,11 +258,19 @@ func addUplevelHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
"INSERT INTO uplevels(garbage_id, user_id) VALUES ($1, $2)",
|
"INSERT INTO uplevels(garbage_id, user_id) VALUES ($1, $2)",
|
||||||
garbageID,
|
garbageID,
|
||||||
userID)
|
userID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var pgErr *pgconn.PgError
|
||||||
|
if errors.As(err, &pgErr) {
|
||||||
|
if pgErr.Code == "23505" { // duplicate key error
|
||||||
|
goto render
|
||||||
|
}
|
||||||
|
}
|
||||||
ise(err, w)
|
ise(err, w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render:
|
||||||
garbageUUID, _ := uuid.FromString(garbageID)
|
garbageUUID, _ := uuid.FromString(garbageID)
|
||||||
garbage := Garbage{ID: garbageUUID}
|
garbage := Garbage{ID: garbageUUID}
|
||||||
tmpl := template.Must(template.ParseFS(partialsFS, "partials/garbage/uplevel_button.tmpl"))
|
tmpl := template.Must(template.ParseFS(partialsFS, "partials/garbage/uplevel_button.tmpl"))
|
||||||
|
|
|
||||||
|
|
@ -147,4 +147,5 @@ h1:hover a, h2:hover a, h3:hover a, h4:hover a {
|
||||||
|
|
||||||
blockquote {
|
blockquote {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue