summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-08-27 22:30:44 +0200
committerlouiz’ <louiz@louiz.org>2017-08-27 22:37:46 +0200
commitfcaffb9e778ad5962e69dc23c1fc91eb59a27945 (patch)
tree99c8270467b67b2dab90235c3ff1147daf1b9422 /src/xmpp
parent25243f53c2479e2fda0f1a05d1589c8214b70b4b (diff)
downloadbiboumi-fcaffb9e778ad5962e69dc23c1fc91eb59a27945.tar.gz
biboumi-fcaffb9e778ad5962e69dc23c1fc91eb59a27945.tar.bz2
biboumi-fcaffb9e778ad5962e69dc23c1fc91eb59a27945.tar.xz
biboumi-fcaffb9e778ad5962e69dc23c1fc91eb59a27945.zip
Add support for the "history" node on MUC join
Supports the "seconds", "maxstanzas", "since" and "maxchars" (but only =0) attributes. fix #3270
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/biboumi_component.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 6cddeb4..7c5b059 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -24,6 +24,7 @@
#include <database/database.hpp>
#include <bridge/result_set_management.hpp>
+#include <bridge/history_limit.hpp>
using namespace std::string_literals;
@@ -155,8 +156,33 @@ void BiboumiComponent::handle_presence(const Stanza& stanza)
bridge->send_irc_nick_change(iid, to.resource, from.resource);
const XmlNode* x = stanza.get_child("x", MUC_NS);
const XmlNode* password = x ? x->get_child("password", MUC_NS): nullptr;
+ const XmlNode* history = x ? x->get_child("history", MUC_NS): nullptr;
+ HistoryLimit history_limit;
+ if (history)
+ {
+ // TODO implement the "seconds"
+ const auto seconds = history->get_tag("seconds");
+ if (!seconds.empty())
+ {
+ const auto now = std::chrono::system_clock::now();
+ std::time_t timestamp = std::chrono::system_clock::to_time_t(now);
+ int int_seconds = std::atoi(seconds.data());
+ timestamp -= int_seconds;
+ history_limit.since = utils::to_string(timestamp);
+ }
+ const auto since = history->get_tag("since");
+ if (!since.empty())
+ history_limit.since = since;
+ const auto maxstanzas = history->get_tag("maxstanzas");
+ if (!maxstanzas.empty())
+ history_limit.stanzas = std::atoi(maxstanzas.data());
+ // Ignore any other value, because this is too complex to implement,
+ // so I won’t do it.
+ if (history->get_tag("maxchars") == "0")
+ history_limit.stanzas = 0;
+ }
bridge->join_irc_channel(iid, to.resource, password ? password->get_inner(): "",
- from.resource);
+ from.resource, history_limit);
}
else if (type == "unavailable")
{