Messages to room participants are forwarded to the IRC user

For example, both JID #chan%server@biboumi/Toto and toto!server@biboumi are
equivalent, except that if you send a message to the first one, subsequent
messages coming from the user toto will come from that same JID. This is
done to be consistent for the XMPP user, and respond from the same JID than
the 'to' of the first message.

fix #2468
This commit is contained in:
Florent Le Coz
2014-06-18 22:42:58 +02:00
parent 56eb5df28a
commit 04de62a4e0
4 changed files with 77 additions and 11 deletions
+28 -2
View File
@@ -242,8 +242,18 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
this->xmpp->send_muc_message(std::to_string(iid), nick,
this->make_xmpp_body(body), this->user_jid);
else
this->xmpp->send_message(std::to_string(iid),
this->make_xmpp_body(body), this->user_jid, "chat");
{
std::string target = std::to_string(iid);
bool fulljid = false;
auto it = this->preferred_user_from.find(iid.get_local());
if (it != this->preferred_user_from.end())
{
target = it->second;
fulljid = true;
}
this->xmpp->send_message(target, this->make_xmpp_body(body),
this->user_jid, "chat", fulljid);
}
}
void Bridge::send_join_failed(const Iid& iid, const std::string& nick, const std::string& type, const std::string& condition, const std::string& text)
@@ -343,3 +353,19 @@ void Bridge::send_iq_version_request(const std::string& nick, const std::string&
{
this->xmpp->send_iq_version_request(nick + "!" + hostname, this->user_jid);
}
void Bridge::set_preferred_from_jid(const std::string& nick, const std::string& full_jid)
{
auto it = this->preferred_user_from.find(nick);
if (it == this->preferred_user_from.end())
this->preferred_user_from.emplace(nick, full_jid);
else
this->preferred_user_from[nick] = full_jid;
}
void Bridge::remove_preferred_from_jid(const std::string& nick)
{
auto it = this->preferred_user_from.find(nick);
if (it != this->preferred_user_from.end())
this->preferred_user_from.erase(it);
}