1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

Use asEntityBareJidOrThrow() in ChatMarkersManager listener

This commit is contained in:
Florian Schmaus 2018-09-06 18:49:12 +02:00
parent b12f5a1591
commit 0b9cce507d

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Fernando Ramirez * Copyright © 2016 Fernando Ramirez, 2018 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,7 +48,6 @@ import org.jivesoftware.smackx.chat_markers.filter.EligibleForChatMarker;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jxmpp.jid.EntityBareJid; import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.EntityFullJid;
/** /**
* Chat Markers Manager class (XEP-0333). * Chat Markers Manager class (XEP-0333).
@ -138,8 +137,10 @@ public final class ChatMarkersManager extends Manager {
SmackException.NotLoggedInException { SmackException.NotLoggedInException {
final Message message = (Message) packet; final Message message = (Message) packet;
EntityFullJid fullFrom = message.getFrom().asEntityFullJidIfPossible(); // Note that this listener is used together with a PossibleFromTypeFilter.ENTITY_BARE_JID filter, hence
EntityBareJid bareFrom = fullFrom.asEntityBareJid(); // every message is guaranteed to have a from address which is representable as bare JID.
EntityBareJid bareFrom = message.getFrom().asEntityBareJidOrThrow();
final Chat chat = chatManager.chatWith(bareFrom); final Chat chat = chatManager.chatWith(bareFrom);
asyncButOrdered.performAsyncButOrdered(chat, new Runnable() { asyncButOrdered.performAsyncButOrdered(chat, new Runnable() {