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; package org.briarproject.bramble.test;
import org.briarproject.bramble.api.FeatureFlags;
import org.briarproject.bramble.battery.DefaultBatteryManagerModule; import org.briarproject.bramble.battery.DefaultBatteryManagerModule;
import org.briarproject.bramble.event.DefaultEventExecutorModule; import org.briarproject.bramble.event.DefaultEventExecutorModule;
import dagger.Module; import dagger.Module;
import dagger.Provides;
@Module(includes = { @Module(includes = {
DefaultBatteryManagerModule.class, DefaultBatteryManagerModule.class,
...@@ -13,4 +15,20 @@ import dagger.Module; ...@@ -13,4 +15,20 @@ import dagger.Module;
TestSecureRandomModule.class TestSecureRandomModule.class
}) })
public class BrambleCoreIntegrationTestModule { 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; package org.briarproject.briar.messaging;
import org.briarproject.bramble.api.FeatureFlags;
import org.briarproject.bramble.api.contact.ContactManager; import org.briarproject.bramble.api.contact.ContactManager;
import org.briarproject.bramble.api.data.BdfReaderFactory; import org.briarproject.bramble.api.data.BdfReaderFactory;
import org.briarproject.bramble.api.data.MetadataEncoder; import org.briarproject.bramble.api.data.MetadataEncoder;
...@@ -19,7 +20,6 @@ import dagger.Provides; ...@@ -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.CLIENT_ID;
import static org.briarproject.briar.api.messaging.MessagingManager.MAJOR_VERSION; import static org.briarproject.briar.api.messaging.MessagingManager.MAJOR_VERSION;
import static org.briarproject.briar.api.messaging.MessagingManager.MINOR_VERSION;
@Module @Module
public class MessagingModule { public class MessagingModule {
...@@ -57,14 +57,17 @@ public class MessagingModule { ...@@ -57,14 +57,17 @@ public class MessagingModule {
ContactManager contactManager, ValidationManager validationManager, ContactManager contactManager, ValidationManager validationManager,
ConversationManager conversationManager, ConversationManager conversationManager,
ClientVersioningManager clientVersioningManager, ClientVersioningManager clientVersioningManager,
MessagingManagerImpl messagingManager) { FeatureFlags featureFlags, MessagingManagerImpl messagingManager) {
lifecycleManager.registerOpenDatabaseHook(messagingManager); lifecycleManager.registerOpenDatabaseHook(messagingManager);
contactManager.registerContactHook(messagingManager); contactManager.registerContactHook(messagingManager);
validationManager.registerIncomingMessageHook(CLIENT_ID, MAJOR_VERSION, validationManager.registerIncomingMessageHook(CLIENT_ID, MAJOR_VERSION,
messagingManager); messagingManager);
conversationManager.registerConversationClient(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, clientVersioningManager.registerClient(CLIENT_ID, MAJOR_VERSION,
MINOR_VERSION, messagingManager); minorVersion, messagingManager);
return messagingManager; return messagingManager;
} }
......
...@@ -3,6 +3,7 @@ package org.briarproject.briar.headless ...@@ -3,6 +3,7 @@ package org.briarproject.briar.headless
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import org.briarproject.bramble.api.FeatureFlags
import org.briarproject.bramble.api.battery.BatteryManager import org.briarproject.bramble.api.battery.BatteryManager
import org.briarproject.bramble.api.db.DatabaseConfig import org.briarproject.bramble.api.db.DatabaseConfig
import org.briarproject.bramble.api.event.EventBus import org.briarproject.bramble.api.event.EventBus
...@@ -94,4 +95,9 @@ internal class HeadlessModule(private val appDir: File) { ...@@ -94,4 +95,9 @@ internal class HeadlessModule(private val appDir: File) {
@Singleton @Singleton
internal fun provideObjectMapper() = ObjectMapper() 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 ...@@ -3,6 +3,7 @@ package org.briarproject.briar.headless
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import dagger.Module import dagger.Module
import dagger.Provides import dagger.Provides
import org.briarproject.bramble.api.FeatureFlags
import org.briarproject.bramble.api.db.DatabaseConfig import org.briarproject.bramble.api.db.DatabaseConfig
import org.briarproject.bramble.api.plugin.PluginConfig import org.briarproject.bramble.api.plugin.PluginConfig
import org.briarproject.bramble.api.plugin.duplex.DuplexPluginFactory import org.briarproject.bramble.api.plugin.duplex.DuplexPluginFactory
...@@ -61,4 +62,9 @@ internal class HeadlessTestModule(private val appDir: File) { ...@@ -61,4 +62,9 @@ internal class HeadlessTestModule(private val appDir: File) {
@Singleton @Singleton
internal fun provideObjectMapper() = ObjectMapper() 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