Commit 00705447 authored by akwizgran's avatar akwizgran

Use feature flag to decide which version to advertise.

parent 9095ccef
Pipeline #3592 passed with stage
in 9 minutes and 1 second
package org.briarproject.bramble.test;
import org.briarproject.bramble.api.FeatureFlags;
import org.briarproject.bramble.battery.DefaultBatteryManagerModule;
import org.briarproject.bramble.event.DefaultEventExecutorModule;
import dagger.Module;
import dagger.Provides;
@Module(includes = {
DefaultBatteryManagerModule.class,
......@@ -13,4 +15,20 @@ import dagger.Module;
TestSecureRandomModule.class
})
public class BrambleCoreIntegrationTestModule {
@Provides
FeatureFlags provideFeatureFlags() {
return new FeatureFlags() {
@Override
public boolean shouldEnableImageAttachments() {
return true;
}
@Override
public boolean shouldEnableRemoteContacts() {
return true;
}
};
}
}
package org.briarproject.briar.messaging;
import org.briarproject.bramble.api.FeatureFlags;
import org.briarproject.bramble.api.contact.ContactManager;
import org.briarproject.bramble.api.data.BdfReaderFactory;
import org.briarproject.bramble.api.data.MetadataEncoder;
......@@ -19,7 +20,6 @@ import dagger.Provides;
import static org.briarproject.briar.api.messaging.MessagingManager.CLIENT_ID;
import static org.briarproject.briar.api.messaging.MessagingManager.MAJOR_VERSION;
import static org.briarproject.briar.api.messaging.MessagingManager.MINOR_VERSION;
@Module
public class MessagingModule {
......@@ -57,14 +57,17 @@ public class MessagingModule {
ContactManager contactManager, ValidationManager validationManager,
ConversationManager conversationManager,
ClientVersioningManager clientVersioningManager,
MessagingManagerImpl messagingManager) {
FeatureFlags featureFlags, MessagingManagerImpl messagingManager) {
lifecycleManager.registerOpenDatabaseHook(messagingManager);
contactManager.registerContactHook(messagingManager);
validationManager.registerIncomingMessageHook(CLIENT_ID, MAJOR_VERSION,
messagingManager);
conversationManager.registerConversationClient(messagingManager);
// Advertise the current or previous minor version depending on the
// feature flag
int minorVersion = featureFlags.shouldEnableImageAttachments() ? 1 : 0;
clientVersioningManager.registerClient(CLIENT_ID, MAJOR_VERSION,
MINOR_VERSION, messagingManager);
minorVersion, messagingManager);
return messagingManager;
}
......
......@@ -3,6 +3,7 @@ package org.briarproject.briar.headless
import com.fasterxml.jackson.databind.ObjectMapper
import dagger.Module
import dagger.Provides
import org.briarproject.bramble.api.FeatureFlags
import org.briarproject.bramble.api.battery.BatteryManager
import org.briarproject.bramble.api.db.DatabaseConfig
import org.briarproject.bramble.api.event.EventBus
......@@ -94,4 +95,9 @@ internal class HeadlessModule(private val appDir: File) {
@Singleton
internal fun provideObjectMapper() = ObjectMapper()
@Provides
internal fun provideFeatureFlags() = object : FeatureFlags {
override fun shouldEnableImageAttachments() = false
override fun shouldEnableRemoteContacts() = true
}
}
......@@ -3,6 +3,7 @@ package org.briarproject.briar.headless
import com.fasterxml.jackson.databind.ObjectMapper
import dagger.Module
import dagger.Provides
import org.briarproject.bramble.api.FeatureFlags
import org.briarproject.bramble.api.db.DatabaseConfig
import org.briarproject.bramble.api.plugin.PluginConfig
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginFactory
......@@ -61,4 +62,9 @@ internal class HeadlessTestModule(private val appDir: File) {
@Singleton
internal fun provideObjectMapper() = ObjectMapper()
@Provides
internal fun provideFeatureFlags() = object : FeatureFlags {
override fun shouldEnableImageAttachments() = false
override fun shouldEnableRemoteContacts() = true
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment