if (hasTo) return handleOutboundDirectedPresence(presenceStanza, serverRuntimeContext, sessionContext,
rosterManager, user, registry, false);
if (!user.isResourceSet()) throw new RuntimeException("resource id not available");
String resourceId = user.getResource();
ResourceState resourceState = registry.getResourceState(resourceId);
boolean isPresenceUpdate = resourceState != null && ResourceState.isAvailable(resourceState);
// TODO in case of !isPresenceUpdate, should we check for resourceState != ResourceState.AVAILABLE_INTERESTED ?
// RFC3921bis-04#4.2.2 Initial Presence
// RFC3921bis-04#4.4.2 Initial Presence
updateLatestPresence(sessionContext, user, presenceStanza);
if (!isPresenceUpdate) {
// things to be done for initial presence
// set resource state
ResourceState currentState = registry.getResourceState(resourceId);
// set to AVAILABLE, but do not override AVAILABLE_INTERESTED
registry.setResourceState(resourceId, ResourceState.makeAvailable(currentState));
}
// the presence priority is optional, but if contained, it might become relevant for