aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java2
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java17
2 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index b4fba14b2..ba583b304 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -322,7 +322,7 @@ public class XmppConnectionService extends Service {
}
final boolean flexible = account.getXmppConnection().getFeatures().flexibleOfflineMessageRetrieval();
final boolean catchup = getMessageArchiveService().inCatchup(account);
- if (flexible && catchup) {
+ if (flexible && catchup && account.getXmppConnection().isMamPreferenceAlways()) {
sendIqPacket(account, mIqGenerator.purgeOfflineMessages(), (acc, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG, acc.getJid().asBareJid() + ": successfully purged offline messages");
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index a40670c55..c92653444 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -162,6 +162,7 @@ public class XmppConnection implements Runnable {
private long lastConnect = 0;
private long lastSessionStarted = 0;
private long lastDiscoStarted = 0;
+ private boolean isMamPreferenceAlways = false;
private AtomicInteger mPendingServiceDiscoveries = new AtomicInteger(0);
private AtomicBoolean mWaitForDisco = new AtomicBoolean(true);
private AtomicBoolean mWaitingForSmCatchup = new AtomicBoolean(false);
@@ -1195,6 +1196,7 @@ public class XmppConnection implements Runnable {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server caps came from cache");
disco.put(Jid.of(account.getServer()), discoveryResult);
}
+ discoverMamPreferences();
sendServiceDiscoveryInfo(account.getJid().asBareJid());
if (!requestDiscoItemsFirst) {
sendServiceDiscoveryItems(Jid.of(account.getServer()));
@@ -1238,6 +1240,21 @@ public class XmppConnection implements Runnable {
});
}
+ private void discoverMamPreferences() {
+ IqPacket request = new IqPacket(IqPacket.TYPE.GET);
+ request.addChild("prefs", MessageArchiveService.Version.MAM_2.namespace);
+ sendIqPacket(request, (account, response) -> {
+ if (response.getType() == IqPacket.TYPE.RESULT) {
+ Element prefs = response.findChild("prefs", MessageArchiveService.Version.MAM_2.namespace);
+ isMamPreferenceAlways = "always".equals(prefs == null ? null : prefs.getAttribute("default"));
+ }
+ });
+ }
+
+ public boolean isMamPreferenceAlways() {
+ return isMamPreferenceAlways;
+ }
+
private void finalizeBind() {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": online with resource " + account.getResource());
if (bindListener != null) {