manual test notnotea put
parent
72e17bdd43
commit
b582041af1
|
|
@ -68,7 +68,7 @@ notnotea() (
|
||||||
}
|
}
|
||||||
|
|
||||||
get() {
|
get() {
|
||||||
local cache_key="notea cache $1"
|
local cache_key="notnotea cache $1"
|
||||||
if cache get "$cache_key"; then
|
if cache get "$cache_key"; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -76,7 +76,7 @@ notnotea() (
|
||||||
}
|
}
|
||||||
|
|
||||||
_get() {
|
_get() {
|
||||||
_ncurl $NOTEA_ADDR/api/notes/$1
|
_nncurl $NNOTEA_ADDR/api/v0/files/$1
|
||||||
}
|
}
|
||||||
|
|
||||||
put() {
|
put() {
|
||||||
|
|
@ -90,27 +90,14 @@ notnotea() (
|
||||||
}
|
}
|
||||||
|
|
||||||
_put() {
|
_put() {
|
||||||
local xsrf_key="xsrf-token"
|
local id="$1"
|
||||||
local contains_tokens="$(_ncurl -i $NOTEA_ADDR/api)"
|
local title="$2"
|
||||||
local xsrf_token="$(echo "$contains_tokens" | grep -o '"csrfToken":[^,]*' | tr ':' '\n' | jq -r . | tail -n 1)"
|
local body="$3"
|
||||||
local xsrf_cookie="$(echo "$contains_tokens" | grep ^set.cookie: | sed 's/^set.cookie: //' | tr ';' '\n' | head -n 1)"
|
echo "$body" | _nncurl \
|
||||||
local request="$(echo '{
|
-X PUT \
|
||||||
"content": '"$(printf "%s\n" "$CONTENT" | jq -Rs)"',
|
-H "Title: $title" \
|
||||||
"deleted": 0,
|
|
||||||
"id": '"$(echo "$ID" | jq -R)"',
|
|
||||||
"pid": '"$(echo "$PID" | jq -R)"',
|
|
||||||
"pinned": 0,
|
|
||||||
"shared": 0,
|
|
||||||
"title": '"$(echo "$TITLE [generated]" | jq -R)"'
|
|
||||||
}' | jq -c .)"
|
|
||||||
echo "$request" | _ncurl \
|
|
||||||
-X POST \
|
|
||||||
-H "$xsrf_key: $xsrf_token" \
|
|
||||||
-b "$xsrf_cookie" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d @- \
|
-d @- \
|
||||||
$NOTEA_ADDR/api/notes \
|
$NNOTEA_ADDR/api/v0/files/$id
|
||||||
| grep -q "$ID"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"$@"
|
"$@"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue