Skip to content
Snippets Groups Projects
Commit 17c0bc64 authored by Aline Gondim Santos's avatar Aline Gondim Santos
Browse files

swarm: add support

Change-Id: I12ec5fd0d79c9cdda63f25e7d042e6836828833c
parent 1bbc7cc2
Branches
No related tags found
No related merge requests found
...@@ -59,13 +59,21 @@ BotPeerChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessage ...@@ -59,13 +59,21 @@ BotPeerChatSubscriber::update(Observable<pluginMessagePtr>*, const pluginMessage
if (isAttached) { if (isAttached) {
if (message->direction) { if (message->direction) {
std::map<std::string, std::string> sendMsg; std::map<std::string, std::string> sendMsg;
for (auto& pair : message->data) { if (message->fromHistory)
if (pair.first == "text/plain" && pair.second == inText_) { return;
sendMsg[pair.first] = textAnswer_; 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()) { 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) ...@@ -100,9 +108,15 @@ BotPeerChatSubscriber::detached(Observable<pluginMessagePtr>* observable)
void void
BotPeerChatSubscriber::sendText(std::string& accountId, BotPeerChatSubscriber::sendText(std::string& accountId,
std::string& peerId, 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()); api_->invokeService(api_, "sendTextMessage", botAnswer.get());
} }
} // namespace jami } // namespace jami
...@@ -44,7 +44,8 @@ public: ...@@ -44,7 +44,8 @@ public:
void sendText(std::string& accountId, void sendText(std::string& accountId,
std::string& peerId, 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 setAnswer(const std::string& textAnswer);
void setInText(const std::string& inText); void setInText(const std::string& inText);
......
...@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) ...@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
# set the project name # set the project name
set (ProjectName AutoAnswer) set (ProjectName AutoAnswer)
set (Version 0.1.0) set (Version 1.0.0)
project(${ProjectName} VERSION ${Version}) project(${ProjectName} VERSION ${Version})
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#define EXPORT_PLUGIN #define EXPORT_PLUGIN
#endif #endif
#define AutoAnswer_VERSION_MAJOR 0 #define AutoAnswer_VERSION_MAJOR 1
#define AutoAnswer_VERSION_MINOR 1 #define AutoAnswer_VERSION_MINOR 0
#define AutoAnswer_VERSION_PATCH 0 #define AutoAnswer_VERSION_PATCH 0
extern "C" { extern "C" {
......
{ {
"name": "AutoAnswer", "name": "AutoAnswer",
"description" : "A plugin that automatically answers with given text", "description": "A plugin that automatically answers with given text",
"version" : "0.1.0", "version": "1.0.0",
"iconPath" : "icon.svg" "iconPath": "icon.svg"
} }
\ No newline at end of file
{ {
"name": "AutoAnswer", "name": "AutoAnswer",
"version": "0.1.0", "version": "1.0.0",
"extractLibs": false, "extractLibs": false,
"deps": [], "deps": [],
"defines": [], "defines": [],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment