check disco feature on entity
This commit is contained in:
parent
873644f528
commit
26bff8028a
|
@ -126,6 +126,12 @@ public abstract class DiscoDao {
|
|||
@Query("SELECT id FROM disco WHERE accountId=:accountId AND capsHash=: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)")
|
||||
public abstract boolean hasFeature(final long account, final Jid entity, final String feature);
|
||||
|
||||
public static class DiscoItemWithParent {
|
||||
public long accountId;
|
||||
public Jid address;
|
||||
|
|
|
@ -1986,7 +1986,7 @@ public class XmppConnection implements Runnable {
|
|||
|
||||
private void enableAdvancedStreamFeatures() {
|
||||
if (getManager(DiscoManager.class)
|
||||
.isFeature(connectionAddress.getDomain(), Namespace.CARBONS)
|
||||
.hasFeature(connectionAddress.getDomain(), Namespace.CARBONS)
|
||||
&& !this.carbonsEnabled) {
|
||||
sendEnableCarbons();
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ public class DiscoManager extends AbstractManager {
|
|||
MoreExecutors.directExecutor());
|
||||
}
|
||||
|
||||
public boolean isFeature(final Jid entity, final String feature) {
|
||||
return true;
|
||||
public boolean hasFeature(final Jid entity, final String feature) {
|
||||
return getDatabase().discoDao().hasFeature(getAccount().id, entity, feature);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package im.conversations.android.xmpp.processor;
|
||||
|
||||
import android.content.Context;
|
||||
import eu.siacs.conversations.xml.Namespace;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
import im.conversations.android.xmpp.XmppConnection;
|
||||
import im.conversations.android.xmpp.manager.BlockingManager;
|
||||
import im.conversations.android.xmpp.manager.BookmarkManager;
|
||||
import im.conversations.android.xmpp.manager.DiscoManager;
|
||||
import im.conversations.android.xmpp.manager.RosterManager;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -31,8 +33,10 @@ public class BindProcessor extends XmppConnection.Delegate implements Consumer<J
|
|||
|
||||
getManager(RosterManager.class).fetch();
|
||||
|
||||
// TODO check feature before fetching
|
||||
if (getManager(DiscoManager.class)
|
||||
.hasFeature(account.address.getDomain(), Namespace.BLOCKING)) {
|
||||
getManager(BlockingManager.class).fetch();
|
||||
}
|
||||
|
||||
getManager(BookmarkManager.class).fetch();
|
||||
|
||||
|
|
Loading…
Reference in a new issue