Correctly set status="110" in the presence for the target of a kick

This commit is contained in:
louiz’
2016-10-07 23:28:40 +02:00
parent 8cf292fa44
commit 8ac8d2b242
5 changed files with 18 additions and 15 deletions
+8 -5
View File
@@ -509,11 +509,8 @@ void XmppComponent::send_nick_change(const std::string& muc_name,
this->send_user_join(muc_name, new_nick, "", affiliation, role, jid_to, self); this->send_user_join(muc_name, new_nick, "", affiliation, role, jid_to, self);
} }
void XmppComponent::kick_user(const std::string& muc_name, void XmppComponent::kick_user(const std::string& muc_name, const std::string& target, const std::string& txt,
const std::string& target, const std::string& author, const std::string& jid_to, const bool self)
const std::string& txt,
const std::string& author,
const std::string& jid_to)
{ {
Stanza presence("presence"); Stanza presence("presence");
presence["from"] = muc_name + "@" + this->served_hostname + "/" + target; presence["from"] = muc_name + "@" + this->served_hostname + "/" + target;
@@ -535,6 +532,12 @@ void XmppComponent::kick_user(const std::string& muc_name,
XmlNode status("status"); XmlNode status("status");
status["code"] = "307"; status["code"] = "307";
x.add_child(std::move(status)); x.add_child(std::move(status));
if (self)
{
XmlNode status("status");
status["code"] = "110";
x.add_child(std::move(status));
}
presence.add_child(std::move(x)); presence.add_child(std::move(x));
this->send_stanza(presence); this->send_stanza(presence);
} }
+2 -5
View File
@@ -164,11 +164,8 @@ public:
/** /**
* An user is kicked from a room * An user is kicked from a room
*/ */
void kick_user(const std::string& muc_name, void kick_user(const std::string& muc_name, const std::string& target, const std::string& reason,
const std::string& target, const std::string& author, const std::string& jid_to, const bool self);
const std::string& reason,
const std::string& author,
const std::string& jid_to);
/** /**
* Send a generic presence error * Send a generic presence error
*/ */
+3 -2
View File
@@ -916,10 +916,11 @@ size_t Bridge::active_clients() const
return this->irc_clients.size(); return this->irc_clients.size();
} }
void Bridge::kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author) void Bridge::kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author,
const bool self)
{ {
for (const auto& resource: this->resources_in_chan[iid.to_tuple()]) for (const auto& resource: this->resources_in_chan[iid.to_tuple()])
this->xmpp.kick_user(std::to_string(iid), target, reason, author, this->user_jid + "/" + resource); this->xmpp.kick_user(std::to_string(iid), target, reason, author, this->user_jid + "/" + resource, self);
} }
void Bridge::send_nickname_conflict_error(const Iid& iid, const std::string& nickname) void Bridge::send_nickname_conflict_error(const Iid& iid, const std::string& nickname)
+2 -1
View File
@@ -181,7 +181,8 @@ public:
const std::string& new_nick, const std::string& new_nick,
const char user_mode, const char user_mode,
const bool self); const bool self);
void kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author); void kick_muc_user(Iid&& iid, const std::string& target, const std::string& reason, const std::string& author,
const bool self);
void send_nickname_conflict_error(const Iid& iid, const std::string& nickname); void send_nickname_conflict_error(const Iid& iid, const std::string& nickname);
/** /**
* Send a role/affiliation change, matching the change of mode for that user * Send a role/affiliation change, matching the change of mode for that user
+3 -2
View File
@@ -964,14 +964,15 @@ void IrcClient::on_kick(const IrcMessage& message)
IrcChannel* channel = this->get_channel(chan_name); IrcChannel* channel = this->get_channel(chan_name);
if (!channel->joined) if (!channel->joined)
return ; return ;
if (channel->get_self()->nick == target) const bool self = channel->get_self()->nick == target;
if (self)
channel->joined = false; channel->joined = false;
IrcUser author(message.prefix); IrcUser author(message.prefix);
Iid iid; Iid iid;
iid.set_local(chan_name); iid.set_local(chan_name);
iid.set_server(this->hostname); iid.set_server(this->hostname);
iid.type = Iid::Type::Channel; iid.type = Iid::Type::Channel;
this->bridge.kick_muc_user(std::move(iid), target, reason, author.nick); this->bridge.kick_muc_user(std::move(iid), target, reason, author.nick, self);
} }
void IrcClient::on_invite(const IrcMessage& message) void IrcClient::on_invite(const IrcMessage& message)