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

Filter MUC 'decline' messages by type 'normal'

and not by '!error' as this there are presence stanzas containing the
muc#user namespace also send to the client, which results in a
ClassCastException in the StanzaListener.
This commit is contained in:
Florian Schmaus 2016-11-10 14:57:01 +01:00
parent a9d5cd4a61
commit 54790cd380

View file

@ -135,6 +135,9 @@ public class MultiUserChat {
private final StanzaListener messageListener; private final StanzaListener messageListener;
private final StanzaListener presenceListener; private final StanzaListener presenceListener;
private final StanzaListener subjectListener; private final StanzaListener subjectListener;
private static final StanzaFilter DECLINE_FILTER = new AndFilter(MessageTypeFilter.NORMAL,
new StanzaExtensionFilter(MUCUser.ELEMENT, MUCUser.NAMESPACE));
private final StanzaListener declinesListener; private final StanzaListener declinesListener;
private String subject; private String subject;
@ -317,8 +320,7 @@ public class MultiUserChat {
StanzaTypeFilter.PRESENCE)); StanzaTypeFilter.PRESENCE));
connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter, connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter,
MessageWithSubjectFilter.INSTANCE, new NotFilter(MessageTypeFilter.ERROR))); MessageWithSubjectFilter.INSTANCE, new NotFilter(MessageTypeFilter.ERROR)));
connection.addSyncStanzaListener(declinesListener, new AndFilter(new StanzaExtensionFilter(MUCUser.ELEMENT, connection.addSyncStanzaListener(declinesListener, DECLINE_FILTER);
MUCUser.NAMESPACE), new NotFilter(MessageTypeFilter.ERROR)));
connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room), connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room),
StanzaTypeFilter.PRESENCE)); StanzaTypeFilter.PRESENCE));
messageCollector = connection.createPacketCollector(fromRoomGroupchatFilter); messageCollector = connection.createPacketCollector(fromRoomGroupchatFilter);