This is an automated email from the git hooks/post-receive script. New commit to branch bow-v2-go in repository bow. See https://gitlab.nuiton.org/chorem/bow.git commit ca1489102a9c8636e64467b0566f920644dbac1a Author: Benjamin <poussin@codelutin.com> Date: Wed May 27 18:51:59 2020 +0200 correction recup bookmark pour edition --- env-dev | 1 - pkg/http/bookmarkResource.go | 5 +---- pkg/repository/bookmarkRepository.go | 14 ++++++++++++++ run-dev | 4 ++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/env-dev b/env-dev deleted file mode 100644 index 667201d..0000000 --- a/env-dev +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL=postgres://dbuser:xxxxxxxx@localhost:5432/bow diff --git a/pkg/http/bookmarkResource.go b/pkg/http/bookmarkResource.go index da2c34b..5809fd0 100644 --- a/pkg/http/bookmarkResource.go +++ b/pkg/http/bookmarkResource.go @@ -53,15 +53,12 @@ func getBookmark(w http.ResponseWriter, r *http.Request) { currentUser := r.Context().Value(constant.User).(model.BowUser) id := mux.Vars(r)["id"] - json, err := repository.BookmarkJSON(currentUser, id, "", []string{}, "", "", false, 0) + json, err := repository.BookmarkByIDJSON(currentUser, id) if err != nil { utils.Throw(w, err) return } - // on a au moins un resultat on supprime les [] - json = json[1 : len(json)-1] - w.Header().Add("Content-Type", "application/json") io.WriteString(w, json) } diff --git a/pkg/repository/bookmarkRepository.go b/pkg/repository/bookmarkRepository.go index a940c0a..63e5156 100644 --- a/pkg/repository/bookmarkRepository.go +++ b/pkg/repository/bookmarkRepository.go @@ -70,6 +70,20 @@ func BookmarkJSON(currentUser model.BowUser, id string, uri string, tags []strin return result, nil } +/* +BookmarkByIDJSON retourne le bookmark au format json +*/ +func BookmarkByIDJSON(currentUser model.BowUser, id string) (string, error) { + q := &query{sql: `select json_agg(*) as result from bookmark where id=$4)`} + result, err := q.QueryString(currentUser, id) + + if err != nil { + return "", utils.NewHTTPError500(err, currentUser) + } + + return result, nil +} + /* RenameTag renomme ou supprime un tag si newName est vide */ diff --git a/run-dev b/run-dev new file mode 100755 index 0000000..2adc709 --- /dev/null +++ b/run-dev @@ -0,0 +1,4 @@ +export DATABASE_URL=postgres://dbuser:xxxxxxxx@localhost:5432/bow +export SECRET_KEY="AZERTYUIOPQSDFGHJKLMWXCVBN" +export BOW_PUBLIC_URL="http://localhost:8000" +go run cmd/bow/main.go -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.