From c23c99dac109b3cfd53c72dbcbaf8b483bd6f4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 24 Aug 2017 23:55:32 +0200 Subject: =?UTF-8?q?Don=E2=80=99t=20forget=20to=20remove=20the=20user=20fro?= =?UTF-8?q?m=20the=20channel,=20when=20kicked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #3291 --- src/irc/irc_client.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 46dbdbe..ba593c9 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -1073,12 +1073,18 @@ void IrcClient::on_nick(const IrcMessage& message) void IrcClient::on_kick(const IrcMessage& message) { const std::string chan_name = utils::tolower(message.arguments[0]); - const std::string target = message.arguments[1]; + const std::string target_nick = message.arguments[1]; const std::string reason = message.arguments[2]; IrcChannel* channel = this->get_channel(chan_name); if (!channel->joined) return ; - const bool self = channel->get_self()->nick == target; + const IrcUser* target = channel->find_user(target_nick); + if (!target) + { + log_warning("Received a KICK command from a nick absent from the channel."); + return; + } + const bool self = channel->get_self() == target; if (self) channel->joined = false; IrcUser author(message.prefix); @@ -1086,7 +1092,8 @@ void IrcClient::on_kick(const IrcMessage& message) iid.set_local(chan_name); iid.set_server(this->hostname); iid.type = Iid::Type::Channel; - this->bridge.kick_muc_user(std::move(iid), target, reason, author.nick, self); + this->bridge.kick_muc_user(std::move(iid), target_nick, reason, author.nick, self); + channel->remove_user(target); } void IrcClient::on_invite(const IrcMessage& message) -- cgit v1.2.3 From 1997fb5c6a5f791960575a31bd34dfd24cf96a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Thu, 24 Aug 2017 23:56:00 +0200 Subject: Small refactor in on_quit() --- src/irc/irc_client.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index ba593c9..7776c8d 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -1017,19 +1017,17 @@ void IrcClient::on_quit(const IrcMessage& message) const std::string& chan_name = pair.first; IrcChannel* channel = pair.second.get(); const IrcUser* user = channel->find_user(message.prefix); + if (!user) + continue; bool self = false; if (user == channel->get_self()) self = true; - if (user) - { - std::string nick = user->nick; - channel->remove_user(user); - Iid iid; - iid.set_local(chan_name); - iid.set_server(this->hostname); - iid.type = Iid::Type::Channel; - this->bridge.send_muc_leave(iid, std::move(nick), txt, self, false); - } + Iid iid; + iid.set_local(chan_name); + iid.set_server(this->hostname); + iid.type = Iid::Type::Channel; + this->bridge.send_muc_leave(iid, user->nick, txt, self, false); + channel->remove_user(user); } } -- cgit v1.2.3 From fcaffb9e778ad5962e69dc23c1fc91eb59a27945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sun, 27 Aug 2017 22:30:44 +0200 Subject: Add support for the "history" node on MUC join Supports the "seconds", "maxstanzas", "since" and "maxchars" (but only =0) attributes. fix #3270 --- src/irc/irc_client.cpp | 2 +- src/irc/irc_client.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 7776c8d..5f26bf0 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -784,7 +784,7 @@ void IrcClient::on_channel_completely_joined(const IrcMessage& message) channel->joined = true; this->bridge.send_user_join(this->hostname, chan_name, channel->get_self(), channel->get_self()->get_most_significant_mode(this->sorted_user_modes), true); - this->bridge.send_room_history(this->hostname, chan_name); + this->bridge.send_room_history(this->hostname, chan_name, this->history_limit); this->bridge.send_topic(this->hostname, chan_name, channel->topic, channel->topic_author); } diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index aec6cd9..de5c520 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -5,6 +5,8 @@ #include #include +#include + #include #include @@ -296,6 +298,11 @@ public: const std::vector& get_sorted_user_modes() const { return this->sorted_user_modes; } std::set get_chantypes() const { return this->chantypes; } + + /** + * Store the history limit that the client asked when joining this room. + */ + HistoryLimit history_limit; private: /** * The hostname of the server we are connected to. -- cgit v1.2.3 From 435a63a070e62a11b0a6f5a3c06c445e1a79b9f5 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Wed, 10 Jan 2018 13:36:53 +0100 Subject: Change max line length to more conservative constants --- src/irc/irc_client.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/irc') diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 5f26bf0..40078d9 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -483,12 +483,16 @@ bool IrcClient::send_channel_message(const std::string& chan_name, const std::st } // The max size is 512, taking into account the whole message, not just // the text we send. - // This includes our own nick, username and host (because this will be - // added by the server into our message), in addition to the basic - // components of the message we send (command name, chan name, \r\n et) + // This includes our own nick, constants for username and host (because these + // are notoriously hard to know what the server will use), in addition to the basic + // components of the message we send (command name, chan name, \r\n etc.) // : + NICK + ! + USER + @ + HOST + + PRIVMSG + + CHAN + + : + \r\n + // 63 is the maximum hostname length defined by the protocol. 10 seems to be + // the username limit. + constexpr auto max_username_size = 10; + constexpr auto max_hostname_size = 63; const auto line_size = 512 - - this->current_nick.size() - this->username.size() - this->own_host.size() - + this->current_nick.size() - max_username_size - max_hostname_size - ::strlen(":!@ PRIVMSG ") - chan_name.length() - ::strlen(" :\r\n"); const auto lines = cut(body, line_size); for (const auto& line: lines) -- cgit v1.2.3