Don't require ownerID to get icons
This commit is contained in:
parent
e31139add1
commit
27bafbdd89
@ -482,17 +482,11 @@ func (q *Queries) GetAllWatchItemsByOwner(ctx context.Context, ownerID int64) ([
|
|||||||
const getIconByLinkID = `-- name: GetIconByLinkID :one
|
const getIconByLinkID = `-- name: GetIconByLinkID :one
|
||||||
select owner_id, link_id, created_at, content_type, data
|
select owner_id, link_id, created_at, content_type, data
|
||||||
from icons
|
from icons
|
||||||
where owner_id = ?
|
where link_id = ?
|
||||||
and link_id = ?
|
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetIconByLinkIDParams struct {
|
func (q *Queries) GetIconByLinkID(ctx context.Context, linkID int64) (Icon, error) {
|
||||||
OwnerID int64 `json:"owner_id"`
|
row := q.db.QueryRowContext(ctx, getIconByLinkID, linkID)
|
||||||
LinkID int64 `json:"link_id"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) GetIconByLinkID(ctx context.Context, arg GetIconByLinkIDParams) (Icon, error) {
|
|
||||||
row := q.db.QueryRowContext(ctx, getIconByLinkID, arg.OwnerID, arg.LinkID)
|
|
||||||
var i Icon
|
var i Icon
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.OwnerID,
|
&i.OwnerID,
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
in {
|
in {
|
||||||
gostart = pkgs.buildGoModule {
|
gostart = pkgs.buildGoModule {
|
||||||
pname = "gostart";
|
pname = "gostart";
|
||||||
version = "v0.1.6";
|
version = "v0.1.7";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
vendorSha256 =
|
vendorSha256 =
|
||||||
|
21
handlers.go
21
handlers.go
@ -54,11 +54,13 @@ func IconCacher(next http.Handler) http.Handler {
|
|||||||
|
|
||||||
func iconGET(w http.ResponseWriter, r *http.Request) {
|
func iconGET(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
ownerID, ok := ctx.Value(ownerKey).(int64)
|
/*
|
||||||
if !ok {
|
ownerID, ok := ctx.Value(ownerKey).(int64)
|
||||||
http.Error(w, http.StatusText(http.StatusUnprocessableEntity), http.StatusUnprocessableEntity)
|
if !ok {
|
||||||
return
|
http.Error(w, http.StatusText(http.StatusUnprocessableEntity), http.StatusUnprocessableEntity)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
linkID, err := strconv.Atoi(chi.URLParam(r, "linkID"))
|
linkID, err := strconv.Atoi(chi.URLParam(r, "linkID"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
@ -71,10 +73,11 @@ func iconGET(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
icon, err := app.queries.GetIconByLinkID(ctx, data.GetIconByLinkIDParams{
|
icon, err := app.queries.GetIconByLinkID(ctx, int64(linkID))
|
||||||
LinkID: int64(linkID),
|
if err != nil {
|
||||||
OwnerID: ownerID,
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
size := 24
|
size := 24
|
||||||
|
@ -59,8 +59,7 @@ where owner_id = ?;
|
|||||||
-- name: GetIconByLinkID :one
|
-- name: GetIconByLinkID :one
|
||||||
select *
|
select *
|
||||||
from icons
|
from icons
|
||||||
where owner_id = ?
|
where link_id = ?;
|
||||||
and link_id = ?;
|
|
||||||
|
|
||||||
-- name: AddIcon :exec
|
-- name: AddIcon :exec
|
||||||
insert
|
insert
|
||||||
|
Loading…
Reference in New Issue
Block a user