summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-07-14 15:15:53 +0200
committerlouiz’ <louiz@louiz.org>2017-07-16 00:16:43 +0200
commit729ea131c9857ecb2e9579359e174483c73194d0 (patch)
treebacf7549ae68185ab3b49e2a1d9b0f7269eba307 /src/xmpp
parent50a2bd736ef76f7ebb7067372d5f89b59a337bec (diff)
downloadbiboumi-729ea131c9857ecb2e9579359e174483c73194d0.tar.gz
biboumi-729ea131c9857ecb2e9579359e174483c73194d0.tar.bz2
biboumi-729ea131c9857ecb2e9579359e174483c73194d0.tar.xz
biboumi-729ea131c9857ecb2e9579359e174483c73194d0.zip
Send an unsubscribed presence on a probe if we don’t have a roster entry
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/biboumi_component.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index ab66519..d1c75d0 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -190,9 +190,18 @@ void BiboumiComponent::handle_presence(const Stanza& stanza)
}
else if (type == "probe")
{
- if ((iid.type == Iid::Type::Server && bridge->find_irc_client(iid.get_server())) ||
- iid.type == Iid::Type::None)
- this->send_presence_to_contact(to_str, from.bare(), "");
+ if ((iid.type == Iid::Type::Server && bridge->find_irc_client(iid.get_server()))
+ || iid.type == Iid::Type::None)
+ {
+#ifdef USE_DATABASE
+ if (Database::has_roster_item(to_str, from.bare()))
+#endif
+ this->send_presence_to_contact(to_str, from.bare(), "");
+#ifdef USE_DATABASE
+ else // rfc 6121 4.3.2.1
+ this->send_presence_to_contact(to_str, from.bare(), "unsubscribed");
+#endif
+ }
}
else if (type.empty())
{ // We just receive a presence from someone (as the result of a probe,
@@ -1057,6 +1066,12 @@ void BiboumiComponent::after_handshake()
for (const Database::RosterItem& roster_item: contacts)
{
const auto remote_jid = roster_item.col<Database::RemoteJid>();
+ // In response, we will receive a presence indicating the
+ // contact is online, to which we will respond with our own
+ // presence.
+ // If the contact removed us from their roster while we were
+ // offline, we will receive an unsubscribed presence, letting us
+ // stay in sync.
this->send_presence_to_contact(this->get_served_hostname(), remote_jid, "probe");
}
#endif