fix pin rest

This commit is contained in:
Umputun
2017-12-25 21:27:26 -06:00
parent 06919c1ae7
commit 0843c236fd
+4 -4
View File
@@ -60,18 +60,18 @@ func (a *admin) setBlockCtrl(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, JSON{"user_id": userID, "site_id": siteID, "block": blockStatus})
}
// PUT /pin/{id}?site=side-id&pin=1
// PUT /pin/{id}?url=post-url&pin=1
func (a *admin) setPinCtrl(w http.ResponseWriter, r *http.Request) {
commentID := chi.URLParam(r, "id")
siteID := r.URL.Query().Get("site")
url := r.URL.Query().Get("url")
pinStatus := r.URL.Query().Get("pin") == "1"
if err := a.dataStore.SetPin(store.Locator{SiteID: siteID}, commentID, pinStatus); err != nil {
if err := a.dataStore.SetPin(store.Locator{URL: url}, commentID, pinStatus); err != nil {
httpError(w, r, http.StatusBadRequest, err, "can't set pin status")
return
}
render.JSON(w, r, JSON{"comment_id": commentID, "site_id": siteID, "pin": pinStatus})
render.JSON(w, r, JSON{"id": commentID, "url": url, "pin": pinStatus})
}
// GET /export?site=site-id