mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
[sid] Add <origin-id/> to MUC messages if not muc#stable_id
This commit is contained in:
parent
4381d04831
commit
64a2db3f19
1 changed files with 9 additions and 0 deletions
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.filter.StanzaFilter;
|
||||||
import org.jivesoftware.smack.filter.ToTypeFilter;
|
import org.jivesoftware.smack.filter.ToTypeFilter;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
|
import org.jivesoftware.smackx.muc.MultiUserChatManager;
|
||||||
import org.jivesoftware.smackx.sid.element.OriginIdElement;
|
import org.jivesoftware.smackx.sid.element.OriginIdElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,6 +69,14 @@ public final class StableUniqueStanzaIdManager extends Manager {
|
||||||
if (enabledByDefault) {
|
if (enabledByDefault) {
|
||||||
getInstanceFor(connection).enable();
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue