- cprintf("<presence type=\"unavailable\" from=\"%s\" to=\"%s\"></presence>",
- xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1),
- xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2)
- );
- cprintf("<presence type=\"unsubscribed\" from=\"%s\" to=\"%s\"></presence>",
- xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1),
- xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2)
- );
+ XPUT("<presence type=\"unavailable\" from=\"");
+ XPutProp(presence_jid, strlen(presence_jid));
+ XPUT("\" to=\"");
+ XPutProp(XMPP->client_jid, strlen(XMPP->client_jid));
+ XPUT("\"></presence>");
+
+ /*
+ * Setting the "aggressively" flag also sends an "unsubscribed" presence update.
+ * We only ask for this when flushing the client side roster, because if we do it
+ * in the middle of a session when another user logs off, some clients (Jitsi) interpret
+ * it as a rejection of a subscription request.
+ */
+ if (aggressively) {
+ XPUT("<presence type=\"unsubscribed\" from=\"");
+ XPutProp(presence_jid, strlen(presence_jid));
+ XPUT("\" to=\"");
+ XPutProp(XMPP->client_jid, strlen(XMPP->client_jid));
+ XPUT("\"></presence>");
+ }
+