add TODO on how to use RangeAfter
This commit is contained in:
parent
97f54b6673
commit
d9e8918727
|
@ -10,6 +10,7 @@ import com.google.common.collect.ImmutableList;
|
||||||
import im.conversations.android.database.entity.ArchivePageEntity;
|
import im.conversations.android.database.entity.ArchivePageEntity;
|
||||||
import im.conversations.android.database.model.Account;
|
import im.conversations.android.database.model.Account;
|
||||||
import im.conversations.android.database.model.StanzaId;
|
import im.conversations.android.database.model.StanzaId;
|
||||||
|
import im.conversations.android.xml.Namespace;
|
||||||
import im.conversations.android.xmpp.Range;
|
import im.conversations.android.xmpp.Range;
|
||||||
import im.conversations.android.xmpp.manager.ArchiveManager;
|
import im.conversations.android.xmpp.manager.ArchiveManager;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,12 +20,19 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
public abstract class ArchiveDao {
|
public abstract class ArchiveDao extends BaseDao {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArchiveDao.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ArchiveDao.class);
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
public List<Range> resetLivePage(final Account account, final Jid archive) {
|
public List<Range> resetLivePage(final Account account, final Jid archive) {
|
||||||
|
// if the server support extended MAM or catch-up query from (live)page.end to now can use
|
||||||
|
// after-id reverse towards that (this means newer messages will be fetched earlier); if and
|
||||||
|
// when we support this we also need a new page type called END that will eventually be
|
||||||
|
// deleted once we need page.end
|
||||||
|
final boolean emitRangeAfter =
|
||||||
|
hasDiscoItemFeature(
|
||||||
|
account.id, archive, Namespace.MESSAGE_ARCHIVE_MANAGEMENT_EXTENDED);
|
||||||
final var page =
|
final var page =
|
||||||
getPage(
|
getPage(
|
||||||
account.id,
|
account.id,
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package im.conversations.android.database.dao;
|
||||||
|
|
||||||
|
import androidx.room.Query;
|
||||||
|
import org.jxmpp.jid.Jid;
|
||||||
|
|
||||||
|
public abstract class BaseDao {
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"SELECT EXISTS (SELECT disco_item.id FROM disco_item JOIN disco_feature on"
|
||||||
|
+ " disco_item.discoId=disco_feature.discoId WHERE accountId=:account AND"
|
||||||
|
+ " address=:entity AND feature=:feature)")
|
||||||
|
protected abstract boolean hasDiscoItemFeature(
|
||||||
|
final long account, final Jid entity, final String feature);
|
||||||
|
}
|
|
@ -33,7 +33,7 @@ import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.parts.Resourcepart;
|
import org.jxmpp.jid.parts.Resourcepart;
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
public abstract class DiscoDao {
|
public abstract class DiscoDao extends BaseDao {
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
protected abstract void insertDiscoItems(Collection<DiscoItemEntity> items);
|
protected abstract void insertDiscoItems(Collection<DiscoItemEntity> items);
|
||||||
|
@ -190,13 +190,6 @@ public abstract class DiscoDao {
|
||||||
@Query("SELECT id FROM disco WHERE accountId=:accountId AND capsHash=:capsHash")
|
@Query("SELECT id FROM disco WHERE accountId=:accountId AND capsHash=:capsHash")
|
||||||
protected abstract Long getDiscoIdByCapsHash(final long accountId, final byte[] capsHash);
|
protected abstract Long getDiscoIdByCapsHash(final long accountId, final byte[] capsHash);
|
||||||
|
|
||||||
@Query(
|
|
||||||
"SELECT EXISTS (SELECT disco_item.id FROM disco_item JOIN disco_feature on"
|
|
||||||
+ " disco_item.discoId=disco_feature.discoId WHERE accountId=:account AND"
|
|
||||||
+ " address=:entity AND feature=:feature)")
|
|
||||||
protected abstract boolean hasDiscoItemFeature(
|
|
||||||
final long account, final Jid entity, final String feature);
|
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"SELECT EXISTS (SELECT presence.id FROM presence JOIN disco_feature on"
|
"SELECT EXISTS (SELECT presence.id FROM presence JOIN disco_feature on"
|
||||||
+ " presence.discoId=disco_feature.discoId WHERE accountId=:account AND"
|
+ " presence.discoId=disco_feature.discoId WHERE accountId=:account AND"
|
||||||
|
|
|
@ -68,6 +68,8 @@ public final class Namespace {
|
||||||
public static final String JINGLE_TRANSPORT_ICE_UDP = "urn:xmpp:jingle:transports:ice-udp:1";
|
public static final String JINGLE_TRANSPORT_ICE_UDP = "urn:xmpp:jingle:transports:ice-udp:1";
|
||||||
public static final String LAST_MESSAGE_CORRECTION = "urn:xmpp:message-correct:0";
|
public static final String LAST_MESSAGE_CORRECTION = "urn:xmpp:message-correct:0";
|
||||||
public static final String MESSAGE_ARCHIVE_MANAGEMENT = "urn:xmpp:mam:2";
|
public static final String MESSAGE_ARCHIVE_MANAGEMENT = "urn:xmpp:mam:2";
|
||||||
|
public static final String MESSAGE_ARCHIVE_MANAGEMENT_EXTENDED =
|
||||||
|
MESSAGE_ARCHIVE_MANAGEMENT + "#extended";
|
||||||
public static final String MUC = "http://jabber.org/protocol/muc";
|
public static final String MUC = "http://jabber.org/protocol/muc";
|
||||||
public static final String MUC_USER = MUC + "#user";
|
public static final String MUC_USER = MUC + "#user";
|
||||||
public static final String NICK = "http://jabber.org/protocol/nick";
|
public static final String NICK = "http://jabber.org/protocol/nick";
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package im.conversations.android.xmpp;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
|
||||||
|
public class RangeAfter extends Range {
|
||||||
|
|
||||||
|
public final String afterId;
|
||||||
|
|
||||||
|
public RangeAfter(final String afterId, final String id) {
|
||||||
|
super(Order.REVERSE, id);
|
||||||
|
this.afterId = afterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return MoreObjects.toStringHelper(this)
|
||||||
|
.add("afterId", afterId)
|
||||||
|
.add("order", order)
|
||||||
|
.add("id", id)
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue