From dcfe31ce3055f3af7e3b617752d9c9fd16672569 Mon Sep 17 00:00:00 2001
From: Roger Planas <roger.planas@isode.com>
Date: Mon, 8 Feb 2016 11:36:14 +0000
Subject: Sluift: Ensure that message event body is retrieved correctly

As a result of commit "Change stanza body to boost::optional<std::string> type"
(commit	1b9ccc1fef6104eaf951153ddccdc6bb15899e9a), Sluift was not
populating the 'body' part of the message event, casting it to a bool instead.

By adding get_value_or("") to that body part, the actual body value
is retrieved, and the message event ends up containing the right information.

Test-Information:

Without the patch, Sluift's message event body is 'true'.
With the patch, Sluift's message event body contains the actual message.
Component messages also tested and event body as expected.

Change-Id: I366202aa5bf28a3315a81d909ea08f0933aa06d7

diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index 997fd00..8f6ff3a 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -487,7 +487,7 @@ static void pushEvent(lua_State* L, const SluiftClient::Event& event) {
 			Lua::Table result = boost::assign::map_list_of
 				("type", boost::make_shared<Lua::Value>(std::string("message")))
 				("from", boost::make_shared<Lua::Value>(message->getFrom().toString()))
-				("body", boost::make_shared<Lua::Value>(message->getBody()))
+				("body", boost::make_shared<Lua::Value>(message->getBody().get_value_or("")))
 				("message_type", boost::make_shared<Lua::Value>(MessageConvertor::convertMessageTypeToString(message->getType())));
 			Lua::pushValue(L, result);
 			addPayloadsToTable(L, message->getPayloads());
diff --git a/Sluift/component.cpp b/Sluift/component.cpp
index e92352e..a9ac2d9 100644
--- a/Sluift/component.cpp
+++ b/Sluift/component.cpp
@@ -362,7 +362,7 @@ static void pushEvent(lua_State* L, const SluiftComponent::Event& event) {
 				("type", boost::make_shared<Lua::Value>(std::string("message")))
 				("from", boost::make_shared<Lua::Value>(message->getFrom().toString()))
 				("to", boost::make_shared<Lua::Value>(message->getTo().toString()))
-				("body", boost::make_shared<Lua::Value>(message->getBody()))
+				("body", boost::make_shared<Lua::Value>(message->getBody().get_value_or("")))
 				("message_type", boost::make_shared<Lua::Value>(MessageConvertor::convertMessageTypeToString(message->getType())));
 			Lua::pushValue(L, result);
 			addPayloadsToTable(L, message->getPayloads());
-- 
cgit v0.10.2-6-g49f6