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
|
||||
select owner_id, link_id, created_at, content_type, data
|
||||
from icons
|
||||
where owner_id = ?
|
||||
and link_id = ?
|
||||
where link_id = ?
|
||||
`
|
||||
|
||||
type GetIconByLinkIDParams struct {
|
||||
OwnerID int64 `json:"owner_id"`
|
||||
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)
|
||||
func (q *Queries) GetIconByLinkID(ctx context.Context, linkID int64) (Icon, error) {
|
||||
row := q.db.QueryRowContext(ctx, getIconByLinkID, linkID)
|
||||
var i Icon
|
||||
err := row.Scan(
|
||||
&i.OwnerID,
|
||||
|
@ -19,7 +19,7 @@
|
||||
in {
|
||||
gostart = pkgs.buildGoModule {
|
||||
pname = "gostart";
|
||||
version = "v0.1.6";
|
||||
version = "v0.1.7";
|
||||
src = ./.;
|
||||
|
||||
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) {
|
||||
ctx := r.Context()
|
||||
ownerID, ok := ctx.Value(ownerKey).(int64)
|
||||
if !ok {
|
||||
http.Error(w, http.StatusText(http.StatusUnprocessableEntity), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
/*
|
||||
ownerID, ok := ctx.Value(ownerKey).(int64)
|
||||
if !ok {
|
||||
http.Error(w, http.StatusText(http.StatusUnprocessableEntity), http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
*/
|
||||
linkID, err := strconv.Atoi(chi.URLParam(r, "linkID"))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
@ -71,10 +73,11 @@ func iconGET(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
icon, err := app.queries.GetIconByLinkID(ctx, data.GetIconByLinkIDParams{
|
||||
LinkID: int64(linkID),
|
||||
OwnerID: ownerID,
|
||||
})
|
||||
icon, err := app.queries.GetIconByLinkID(ctx, int64(linkID))
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
size := 24
|
||||
|
@ -59,8 +59,7 @@ where owner_id = ?;
|
||||
-- name: GetIconByLinkID :one
|
||||
select *
|
||||
from icons
|
||||
where owner_id = ?
|
||||
and link_id = ?;
|
||||
where link_id = ?;
|
||||
|
||||
-- name: AddIcon :exec
|
||||
insert
|
||||
|
Loading…
Reference in New Issue
Block a user