Entirely remove the code for the “preferred_from” nick
Since private messages are now always coming from the server-wide JIDs
This commit is contained in:
@@ -453,9 +453,6 @@ void Bridge::leave_irc_channel(Iid&& iid, const std::string& status_message, con
|
|||||||
}
|
}
|
||||||
if (persistent)
|
if (persistent)
|
||||||
this->remove_resource_from_chan(key, resource);
|
this->remove_resource_from_chan(key, resource);
|
||||||
// Since there are no resources left in that channel, we don't
|
|
||||||
// want to receive private messages using this room's JID
|
|
||||||
this->remove_all_preferred_from_jid_of_room(iid.get_local());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1132,34 +1129,6 @@ void Bridge::on_irc_client_disconnected(const std::string& hostname)
|
|||||||
this->xmpp.on_irc_client_disconnected(hostname, this->user_jid);
|
this->xmpp.on_irc_client_disconnected(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bridge::remove_all_preferred_from_jid_of_room(const std::string& channel_name)
|
|
||||||
{
|
|
||||||
for (auto it = this->preferred_user_from.begin(); it != this->preferred_user_from.end();)
|
|
||||||
{
|
|
||||||
Iid iid(Jid(it->second).local, {});
|
|
||||||
if (iid.get_local() == channel_name)
|
|
||||||
it = this->preferred_user_from.erase(it);
|
|
||||||
else
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bridge::add_waiting_irc(irc_responder_callback_t&& callback)
|
void Bridge::add_waiting_irc(irc_responder_callback_t&& callback)
|
||||||
{
|
{
|
||||||
this->waiting_irc.emplace_back(std::move(callback));
|
this->waiting_irc.emplace_back(std::move(callback));
|
||||||
|
|||||||
@@ -216,19 +216,6 @@ public:
|
|||||||
* Get the number of server to which this bridge is connected or connecting.
|
* Get the number of server to which this bridge is connected or connecting.
|
||||||
*/
|
*/
|
||||||
size_t active_clients() const;
|
size_t active_clients() const;
|
||||||
/**
|
|
||||||
* Add (or replace the existing) <nick, jid> into the preferred_user_from map
|
|
||||||
*/
|
|
||||||
void set_preferred_from_jid(const std::string& nick, const std::string& full_jid);
|
|
||||||
/**
|
|
||||||
* Remove the preferred jid for the given IRC nick
|
|
||||||
*/
|
|
||||||
void remove_preferred_from_jid(const std::string& nick);
|
|
||||||
/**
|
|
||||||
* Given a channel_name, remove all preferred from_jid that come
|
|
||||||
* from this chan.
|
|
||||||
*/
|
|
||||||
void remove_all_preferred_from_jid_of_room(const std::string& channel_name);
|
|
||||||
/**
|
/**
|
||||||
* Add a callback to the waiting list of irc callbacks.
|
* Add a callback to the waiting list of irc callbacks.
|
||||||
*/
|
*/
|
||||||
@@ -283,14 +270,6 @@ private:
|
|||||||
* their sockets.
|
* their sockets.
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<Poller> poller;
|
std::shared_ptr<Poller> poller;
|
||||||
/**
|
|
||||||
* A map of <nick, full_jid>. For example if this map contains <"toto",
|
|
||||||
* "#somechan%server@biboumi/ToTo">, whenever a private message is
|
|
||||||
* received from the user "toto", instead of forwarding it to XMPP with
|
|
||||||
* from='toto!server@biboumi', we use instead
|
|
||||||
* from='#somechan%server@biboumi/ToTo'
|
|
||||||
*/
|
|
||||||
std::unordered_map<std::string, std::string> preferred_user_from;
|
|
||||||
/**
|
/**
|
||||||
* A list of callbacks that are waiting for some IrcMessage to trigger a
|
* A list of callbacks that are waiting for some IrcMessage to trigger a
|
||||||
* response. We add callbacks in this list whenever we received an IQ
|
* response. We add callbacks in this list whenever we received an IQ
|
||||||
|
|||||||
@@ -360,7 +360,6 @@ void BiboumiComponent::handle_message(const Stanza& stanza)
|
|||||||
if (iid.type == Iid::Type::User && !iid.get_local().empty())
|
if (iid.type == Iid::Type::User && !iid.get_local().empty())
|
||||||
{
|
{
|
||||||
bridge->send_private_message(iid, body->get_inner());
|
bridge->send_private_message(iid, body->get_inner());
|
||||||
bridge->remove_preferred_from_jid(iid.get_local());
|
|
||||||
}
|
}
|
||||||
else if (iid.type != Iid::Type::User && !to.resource.empty())
|
else if (iid.type != Iid::Type::User && !to.resource.empty())
|
||||||
{ // a message for chan%server@biboumi/Nick or
|
{ // a message for chan%server@biboumi/Nick or
|
||||||
@@ -368,7 +367,6 @@ void BiboumiComponent::handle_message(const Stanza& stanza)
|
|||||||
// Convert that into a message to nick!server
|
// Convert that into a message to nick!server
|
||||||
Iid user_iid(utils::tolower(to.resource), iid.get_server(), Iid::Type::User);
|
Iid user_iid(utils::tolower(to.resource), iid.get_server(), Iid::Type::User);
|
||||||
bridge->send_private_message(user_iid, body->get_inner());
|
bridge->send_private_message(user_iid, body->get_inner());
|
||||||
bridge->set_preferred_from_jid(user_iid.get_local(), to_str);
|
|
||||||
}
|
}
|
||||||
else if (iid.type == Iid::Type::Server)
|
else if (iid.type == Iid::Type::Server)
|
||||||
bridge->send_raw_message(iid.get_server(), body->get_inner());
|
bridge->send_raw_message(iid.get_server(), body->get_inner());
|
||||||
|
|||||||
Reference in New Issue
Block a user