diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bridge/bridge.cpp | 6 | ||||
-rw-r--r-- | src/bridge/bridge.hpp | 2 | ||||
-rw-r--r-- | src/irc/irc_client.cpp | 12 | ||||
-rw-r--r-- | src/irc/irc_client.hpp | 1 | ||||
-rw-r--r-- | src/xmpp/biboumi_component.cpp | 16 | ||||
-rw-r--r-- | src/xmpp/biboumi_component.hpp | 1 |
6 files changed, 38 insertions, 0 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp index f6fefd9..f69da77 100644 --- a/src/bridge/bridge.cpp +++ b/src/bridge/bridge.cpp @@ -798,6 +798,12 @@ void Bridge::send_xmpp_ping_request(const std::string& nick, const std::string& this->xmpp.send_ping_request(utils::tolower(nick) + "%" + utils::empty_if_fixed_server(hostname), this->user_jid + "/" + *resources.begin(), utils::revstr(id)); } +void Bridge::send_xmpp_invitation(const Iid& iid, const std::string& author) +{ + for (const auto& resource: this->resources_in_server[iid.get_server()]) + this->xmpp.send_invitation(std::to_string(iid), this->user_jid + "/" + resource, author); +} + void Bridge::set_preferred_from_jid(const std::string& nick, const std::string& full_jid) { auto it = this->preferred_user_from.find(nick); diff --git a/src/bridge/bridge.hpp b/src/bridge/bridge.hpp index bcad030..6fdbcc9 100644 --- a/src/bridge/bridge.hpp +++ b/src/bridge/bridge.hpp @@ -175,6 +175,8 @@ public: */ void send_xmpp_ping_request(const std::string& nick, const std::string& hostname, const std::string& id); + void send_xmpp_invitation(const Iid& iid, const std::string& author); + /** * Misc */ diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp index 6d4df4a..e4b6377 100644 --- a/src/irc/irc_client.cpp +++ b/src/irc/irc_client.cpp @@ -75,6 +75,7 @@ static const std::unordered_map<std::string, {"PING", {&IrcClient::send_pong_command, {1, 0}}}, {"PONG", {&IrcClient::on_pong, {0, 0}}}, {"KICK", {&IrcClient::on_kick, {3, 0}}}, + {"INVITE", {&IrcClient::on_invite, {2, 0}}}, {"401", {&IrcClient::on_generic_error, {2, 0}}}, {"402", {&IrcClient::on_generic_error, {2, 0}}}, @@ -971,6 +972,17 @@ void IrcClient::on_kick(const IrcMessage& message) this->bridge.kick_muc_user(std::move(iid), target, reason, author.nick); } +void IrcClient::on_invite(const IrcMessage& message) +{ + const std::string& author = message.arguments[0]; + Iid iid; + iid.set_local(message.arguments[1]); + iid.set_server(this->hostname); + iid.type = Iid::Type::Channel; + + this->bridge.send_xmpp_invitation(iid, author); +} + void IrcClient::on_mode(const IrcMessage& message) { const std::string target = message.arguments[0]; diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp index 6fa40ce..9f53c3c 100644 --- a/src/irc/irc_client.hpp +++ b/src/irc/irc_client.hpp @@ -249,6 +249,7 @@ public: void on_welcome_message(const IrcMessage& message); void on_part(const IrcMessage& message); void on_error(const IrcMessage& message); + void on_invite(const IrcMessage& message); void on_nick(const IrcMessage& message); void on_kick(const IrcMessage& message); void on_mode(const IrcMessage& message); diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index cb9aac8..5c52494 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -645,3 +645,19 @@ void BiboumiComponent::send_iq_room_list_result(const std::string& id, iq.add_child(std::move(query)); this->send_stanza(iq); } + +void BiboumiComponent::send_invitation(const std::string& room_target, + const std::string& jid_to, + const std::string& author_nick) +{ + Stanza message("message"); + message["from"] = room_target + "@" + this->served_hostname; + message["to"] = jid_to; + XmlNode x("x"); + x["xmlns"] = MUC_USER_NS; + XmlNode invite("invite"); + invite["from"] = room_target + "@" + this->served_hostname + "/" + author_nick; + x.add_child(std::move(invite)); + message.add_child(std::move(x)); + this->send_stanza(message); +} diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp index 24d768a..0dbf8f1 100644 --- a/src/xmpp/biboumi_component.hpp +++ b/src/xmpp/biboumi_component.hpp @@ -74,6 +74,7 @@ public: void send_iq_room_list_result(const std::string& id, const std::string& to_jid, const std::string& from, const std::vector<ListElement>& rooms_list); + void send_invitation(const std::string& room_target, const std::string& jid_to, const std::string& author_nick); /** * Handle the various stanza types */ |