summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bridge/bridge.cpp11
-rw-r--r--src/database/database.cpp14
-rw-r--r--src/database/database.hpp2
-rw-r--r--src/xmpp/xmpp_component.cpp11
-rw-r--r--src/xmpp/xmpp_component.hpp4
5 files changed, 29 insertions, 13 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 0d6ade3..2da1d96 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -254,15 +254,16 @@ void Bridge::send_channel_message(const Iid& iid, const std::string& body)
else
irc->send_channel_message(iid.get_local(), line);
+ std::string uuid;
#ifdef USE_DATABASE
const auto xmpp_body = this->make_xmpp_body(line);
if (this->record_history)
- Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
+ uuid = Database::store_muc_message(this->get_bare_jid(), iid, std::chrono::system_clock::now(),
std::get<0>(xmpp_body), irc->get_own_nick());
#endif
for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
- this->xmpp.send_muc_message(std::to_string(iid), irc->get_own_nick(),
- this->make_xmpp_body(line), this->user_jid + "/" + resource);
+ this->xmpp.send_muc_message(std::to_string(iid), irc->get_own_nick(), this->make_xmpp_body(line),
+ this->user_jid + "/" + resource, uuid);
}
}
@@ -839,8 +840,8 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
#endif
for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
{
- this->xmpp.send_muc_message(std::to_string(iid), nick,
- this->make_xmpp_body(body, encoding), this->user_jid + "/" + resource);
+ this->xmpp.send_muc_message(std::to_string(iid), nick, this->make_xmpp_body(body, encoding),
+ this->user_jid + "/" + resource, {});
}
}
diff --git a/src/database/database.cpp b/src/database/database.cpp
index 71b0c37..9f310da 100644
--- a/src/database/database.cpp
+++ b/src/database/database.cpp
@@ -119,14 +119,16 @@ db::IrcChannelOptions Database::get_irc_channel_options_with_server_and_global_d
return coptions;
}
-void Database::store_muc_message(const std::string& owner, const Iid& iid,
- Database::time_point date,
- const std::string& body,
- const std::string& nick)
+std::string Database::store_muc_message(const std::string& owner, const Iid& iid,
+ Database::time_point date,
+ const std::string& body,
+ const std::string& nick)
{
db::MucLogLine line(*Database::db);
- line.uuid = Database::gen_uuid();
+ auto uuid = Database::gen_uuid();
+
+ line.uuid = uuid;
line.owner = owner;
line.ircChanName = iid.get_local();
line.ircServerName = iid.get_server();
@@ -135,6 +137,8 @@ void Database::store_muc_message(const std::string& owner, const Iid& iid,
line.nick = nick;
line.update();
+
+ return uuid;
}
std::vector<db::MucLogLine> Database::get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
diff --git a/src/database/database.hpp b/src/database/database.hpp
index 1665a9a..b08a175 100644
--- a/src/database/database.hpp
+++ b/src/database/database.hpp
@@ -50,7 +50,7 @@ public:
const std::string& channel);
static std::vector<db::MucLogLine> get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server,
int limit=-1, const std::string& start="", const std::string& end="");
- static void store_muc_message(const std::string& owner, const Iid& iid,
+ static std::string store_muc_message(const std::string& owner, const Iid& iid,
time_point date, const std::string& body, const std::string& nick);
static void close();
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 6829cef..8335c8a 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -380,7 +380,7 @@ void XmppComponent::send_topic(const std::string& from, Xmpp::body&& topic, cons
this->send_stanza(message);
}
-void XmppComponent::send_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& xmpp_body, const std::string& jid_to)
+void XmppComponent::send_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& xmpp_body, const std::string& jid_to, std::string uuid)
{
Stanza message("message");
message["to"] = jid_to;
@@ -402,6 +402,15 @@ void XmppComponent::send_muc_message(const std::string& muc_name, const std::str
// Pass the ownership of the pointer to this xmlnode
html.add_child(std::move(std::get<1>(xmpp_body)));
}
+
+ if (!uuid.empty())
+ {
+ XmlSubNode stanza_id(message, "stanza-id");
+ stanza_id["xmlns"] = STABLE_ID_NS;
+ stanza_id["by"] = muc_name + "@" + this->served_hostname;
+ stanza_id["id"] = std::move(uuid);
+ }
+
this->send_stanza(message);
}
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index 250f0a8..8eabaf6 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -33,6 +33,7 @@
#define DATAFORM_NS "jabber:x:data"
#define RSM_NS "http://jabber.org/protocol/rsm"
#define MUC_TRAFFIC_NS "http://jabber.org/protocol/muc#traffic"
+#define STABLE_ID_NS "urn:xmpp:sid:0"
/**
* An XMPP component, communicating with an XMPP server using the protocole
@@ -134,7 +135,8 @@ public:
/**
* Send a (non-private) message to the MUC
*/
- void send_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& body, const std::string& jid_to);
+ void send_muc_message(const std::string& muc_name, const std::string& nick, Xmpp::body&& body, const std::string& jid_to,
+ std::string uuid);
/**
* Send a message, with a <delay/> element, part of a MUC history
*/