From 99389eefba1883753c15c6f411fb8543c93f58a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 10 Feb 2018 17:36:33 +0100 Subject: Always return the oldest matching messages from MAM, even if no date is set --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 481ebb9..250007e 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -721,7 +721,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if (max) limit = std::atoi(max->get_inner().data()); } - // Do send more than 100 messages, even if the client asked for more, + // Do not send more than 100 messages, even if the client asked for more, // or if it didn’t specify any limit. // 101 is just a trick to know if there are more available messages. // If our query returns 101 message, we know it’s incomplete, but we -- cgit v1.2.3 From 0280343ced6c520700c3ca508e2d04c6b512d319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 10 Feb 2018 19:51:59 +0100 Subject: =?UTF-8?q?Handle=20the=20=E2=80=9Cafter=E2=80=9D=20RSM=20value=20?= =?UTF-8?q?to=20page=20through=20results?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/xmpp/biboumi_component.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 250007e..cd6d570 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -715,11 +715,19 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) } const XmlNode* set = query->get_child("set", RSM_NS); int limit = -1; + Id::real_type after_id{Id::unset_value}; if (set) { const XmlNode* max = set->get_child("max", RSM_NS); if (max) limit = std::atoi(max->get_inner().data()); + const XmlNode* after = set->get_child("after", RSM_NS); + if (after) + { + auto after_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), + after->get_inner(), start, end); + after_id = after_record.col(); + } } // Do not send more than 100 messages, even if the client asked for more, // or if it didn’t specify any limit. @@ -729,7 +737,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if ((limit == -1 && start.empty() && end.empty()) || limit > 100) limit = 101; - auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end); + auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, after_id); bool complete = true; if (lines.size() > 100) { -- cgit v1.2.3 From d70554143554f1a4ed3d225d30a6e49227f40fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 11 Feb 2018 23:29:58 +0100 Subject: =?UTF-8?q?Send=20a=20item-not-found=20error=20when=20the=20?= =?UTF-8?q?=E2=80=9Cafter=E2=80=9D=20value=20is=20not=20in=20the=20archive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/xmpp/biboumi_component.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index cd6d570..405ac15 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -467,8 +467,12 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) #ifdef USE_DATABASE else if ((query = stanza.get_child("query", MAM_NS))) { - if (this->handle_mam_request(stanza)) - stanza_error.disable(); + try { + if (this->handle_mam_request(stanza)) + stanza_error.disable(); + } catch (const Database::RecordNotFound& exc) { + error_name = "item-not-found"; + } } else if ((query = stanza.get_child("query", MUC_OWNER_NS))) { -- cgit v1.2.3 From 50d3c4a0b20a4fde582d186e4c9a2226755b1a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 13 Feb 2018 03:39:13 +0100 Subject: Do not forget an early return, to return the correct item-not-found error --- src/xmpp/biboumi_component.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 405ac15..75a55e6 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -472,6 +472,7 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) stanza_error.disable(); } catch (const Database::RecordNotFound& exc) { error_name = "item-not-found"; + return; } } else if ((query = stanza.get_child("query", MUC_OWNER_NS))) -- cgit v1.2.3 From 4a2a280d76e45e165d5c4657f4a46eebf71594bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 13 Feb 2018 03:51:03 +0100 Subject: Support the element in MAM requests --- src/xmpp/biboumi_component.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 75a55e6..fe6cc1b 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -720,7 +720,8 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) } const XmlNode* set = query->get_child("set", RSM_NS); int limit = -1; - Id::real_type after_id{Id::unset_value}; + Id::real_type reference_record_id{Id::unset_value}; + Database::Paging paging_order{Database::Paging::first}; if (set) { const XmlNode* max = set->get_child("max", RSM_NS); @@ -731,7 +732,17 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) { auto after_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), after->get_inner(), start, end); - after_id = after_record.col(); + reference_record_id = after_record.col(); + } + const XmlNode* before = set->get_child("before", RSM_NS); + if (before) + { + paging_order = Database::Paging::last; + if (!before->get_inner().empty()) + { + auto before_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end); + reference_record_id = before_record.col(); + } } } // Do not send more than 100 messages, even if the client asked for more, @@ -742,7 +753,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if ((limit == -1 && start.empty() && end.empty()) || limit > 100) limit = 101; - auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, after_id); + auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_record_id, paging_order); bool complete = true; if (lines.size() > 100) { -- cgit v1.2.3 From 158d743bf539399e48c64044639b90e5c1705ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 4 Mar 2018 22:18:58 +0100 Subject: Remove the virtual channel feature altogether --- src/xmpp/biboumi_component.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index fe6cc1b..891b715 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -148,8 +148,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) try { if (iid.type == Iid::Type::Channel && !iid.get_server().empty()) - { // presence toward a MUC that corresponds to an irc channel, or a - // dummy channel if iid.chan is empty + { // presence toward a MUC that corresponds to an irc channel if (type.empty()) { const std::string own_nick = bridge->get_own_nick(iid); -- cgit v1.2.3 From 9500bfd4ccb21b261fd8204180d78553704f7acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 18 Mar 2018 19:33:07 +0100 Subject: Reflect message IDs in channel MUCs fix #3283 --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 891b715..f35c7f4 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -279,7 +279,7 @@ void BiboumiComponent::handle_message(const Stanza& stanza) { if (body && !body->get_inner().empty()) { - bridge->send_channel_message(iid, body->get_inner()); + bridge->send_channel_message(iid, body->get_inner(), id); } const XmlNode* subject = stanza.get_child("subject", COMPONENT_NS); if (subject) -- cgit v1.2.3 From 0de282a177baa0ed2d38a68715e78344172894ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 18 Mar 2018 19:37:41 +0100 Subject: Advertise the muc#stable_id feature on disco#info results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From XEP 0045: “Note: the requirement to reflect the 'id' attribute was added in version 1.31 of this XEP. Servers following the new specification SHOULD advertise that with a disco info feature of 'http://jabber.org/protocol/muc#stable_id' on both the service domain and on individual MUCs, so that clients can check for support.” --- src/xmpp/biboumi_component.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index f35c7f4..f25aeea 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -915,7 +915,7 @@ void BiboumiComponent::send_self_disco_info(const std::string& id, const std::st identity["category"] = "conference"; identity["type"] = "irc"; identity["name"] = "Biboumi XMPP-IRC gateway"; - for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS}) + for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS, STABLE_MUC_ID_NS}) { XmlSubNode feature(query, "feature"); feature["var"] = ns; @@ -939,7 +939,7 @@ void BiboumiComponent::send_irc_server_disco_info(const std::string& id, const s identity["category"] = "conference"; identity["type"] = "irc"; identity["name"] = "IRC server " + from.local + " over Biboumi"; - for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS}) + for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS, STABLE_MUC_ID_NS}) { XmlSubNode feature(query, "feature"); feature["var"] = ns; @@ -982,7 +982,7 @@ void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const identity["category"] = "conference"; identity["type"] = "irc"; identity["name"] = "IRC channel " + iid.get_local() + " from server " + iid.get_server() + " over biboumi"; - for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS}) + for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS, STABLE_MUC_ID_NS}) { XmlSubNode feature(query, "feature"); feature["var"] = ns; -- cgit v1.2.3 From e2fc3cf68e1dc145e75fe67f2543765ff00ba839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Mar 2018 16:16:30 +0100 Subject: Properly handle force-join presences by sending everything in return fix #3305 --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index f25aeea..02383f6 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -181,7 +181,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) history_limit.stanzas = 0; } bridge->join_irc_channel(iid, to.resource, password ? password->get_inner(): "", - from.resource, history_limit); + from.resource, history_limit, x != nullptr); } else if (type == "unavailable") { -- cgit v1.2.3 From d81a9456ac33d7be8e494a6e7af01b45b8fa2478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 23 Mar 2018 21:17:44 +0100 Subject: Change the nick of the joining user AFTER sending all the join stuff fix #3305 --- src/xmpp/biboumi_component.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 02383f6..26e8035 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -152,8 +152,6 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) if (type.empty()) { const std::string own_nick = bridge->get_own_nick(iid); - if (!own_nick.empty() && own_nick != to.resource) - 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; @@ -182,6 +180,8 @@ void BiboumiComponent::handle_presence(const Stanza& stanza) } bridge->join_irc_channel(iid, to.resource, password ? password->get_inner(): "", from.resource, history_limit, x != nullptr); + if (!own_nick.empty() && own_nick != to.resource) + bridge->send_irc_nick_change(iid, to.resource, from.resource); } else if (type == "unavailable") { -- cgit v1.2.3 From 49bb383080fab1a88c343d84825dd40892ee085d Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Mon, 26 Mar 2018 16:55:42 +0200 Subject: Channel disco-info: use shorter string --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 26e8035..12dd520 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -981,7 +981,7 @@ void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const XmlSubNode identity(query, "identity"); identity["category"] = "conference"; identity["type"] = "irc"; - identity["name"] = "IRC channel " + iid.get_local() + " from server " + iid.get_server() + " over biboumi"; + identity["name"] = ""s + iid.get_local() + " on " + iid.get_server(); for (const char *ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS, PING_NS, MAM_NS, VERSION_NS, STABLE_MUC_ID_NS}) { XmlSubNode feature(query, "feature"); -- cgit v1.2.3 From 857c7d3972a03cbeebf730d99b924d3710dee6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 10 Apr 2018 23:33:59 +0200 Subject: Use a different Date data type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PLEASE backup your database before testing this commit, and report any migration issue. In postgresql, we use timestamp with timezone. In sqlite3 we use REAL (the date is expressed as julianday) This requires a migration of the muclogline_ table: In postgresql it’s pretty simple, we convert all the integer into timestamps With sqlite3, we actually rename the table, create the new one with the correct type, then copy everything to the new table, with a conversion function for the Date_ column, and then we delete the old table. fix #3343 --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 12dd520..9748258 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -808,7 +808,7 @@ void BiboumiComponent::send_archived_message(const Database::MucLogLine& log_lin XmlSubNode delay(forwarded, "delay"); delay["xmlns"] = DELAY_NS; - delay["stamp"] = utils::to_string(log_line.col()); + delay["stamp"] = log_line.col().to_string(); XmlSubNode submessage(forwarded, "message"); submessage["xmlns"] = CLIENT_NS; -- cgit v1.2.3 From d375a9edeb7a2aa21497a2cbc1db0d3f703283a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 13 Apr 2018 23:37:46 +0200 Subject: one log_debug -> log_error, also some trivial indent --- src/xmpp/biboumi_component.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 9748258..acaac34 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -760,10 +760,10 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) lines.erase(lines.begin(), std::prev(lines.end(), 100)); } for (const Database::MucLogLine& line: lines) - { - if (!line.col().empty()) - this->send_archived_message(line, to.full(), from.full(), query_id); - } + { + if (!line.col().empty()) + this->send_archived_message(line, to.full(), from.full(), query_id); + } { auto fin_ptr = std::make_unique("fin"); { -- cgit v1.2.3 From 5ef7ba08028065b03d51d1dc70bb35aeb41ae19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 14 Apr 2018 19:48:45 +0200 Subject: Use the Date to find a next page in RSM, not the id This way, it works, whatever the order of insertion in the database was. fix #3343 --- src/xmpp/biboumi_component.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index acaac34..f82a923 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -719,7 +719,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) } const XmlNode* set = query->get_child("set", RSM_NS); int limit = -1; - Id::real_type reference_record_id{Id::unset_value}; + std::string reference_uuid{}; Database::Paging paging_order{Database::Paging::first}; if (set) { @@ -729,9 +729,10 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) const XmlNode* after = set->get_child("after", RSM_NS); if (after) { - auto after_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), + // Will throw if the uuid does not exist, that’s all. + Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), after->get_inner(), start, end); - reference_record_id = after_record.col(); + reference_uuid = after->get_inner(); } const XmlNode* before = set->get_child("before", RSM_NS); if (before) @@ -739,8 +740,9 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) paging_order = Database::Paging::last; if (!before->get_inner().empty()) { - auto before_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end); - reference_record_id = before_record.col(); + // Will throw if the uuid does not exist + Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end); + reference_uuid = before->get_inner(); } } } @@ -752,7 +754,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if ((limit == -1 && start.empty() && end.empty()) || limit > 100) limit = 101; - auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_record_id, paging_order); + auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_uuid, paging_order); bool complete = true; if (lines.size() > 100) { -- cgit v1.2.3 From 0d487f40c51463a15013255990f374fa9c41e590 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 31 Mar 2018 16:55:30 +0200 Subject: Use Config::is_in_list() to allow for multiple admins --- src/xmpp/biboumi_component.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index f82a923..9bcfa8a 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -551,24 +551,21 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) if (to.local.empty()) { // Get biboumi's adhoc commands this->send_adhoc_commands_list(id, from, this->served_hostname, - (Config::get("admin", "") == - from_jid.bare()), + Config::is_in_list("admin", from_jid.bare()), this->adhoc_commands_handler); stanza_error.disable(); } else if (iid.type == Iid::Type::Server) { // Get the server's adhoc commands this->send_adhoc_commands_list(id, from, to_str, - (Config::get("admin", "") == - from_jid.bare()), + Config::is_in_list("admin", from_jid.bare()), this->irc_server_adhoc_commands_handler); stanza_error.disable(); } else if (iid.type == Iid::Type::Channel && to.resource.empty()) { // Get the channel's adhoc commands this->send_adhoc_commands_list(id, from, to_str, - (Config::get("admin", "") == - from_jid.bare()), + Config::is_in_list("admin", from_jid.bare()), this->irc_channel_adhoc_commands_handler); stanza_error.disable(); } -- cgit v1.2.3 From a90f196a1ce779d502baf0aadff6e6917fec8a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 24 Apr 2018 19:13:10 +0200 Subject: Revert "Use the Date to find a next page in RSM, not the id" This reverts commit 5ef7ba08028065b03d51d1dc70bb35aeb41ae19d. --- src/xmpp/biboumi_component.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 9bcfa8a..95b38f0 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -716,7 +716,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) } const XmlNode* set = query->get_child("set", RSM_NS); int limit = -1; - std::string reference_uuid{}; + Id::real_type reference_record_id{Id::unset_value}; Database::Paging paging_order{Database::Paging::first}; if (set) { @@ -726,10 +726,9 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) const XmlNode* after = set->get_child("after", RSM_NS); if (after) { - // Will throw if the uuid does not exist, that’s all. - Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), + auto after_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), after->get_inner(), start, end); - reference_uuid = after->get_inner(); + reference_record_id = after_record.col(); } const XmlNode* before = set->get_child("before", RSM_NS); if (before) @@ -737,9 +736,8 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) paging_order = Database::Paging::last; if (!before->get_inner().empty()) { - // Will throw if the uuid does not exist - Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end); - reference_uuid = before->get_inner(); + auto before_record = Database::get_muc_log(from.bare(), iid.get_local(), iid.get_server(), before->get_inner(), start, end); + reference_record_id = before_record.col(); } } } @@ -751,7 +749,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if ((limit == -1 && start.empty() && end.empty()) || limit > 100) limit = 101; - auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_uuid, paging_order); + auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_record_id, paging_order); bool complete = true; if (lines.size() > 100) { -- cgit v1.2.3 From 61de6b1dac4ef29627f3bdb9ce11b6c0d06f4a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 24 Apr 2018 19:19:06 +0200 Subject: Revert "Use a different Date data type" This reverts commit 857c7d3972a03cbeebf730d99b924d3710dee6a0. --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 95b38f0..6dc5fc5 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -805,7 +805,7 @@ void BiboumiComponent::send_archived_message(const Database::MucLogLine& log_lin XmlSubNode delay(forwarded, "delay"); delay["xmlns"] = DELAY_NS; - delay["stamp"] = log_line.col().to_string(); + delay["stamp"] = utils::to_string(log_line.col()); XmlSubNode submessage(forwarded, "message"); submessage["xmlns"] = CLIENT_NS; -- cgit v1.2.3 From b0168fd45b3683c2d6f61ccae67dcd5b918a363d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 29 Apr 2018 22:18:26 +0200 Subject: =?UTF-8?q?mam:=20Send=20=E2=80=9Cfin=20complete=E2=80=9D=20only?= =?UTF-8?q?=20when=20appropriate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also simplify how we did the whole “limit + 1” And fix one bad interpretation of the XEP for the case where the query has no after or before restriction. fix #3349 --- src/xmpp/biboumi_component.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 6dc5fc5..dbaf8a4 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -743,19 +743,15 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) } // Do not send more than 100 messages, even if the client asked for more, // or if it didn’t specify any limit. - // 101 is just a trick to know if there are more available messages. - // If our query returns 101 message, we know it’s incomplete, but we - // still send only 100 - if ((limit == -1 && start.empty() && end.empty()) - || limit > 100) - limit = 101; - auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end, reference_record_id, paging_order); - bool complete = true; - if (lines.size() > 100) - { - complete = false; - lines.erase(lines.begin(), std::prev(lines.end(), 100)); - } + if (limit < 0 || limit > 100) + limit = 100; + auto result = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), + limit, + start, end, + reference_record_id, paging_order); + bool complete = std::get(result); + auto& lines = std::get<1>(result); + for (const Database::MucLogLine& line: lines) { if (!line.col().empty()) -- cgit v1.2.3 From 760076a33aa50c700bc0d825e5cb9d0fa9d5bd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 1 Jun 2018 12:29:04 +0200 Subject: Make the global ad-hoc configure command available in fixed mode fix #3360 --- src/xmpp/biboumi_component.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index dbaf8a4..be34873 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -72,11 +72,16 @@ BiboumiComponent::BiboumiComponent(std::shared_ptr& poller, const std::s AdhocCommand configure_global_command({&ConfigureGlobalStep1, &ConfigureGlobalStep2}, "Configure a few settings", false); if (!Config::get("fixed_irc_server", "").empty()) - this->adhoc_commands_handler.add_command("configure", configure_server_command); + { + this->adhoc_commands_handler.add_command("server-configure", configure_server_command); + this->adhoc_commands_handler.add_command("global-configure", configure_global_command); + } else - this->adhoc_commands_handler.add_command("configure", configure_global_command); + { + this->adhoc_commands_handler.add_command("configure", configure_global_command); + this->irc_server_adhoc_commands_handler.add_command("configure", configure_server_command); + } - this->irc_server_adhoc_commands_handler.add_command("configure", configure_server_command); this->irc_channel_adhoc_commands_handler.add_command("configure", {{&ConfigureIrcChannelStep1, &ConfigureIrcChannelStep2}, "Configure a few settings for that IRC channel", false}); #endif } -- cgit v1.2.3 From 2f0e26db4cd91037463e5aa45c7538a942a9eee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 17 Jun 2018 15:16:49 +0200 Subject: =?UTF-8?q?Channels=E2=80=99=20disco#info=20includes=20the=20numbe?= =?UTF-8?q?r=20of=20participants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #3311 --- src/xmpp/biboumi_component.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index be34873..852b13f 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -514,7 +514,11 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) { if (node.empty()) { - this->send_irc_channel_disco_info(id, from, to_str); + const IrcClient* irc_client = bridge->find_irc_client(iid.get_server()); + const IrcChannel* irc_channel{}; + if (irc_client) + irc_channel = irc_client->find_channel(iid.get_local()); + this->send_irc_channel_disco_info(id, from, to_str, irc_channel); stanza_error.disable(); } else if (node == MUC_TRAFFIC_NS) @@ -964,7 +968,8 @@ void BiboumiComponent::send_irc_channel_muc_traffic_info(const std::string& id, this->send_stanza(iq); } -void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const std::string& jid_to, const std::string& jid_from) +void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const std::string& jid_to, + const std::string& jid_from, const IrcChannel* irc_channel) { Jid from(jid_from); Iid iid(from.local, {}); @@ -985,6 +990,26 @@ void BiboumiComponent::send_irc_channel_disco_info(const std::string& id, const XmlSubNode feature(query, "feature"); feature["var"] = ns; } + + XmlSubNode x(query, "x"); + x["xmlns"] = DATAFORM_NS; + x["type"] = "result"; + { + XmlSubNode field(x, "field"); + field["var"] = "FORM_TYPE"; + field["type"] = "hidden"; + XmlSubNode value(field, "value"); + value.set_inner("http://jabber.org/protocol/muc#roominfo"); + } + + if (irc_channel && irc_channel->joined) + { + XmlSubNode field(x, "field"); + field["var"] = "muc#roominfo_occupants"; + field["label"] = "Number of occupants"; + XmlSubNode value(field, "value"); + value.set_inner(std::to_string(irc_channel->get_users().size())); + } } this->send_stanza(iq); } -- cgit v1.2.3 From 21a79b7bad51e755cee2890aa6d0bec5dd45f901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 19 Jun 2018 21:31:11 +0200 Subject: Reject messages from unjoined resources, with an error fix #3346 --- src/xmpp/biboumi_component.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 852b13f..8d97d07 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -273,9 +273,10 @@ void BiboumiComponent::handle_message(const Stanza& stanza) std::string error_type("cancel"); std::string error_name("internal-server-error"); - utils::ScopeGuard stanza_error([this, &from_str, &to_str, &id, &error_type, &error_name](){ + std::string error_text{}; + utils::ScopeGuard stanza_error([this, &from_str, &to_str, &id, &error_type, &error_name, &error_text](){ this->send_stanza_error("message", from_str, to_str, id, - error_type, error_name, ""); + error_type, error_name, error_text); }); const XmlNode* body = stanza.get_child("body", COMPONENT_NS); @@ -284,7 +285,15 @@ void BiboumiComponent::handle_message(const Stanza& stanza) { if (body && !body->get_inner().empty()) { - bridge->send_channel_message(iid, body->get_inner(), id); + if (bridge->is_resource_in_chan(iid.to_tuple(), from.resource)) + bridge->send_channel_message(iid, body->get_inner(), id); + else + { + error_type = "modify"; + error_name = "not-acceptable"; + error_text = "You are not a participant in this room."; + return; + } } const XmlNode* subject = stanza.get_child("subject", COMPONENT_NS); if (subject) -- cgit v1.2.3 From 782732ba167470fa99ab3d0900c02295b4684b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 4 Aug 2018 14:50:33 +0200 Subject: Remove a bunch of useless empty lines --- src/xmpp/biboumi_component.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 8d97d07..fa10932 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -359,7 +359,6 @@ void BiboumiComponent::handle_message(const Stanza& stanza) this->send_invitation_from_fulljid(std::to_string(iid), invite_to, from_str); } } - } } catch (const IRCNotConnected& ex) { @@ -605,7 +604,6 @@ void BiboumiComponent::handle_iq(const Stanza& stanza) const XmlNode* max = set_node->get_child("max", RSM_NS); if (max) rs_info.max = std::atoi(max->get_inner().data()); - } if (rs_info.max == -1) rs_info.max = 100; -- cgit v1.2.3 From b1564e4ddc3e54ad78788a6f5643056d03a41678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 23 Aug 2018 20:31:31 +0200 Subject: Fix a bunch of int to unsigned int conversion warnings --- src/xmpp/biboumi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index fa10932..6add068 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -762,7 +762,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza) if (limit < 0 || limit > 100) limit = 100; auto result = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), - limit, + static_cast(limit), start, end, reference_record_id, paging_order); bool complete = std::get(result); -- cgit v1.2.3 From 478619b10a27f7a25ba0b1082f4b12981b29d546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 26 Aug 2018 15:42:38 +0200 Subject: Trivial little syntax changes --- src/xmpp/biboumi_component.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/xmpp/biboumi_component.cpp') diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index 6add068..85617e8 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -102,8 +102,8 @@ void BiboumiComponent::shutdown() void BiboumiComponent::clean() { - auto it = this->bridges.begin(); - while (it != this->bridges.end()) + auto it = std::begin(this->bridges); + while (it != std::end(this->bridges)) { it->second->clean(); if (it->second->active_clients() == 0) -- cgit v1.2.3