Fix meshms restful newsince with empty conversation

This commit is contained in:
Jeremy Lakeman 2016-10-17 10:07:03 -04:00
parent 95cce9109f
commit 75dfcff213
2 changed files with 25 additions and 0 deletions

View File

@ -178,6 +178,13 @@ static int restful_meshms_(httpd_request *r, const char *remainder)
handler = restful_meshms_messagelist_json; handler = restful_meshms_messagelist_json;
remainder = ""; remainder = "";
} }
else if (strcmp(remainder, "/newsince/messagelist.json") == 0){
handler = restful_meshms_newsince_messagelist_json;
remainder = "";
r->u.msglist.token.which_ply = MY_PLY;
r->u.msglist.token.offset = 0;
r->u.msglist.token.their_ack = 0;
}
else if ( str_startswith(remainder, "/newsince/", &end) else if ( str_startswith(remainder, "/newsince/", &end)
&& strn_to_meshms_token(end, &r->u.msglist.token, &end) && strn_to_meshms_token(end, &r->u.msglist.token, &end)
&& strcmp(end, "messagelist.json") == 0 && strcmp(end, "messagelist.json") == 0

View File

@ -288,6 +288,24 @@ test_MeshmsListMessagesNoIdentity() {
assertJqGrep --ignore-case http.body '.meshms_status_message' 'identity.*unknown' assertJqGrep --ignore-case http.body '.meshms_status_message' 'identity.*unknown'
} }
doc_MeshmsEmptyNewSince="HTTP RESTful list MeshMS since token with no messages"
setup_MeshmsEmptyNewSince() {
IDENTITY_COUNT=2
set_extra_config() {
executeOk_servald config set api.restful.newsince_timeout 1s
}
setup
}
test_MeshmsEmptyNewSince() {
executeOk curl \
--silent --fail --show-error \
--output messagelist.json \
--dump-header http.headers \
--basic --user harry:potter \
"http://$addr_localhost:$PORTA/restful/meshms/$SIDA1/$SIDA2/newsince/messagelist.json"
tfw_preserve messagelist.json
}
doc_MeshmsListMessagesNewSince="HTTP RESTful list MeshMS messages in one conversation since token as JSON" doc_MeshmsListMessagesNewSince="HTTP RESTful list MeshMS messages in one conversation since token as JSON"
setup_MeshmsListMessagesNewSince() { setup_MeshmsListMessagesNewSince() {
IDENTITY_COUNT=2 IDENTITY_COUNT=2