Always send direct messages to the user’s bare JID

This has the following advantages:

- Works while all resources are offline (persistent channels)
- Helps with combating duplicate messages when sent to different
  resources, resources going offline, carbon-copying etc. etc.

As a side effect, this also makes the MUC PMs not be MUC PMs and
always be emitted from the server-wide JID of the sending user.

Fixes #3313.
This commit is contained in:
Jonas Schäfer
2020-09-23 23:20:47 +02:00
committed by louiz’
parent 5900c19c22
commit f8da92a8be
3 changed files with 19 additions and 40 deletions
+4 -15
View File
@@ -872,21 +872,10 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
}
else
{
const auto it = this->preferred_user_from.find(iid.get_local());
if (it != this->preferred_user_from.end())
{
const auto chan_name = Iid(Jid(it->second).local, {}).get_local();
for (const auto& resource: this->resources_in_chan[ChannelKey{chan_name, iid.get_server()}])
this->xmpp.send_message(it->second, this->make_xmpp_body(body, encoding),
this->user_jid + "/"
+ resource, "chat", true, true, true);
}
else
{
for (const auto& resource: this->resources_in_server[iid.get_server()])
this->xmpp.send_message(std::to_string(iid), this->make_xmpp_body(body, encoding),
this->user_jid + "/" + resource, "chat", false, true);
}
this->xmpp.send_message(std::to_string(iid),
this->make_xmpp_body(body, encoding),
this->user_jid,
"chat", false, true);
}
}