diff --git a/app/src/main/java/im/conversations/android/xmpp/processor/PresenceProcessor.java b/app/src/main/java/im/conversations/android/xmpp/processor/PresenceProcessor.java index 31f4c710e..2cd7d5f25 100644 --- a/app/src/main/java/im/conversations/android/xmpp/processor/PresenceProcessor.java +++ b/app/src/main/java/im/conversations/android/xmpp/processor/PresenceProcessor.java @@ -1,6 +1,10 @@ package im.conversations.android.xmpp.processor; import android.content.Context; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import im.conversations.android.database.model.PresenceShow; import im.conversations.android.database.model.PresenceType; import im.conversations.android.xmpp.Entity; @@ -11,6 +15,8 @@ import java.util.function.Consumer; public class PresenceProcessor extends XmppConnection.Delegate implements Consumer { + private static final Logger LOGGER = LoggerFactory.getLogger(PresenceProcessor.class); + public PresenceProcessor(final Context context, final XmppConnection connection) { super(context, connection); } @@ -19,20 +25,24 @@ public class PresenceProcessor extends XmppConnection.Delegate implements Consum public void accept(final Presence presencePacket) { final var from = presencePacket.getFrom(); final var address = from == null ? null : from.asBareJid(); - final var resource = from == null ? null : from.getResourceOrEmpty(); + if (address == null) { + LOGGER.warn("Received presence from account (from=null). This is unusual."); + return; + } + final var resource = from.getResourceOrEmpty(); final var typeAttribute = presencePacket.getAttribute("type"); final PresenceType type; try { type = PresenceType.of(typeAttribute); } catch (final IllegalArgumentException e) { - // log we don’t parse presence of type $type + LOGGER.warn("Received presence of type '{}' from {}", typeAttribute, from); return; } final var show = PresenceShow.of(presencePacket.findChildContent("show")); final var status = presencePacket.findChildContent("status"); getDatabase().presenceDao().set(getAccount(), address, resource, type, show, status); - // TODO store presence info + // TODO store presence info (vCard + muc#user stuff + occupantId) // TODO do this only for contacts? fetchCapabilities(presencePacket);