summaryrefslogtreecommitdiff
path: root/louloulibs/xmpp/xmpp_component.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'louloulibs/xmpp/xmpp_component.cpp')
-rw-r--r--louloulibs/xmpp/xmpp_component.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/louloulibs/xmpp/xmpp_component.cpp b/louloulibs/xmpp/xmpp_component.cpp
index e87cdf7..22121f6 100644
--- a/louloulibs/xmpp/xmpp_component.cpp
+++ b/louloulibs/xmpp/xmpp_component.cpp
@@ -16,6 +16,9 @@
#include <uuid.h>
+#include <cstdlib>
+#include <iomanip>
+
#include <louloulibs.h>
#ifdef SYSTEMD_FOUND
# include <systemd/sd-daemon.h>
@@ -426,6 +429,31 @@ void XmppComponent::send_muc_message(const std::string& muc_name, const std::str
this->send_stanza(message);
}
+void XmppComponent::send_history_message(const std::string& muc_name, const std::string& nick, const std::string& body_txt, const std::string& jid_to, std::time_t timestamp)
+{
+ Stanza message("message");
+ message["to"] = jid_to;
+ if (!nick.empty())
+ message["from"] = muc_name + "@" + this->served_hostname + "/" + nick;
+ else
+ message["from"] = muc_name + "@" + this->served_hostname;
+ message["type"] = "groupchat";
+
+ XmlNode body("body");
+ body.set_inner(body_txt);
+ message.add_child(std::move(body));
+
+ XmlNode delay("delay");
+ delay["xmlns"] = "urn:xmpp:delay";
+ delay["from"] = muc_name + "@" + this->served_hostname;
+ std::stringstream date_ss;
+ date_ss << std::put_time(std::gmtime(&timestamp), "%FT%Tz") << std::endl;
+ delay["stamp"] = date_ss.str();
+
+ message.add_child(std::move(delay));
+ this->send_stanza(message);
+}
+
void XmppComponent::send_muc_leave(const std::string& muc_name, std::string&& nick, Xmpp::body&& message, const std::string& jid_to, const bool self)
{
Stanza presence("presence");