add back logic to filter out non-shared links
This commit is contained in:
parent
a0cc20e5b9
commit
fa314ff14d
14
handlers.go
14
handlers.go
@ -245,12 +245,24 @@ func linksGET(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, http.StatusText(http.StatusUnprocessableEntity), http.StatusUnprocessableEntity)
|
http.Error(w, http.StatusText(http.StatusUnprocessableEntity), http.StatusUnprocessableEntity)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
owner, err := app.queries.GetOwner(ctx, ownerID)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
links, err := app.queries.GetAllLinksForOwner(app.ctx, ownerID)
|
links, err := app.queries.GetAllLinksForOwner(app.ctx, ownerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
linksJson, err := json.Marshal(links)
|
filteredLinks := []data.Link{}
|
||||||
|
for _, l := range links {
|
||||||
|
if !owner.ShowShared && l.OwnerID != ownerID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
filteredLinks = append(filteredLinks, l)
|
||||||
|
}
|
||||||
|
linksJson, err := json.Marshal(filteredLinks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user