Auto accept presence subscription
This commit is contained in:
@@ -178,10 +178,6 @@ public:
|
|||||||
const std::string& affiliation,
|
const std::string& affiliation,
|
||||||
const std::string& role,
|
const std::string& role,
|
||||||
const std::string& jid_to);
|
const std::string& jid_to);
|
||||||
/**
|
|
||||||
* Send a result IQ with the gateway disco informations.
|
|
||||||
*/
|
|
||||||
void send_self_disco_info(const std::string& id, const std::string& jid_to);
|
|
||||||
/**
|
/**
|
||||||
* Send a result IQ with the given version, or the gateway version if the
|
* Send a result IQ with the given version, or the gateway version if the
|
||||||
* passed string is empty.
|
* passed string is empty.
|
||||||
|
|||||||
@@ -161,6 +161,16 @@ void BiboumiComponent::handle_presence(const Stanza& stanza)
|
|||||||
bridge->leave_irc_channel(std::move(iid), status ? status->get_inner() : "", from.resource);
|
bridge->leave_irc_channel(std::move(iid), status ? status->get_inner() : "", from.resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (iid.type == Iid::Type::Server || iid.type == Iid::Type::None)
|
||||||
|
{
|
||||||
|
if (type == "subscribe")
|
||||||
|
{ // Auto-accept any subscription request for an IRC server
|
||||||
|
this->add_to_roster(to_str, from.bare());
|
||||||
|
this->accept_subscription(to_str, from.bare());
|
||||||
|
this->ask_subscription(to_str, from.bare());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// A user wants to join an invalid IRC channel, return a presence error to him/her
|
// A user wants to join an invalid IRC channel, return a presence error to him/her
|
||||||
@@ -751,20 +761,6 @@ void BiboumiComponent::send_irc_channel_muc_traffic_info(const std::string id, c
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BiboumiComponent::send_iq_version_request(const std::string& from,
|
|
||||||
const std::string& jid_to)
|
|
||||||
{
|
|
||||||
Stanza iq("iq");
|
|
||||||
iq["type"] = "get";
|
|
||||||
iq["id"] = "version_"s + this->next_id();
|
|
||||||
iq["from"] = from + "@" + this->served_hostname;
|
|
||||||
iq["to"] = jid_to;
|
|
||||||
XmlNode query("query");
|
|
||||||
query["xmlns"] = VERSION_NS;
|
|
||||||
iq.add_child(std::move(query));
|
|
||||||
this->send_stanza(iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BiboumiComponent::send_ping_request(const std::string& from,
|
void BiboumiComponent::send_ping_request(const std::string& from,
|
||||||
const std::string& jid_to,
|
const std::string& jid_to,
|
||||||
const std::string& id)
|
const std::string& id)
|
||||||
@@ -863,3 +859,23 @@ void BiboumiComponent::send_invitation(const std::string& room_target,
|
|||||||
message.add_child(std::move(x));
|
message.add_child(std::move(x));
|
||||||
this->send_stanza(message);
|
this->send_stanza(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BiboumiComponent::accept_subscription(const std::string& from, const std::string& to)
|
||||||
|
{
|
||||||
|
Stanza presence("presence");
|
||||||
|
presence["from"] = from;
|
||||||
|
presence["to"] = to;
|
||||||
|
presence["id"] = this->next_id();
|
||||||
|
presence["type"] = "subscribed";
|
||||||
|
this->send_stanza(presence);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BiboumiComponent::ask_subscription(const std::string& from, const std::string& to)
|
||||||
|
{
|
||||||
|
Stanza presence("presence");
|
||||||
|
presence["from"] = from;
|
||||||
|
presence["to"] = to;
|
||||||
|
presence["id"] = this->next_id();
|
||||||
|
presence["type"] = "subscribe";
|
||||||
|
this->send_stanza(presence);
|
||||||
|
}
|
||||||
|
|||||||
@@ -70,11 +70,6 @@ public:
|
|||||||
* http://xmpp.org/extensions/xep-0045.html#impl-service-traffic
|
* http://xmpp.org/extensions/xep-0045.html#impl-service-traffic
|
||||||
*/
|
*/
|
||||||
void send_irc_channel_muc_traffic_info(const std::string id, const std::string& jid_from, const std::string& jid_to);
|
void send_irc_channel_muc_traffic_info(const std::string id, const std::string& jid_from, const std::string& jid_to);
|
||||||
/**
|
|
||||||
* Send an iq version request
|
|
||||||
*/
|
|
||||||
void send_iq_version_request(const std::string& from,
|
|
||||||
const std::string& jid_to);
|
|
||||||
/**
|
/**
|
||||||
* Send a ping request
|
* Send a ping request
|
||||||
*/
|
*/
|
||||||
@@ -88,6 +83,8 @@ public:
|
|||||||
const ChannelList& channel_list, std::vector<ListElement>::const_iterator begin,
|
const ChannelList& channel_list, std::vector<ListElement>::const_iterator begin,
|
||||||
std::vector<ListElement>::const_iterator end, const ResultSetInfo& rs_info);
|
std::vector<ListElement>::const_iterator end, const ResultSetInfo& rs_info);
|
||||||
void send_invitation(const std::string& room_target, const std::string& jid_to, const std::string& author_nick);
|
void send_invitation(const std::string& room_target, const std::string& jid_to, const std::string& author_nick);
|
||||||
|
void accept_subscription(const std::string& from, const std::string& to);
|
||||||
|
void ask_subscription(const std::string& from, const std::string& to);
|
||||||
/**
|
/**
|
||||||
* Handle the various stanza types
|
* Handle the various stanza types
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1840,6 +1840,19 @@ if __name__ == '__main__':
|
|||||||
"/presence/muc:x",
|
"/presence/muc:x",
|
||||||
"/presence/error/stanza:text")),
|
"/presence/error/stanza:text")),
|
||||||
], conf='fixed_server'),
|
], conf='fixed_server'),
|
||||||
|
Scenario("irc_server_presence_subscription",
|
||||||
|
[
|
||||||
|
handshake_sequence(),
|
||||||
|
partial(send_stanza, "<presence type='subscribe' from='{jid_one}/{resource_one}' to='{irc_server_one}' id='sub1' />"),
|
||||||
|
partial(expect_stanza, "/presence[@to='{jid_one}'][@from='{irc_server_one}'][@type='subscribed']")
|
||||||
|
]),
|
||||||
|
Scenario("fixed_irc_server_presence_subscription",
|
||||||
|
[
|
||||||
|
handshake_sequence(),
|
||||||
|
partial(send_stanza, "<presence type='subscribe' from='{jid_one}/{resource_one}' to='{biboumi_host}' id='sub1' />"),
|
||||||
|
partial(expect_stanza, "/presence[@to='{jid_one}'][@from='{biboumi_host}'][@type='subscribed']")
|
||||||
|
], conf='fixed_server')
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user