Compare MeshMS sender first, so you can talk to yourself (Fixes #124)

This commit is contained in:
Jeremy Lakeman 2017-09-06 12:38:53 +09:30
parent 34ad8c0fc0
commit 3333d2faa2
2 changed files with 34 additions and 2 deletions

View File

@ -136,14 +136,14 @@ static enum meshms_status get_database_conversations(const keyring_identity *id,
WHYF("invalid Bundle ID hex: %s -- skipping", alloca_str_toprint(id_hex));
continue;
}
const char *them = recipient;
const char *them = sender;
sid_t their_sid;
if (str_to_sid_t(&their_sid, them) == -1) {
WHYF("invalid SID hex: %s -- skipping", alloca_str_toprint(them));
continue;
}
if (cmp_sid_t(&their_sid, id->box_pk) == 0) {
them = sender;
them = recipient;
if (str_to_sid_t(&their_sid, them) == -1) {
WHYF("invalid SID hex: %s -- skipping", alloca_str_toprint(them));
continue;

View File

@ -116,6 +116,38 @@ teardown_AuthBasicWrong() {
teardown
}
doc_MeshmsTalkToYourself="HTTP RESTful talk to yourself"
setup_MeshmsTalkToYourself() {
IDENTITY_COUNT=1
setup
}
test_MeshmsTalkToYourself() {
executeOk curl \
--silent --fail --show-error \
--output sendmessage.json \
--basic --user harry:potter \
--form "message=Hello World;type=text/plain;charset=utf-8" \
"http://$addr_localhost:$PORTA/restful/meshms/$SIDA1/$SIDA1/sendmessage"
tfw_cat sendmessage.json
tfw_preserve sendmessage.json
executeOk curl \
--silent --fail --show-error \
--output conversationlist.json \
--dump-header http.headers \
--basic --user harry:potter \
"http://$addr_localhost:$PORTA/restful/meshms/$SIDA1/conversationlist.json"
tfw_cat conversationlist.json
tfw_preserve conversationlist.json
executeOk curl \
--silent --fail --show-error \
--output messagelist.json \
--dump-header http.headers \
--basic --user harry:potter \
"http://$addr_localhost:$PORTA/restful/meshms/$SIDA1/$SIDA1/messagelist.json"
tfw_cat messagelist.json
tfw_preserve messagelist.json
}
doc_MeshmsListConversations="HTTP RESTful list MeshMS conversations as JSON"
setup_MeshmsListConversations() {
IDENTITY_COUNT=5