@SpecCompliance(compliant = {
@SpecCompliant(spec = "RFC3921bis-05", section = "3.3.3", status = IN_PROGRESS, comment = "current impl based hereupon"),
@SpecCompliant(spec = "RFC3921bis-08", section = "3.3.3", status = NOT_STARTED, comment = "substantial additions from bis-05 not yet taken into account") })
protected void handleInboundUnsubscription(PresenceStanza stanza, ServerRuntimeContext serverRuntimeContext,
SessionContext sessionContext, ResourceRegistry registry, RosterManager rosterManager) {
Entity contact = stanza.getFrom();
Entity user = stanza.getTo();
Entity userBareJid = user.getBareJID();
Entity contactBareJid = contact.getBareJID();
RosterItem rosterItem;
try {
rosterItem = rosterManager.getContact(userBareJid, contactBareJid);
} catch (RosterException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
if (rosterItem == null)
return;
RosterSubscriptionMutator.Result result = RosterSubscriptionMutator.getInstance().remove(rosterItem, FROM);
if (result != OK) {
// TODO
return;
}
// send roster push to all interested resources
// TODO do this only once, since inbound is multiplexed on DeliveringInboundStanzaRelay level already
List<String> resources = registry.getInterestedResources(user);
for (String resource : resources) {
Entity userResource = new EntityImpl(user, resource);
Stanza push = RosterStanzaUtils.createRosterItemPushIQ(userResource, sessionContext.nextSequenceValue(),
rosterItem);
LocalDeliveryUtils.relayToResourceDirectly(registry, resource, push);
}