Skip to content
Snippets Groups Projects
Commit 93846bfa authored by Sébastien Blin's avatar Sébastien Blin Committed by Philippe Gorley
Browse files

sendTextMessage: take into account payload type


Currently, the daemon lie a bit about sendTextMessage. Indeed, it
takes a map (string, string) like {{datatype: msg}} but the datatype
is ignored.

It can be problematic if a client wants to manipulate a custom datatype
because the daemon will replace the datatype by "plain/text". Now,
an ImMessage can have a datatype which permits to not lie in the api
and manipulate the datatype the user wants.

Change-Id: I1ec5a34082337570bf43231078fc894304b00182
Reviewed-by: default avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 2aa72b93
No related branches found
No related tags found
No related merge requests found
......@@ -2256,7 +2256,11 @@ RingAccount::doRegister_()
const dht::InfoHash& peer_account)
{
auto now = clock::to_time_t(clock::now());
std::map<std::string, std::string> payloads = {{"text/plain",
std::string datatype = utf8_make_valid(v.datatype);
if (datatype.empty()) {
datatype = "text/plain";
}
std::map<std::string, std::string> payloads = {{datatype,
utf8_make_valid(v.msg)}};
shared->onTextMessage(peer_account.toString(), payloads);
RING_DBG("Sending message confirmation %" PRIx64, v.id);
......@@ -3351,7 +3355,7 @@ RingAccount::sendTextMessage(const std::string& to, const std::map<std::string,
});
confirm->listenTokens.emplace(h, std::move(list_token));
shared->dht_.putEncrypted(h, dev,
dht::ImMessage(token, std::string(payloads.begin()->second), now),
dht::ImMessage(token, std::string(payloads.begin()->first), std::string(payloads.begin()->second), now),
[wshared,token,confirm,h](bool ok) {
if (auto this_ = wshared.lock()) {
RING_DBG("[Account %s] [message %" PRIx64 "] put encrypted %s", this_->getAccountID().c_str(), token, ok ? "ok" : "failed");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment