diff --git a/AutoAnswer/BotPeerChatSubscriber.cpp b/AutoAnswer/BotPeerChatSubscriber.cpp index 26c6d30d7c9e1f2c4062fe488c441ff6d0cd684f..c1e6761b1fff2a0a56e894500ccfe739edee2fe8 100644 --- a/AutoAnswer/BotPeerChatSubscriber.cpp +++ b/AutoAnswer/BotPeerChatSubscriber.cpp @@ -59,13 +59,21 @@ BotPeerChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessage if (isAttached) { if (message->direction) { std::map<std::string, std::string> sendMsg; - for (auto& pair : message->data) { - if (pair.first == "text/plain" && pair.second == inText_) { - sendMsg[pair.first] = textAnswer_; + if (message->fromHistory) + return; + if (!message->isSwarm) + for (auto& pair : message->data) { + if (pair.first == "text/plain" && pair.second == inText_) { + sendMsg[pair.first] = textAnswer_; + } } + else if (message->data.at("type") == "text/plain" + && message->data.at("body") == inText_) { + sendMsg["type"] = "text/plain"; + sendMsg["body"] = textAnswer_; } if (!sendMsg.empty()) { - sendText(message->accountId, message->peerId, sendMsg); + sendText(message->accountId, message->peerId, sendMsg, message->isSwarm); } } } @@ -100,9 +108,15 @@ BotPeerChatSubscriber::detached(Observable<pluginMessagePtr>* observable) void BotPeerChatSubscriber::sendText(std::string& accountId, std::string& peerId, - std::map<std::string, std::string>& sendMsg) + std::map<std::string, std::string>& sendMsg, + bool swarm) { - pluginMessagePtr botAnswer = std::make_shared<JamiMessage>(accountId, peerId, false, sendMsg, true); + pluginMessagePtr botAnswer = std::make_shared<JamiMessage>(accountId, + peerId, + false, + sendMsg, + true); + botAnswer->isSwarm = swarm; api_->invokeService(api_, "sendTextMessage", botAnswer.get()); } } // namespace jami diff --git a/AutoAnswer/BotPeerChatSubscriber.h b/AutoAnswer/BotPeerChatSubscriber.h index a2c66dbef7772702034bfc3f7c47dad7e90248ec..26b7a276ebc10de7b32fb2c6562279ce8534b22c 100644 --- a/AutoAnswer/BotPeerChatSubscriber.h +++ b/AutoAnswer/BotPeerChatSubscriber.h @@ -44,7 +44,8 @@ public: void sendText(std::string& accountId, std::string& peerId, - std::map<std::string, std::string>& sendMsg); + std::map<std::string, std::string>& sendMsg, + bool swarm); void setAnswer(const std::string& textAnswer); void setInText(const std::string& inText); diff --git a/AutoAnswer/CMakeLists.txt b/AutoAnswer/CMakeLists.txt index db5d00d81b10a9c502a83bb14bd3f3be71e535cd..8e0144600995b434a748d213027a9c796e4c68be 100644 --- a/AutoAnswer/CMakeLists.txt +++ b/AutoAnswer/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) # set the project name set (ProjectName AutoAnswer) -set (Version 0.1.0) +set (Version 1.0.0) project(${ProjectName} VERSION ${Version}) diff --git a/AutoAnswer/main.cpp b/AutoAnswer/main.cpp index b35e17655c9cff894e637464a94938dd0229cf7a..7d90bbacd1294b8ec0079f3ff037bb90bae8e260 100644 --- a/AutoAnswer/main.cpp +++ b/AutoAnswer/main.cpp @@ -32,8 +32,8 @@ #define EXPORT_PLUGIN #endif -#define AutoAnswer_VERSION_MAJOR 0 -#define AutoAnswer_VERSION_MINOR 1 +#define AutoAnswer_VERSION_MAJOR 1 +#define AutoAnswer_VERSION_MINOR 0 #define AutoAnswer_VERSION_PATCH 0 extern "C" { diff --git a/AutoAnswer/manifest.json b/AutoAnswer/manifest.json index 5855af7ff08ea54586663d53afb8bc51a5624293..2cb02f9758fe0a19405f48a8ceef772542803ae0 100644 --- a/AutoAnswer/manifest.json +++ b/AutoAnswer/manifest.json @@ -1,6 +1,6 @@ { - "name": "AutoAnswer", - "description" : "A plugin that automatically answers with given text", - "version" : "0.1.0", - "iconPath" : "icon.svg" -} + "name": "AutoAnswer", + "description": "A plugin that automatically answers with given text", + "version": "1.0.0", + "iconPath": "icon.svg" +} \ No newline at end of file diff --git a/AutoAnswer/package.json b/AutoAnswer/package.json index 5d42d67a1efad3ffa544c7056b5049f396a6e23f..25df3169858c81b7fcc31b1bda098e62bc4542cf 100644 --- a/AutoAnswer/package.json +++ b/AutoAnswer/package.json @@ -1,6 +1,6 @@ { "name": "AutoAnswer", - "version": "0.1.0", + "version": "1.0.0", "extractLibs": false, "deps": [], "defines": [],