mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 18:29:45 +02:00
Merge branch '4.4'
This commit is contained in:
commit
ed807d5954
5 changed files with 91 additions and 6 deletions
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.filter.StanzaFilter;
|
|||
import org.jivesoftware.smack.filter.ToTypeFilter;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChatManager;
|
||||
import org.jivesoftware.smackx.sid.element.OriginIdElement;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +49,7 @@ public final class StableUniqueStanzaIdManager extends Manager {
|
|||
|
||||
private static final Map<XMPPConnection, StableUniqueStanzaIdManager> INSTANCES = new WeakHashMap<>();
|
||||
|
||||
private static boolean enabledByDefault = true;
|
||||
private static boolean enabledByDefault = false;
|
||||
|
||||
// Filter for outgoing stanzas.
|
||||
private static final StanzaFilter OUTGOING_FILTER = new AndFilter(
|
||||
|
@ -68,6 +69,14 @@ public final class StableUniqueStanzaIdManager extends Manager {
|
|||
if (enabledByDefault) {
|
||||
getInstanceFor(connection).enable();
|
||||
}
|
||||
|
||||
MultiUserChatManager.addDefaultMessageInterceptor((mb, muc) -> {
|
||||
// No need to add an <origin-id/> if the MUC service supports stable IDs.
|
||||
if (muc.serviceSupportsStableIds()) {
|
||||
return;
|
||||
}
|
||||
OriginIdElement.addTo(mb);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2018 Paul Schaub
|
||||
* Copyright 2018 Paul Schaub, 2021 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -48,7 +48,12 @@ public class OriginIdElement extends StableAndUniqueIdElement {
|
|||
@Deprecated
|
||||
// TODO: Remove in Smack 4.5.
|
||||
public static OriginIdElement addOriginId(Message message) {
|
||||
OriginIdElement originId = new OriginIdElement();
|
||||
OriginIdElement originId = message.getExtension(OriginIdElement.class);
|
||||
if (originId != null) {
|
||||
return originId;
|
||||
}
|
||||
|
||||
originId = new OriginIdElement();
|
||||
message.addExtension(originId);
|
||||
// TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID.
|
||||
// message.setStanzaId(originId.getId());
|
||||
|
@ -62,7 +67,12 @@ public class OriginIdElement extends StableAndUniqueIdElement {
|
|||
* @return the added origin-id element.
|
||||
*/
|
||||
public static OriginIdElement addTo(MessageBuilder messageBuilder) {
|
||||
OriginIdElement originId = new OriginIdElement();
|
||||
OriginIdElement originId = messageBuilder.getExtension(OriginIdElement.class);
|
||||
if (originId != null) {
|
||||
return originId;
|
||||
}
|
||||
|
||||
originId = new OriginIdElement();
|
||||
messageBuilder.addExtension(originId);
|
||||
// TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID.
|
||||
// message.setStanzaId(originId.getId());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue