Add feature flag for introductions

This commit is contained in:
Sebastian Kürten
2022-01-06 14:37:21 +01:00
parent 707802c459
commit e8e07414e7
5 changed files with 24 additions and 4 deletions

View File

@@ -11,6 +11,8 @@ public interface FeatureFlags {
boolean shouldEnableDisappearingMessages();
boolean shouldEnableIntroductionsInCore();
boolean shouldEnablePrivateGroupsInCore();
boolean shouldEnableForumsInCore();

View File

@@ -25,6 +25,11 @@ public class TestFeatureFlagModule {
return true;
}
@Override
public boolean shouldEnableIntroductionsInCore() {
return true;
}
@Override
public boolean shouldEnablePrivateGroupsInCore() {
return true;

View File

@@ -340,6 +340,11 @@ public class AppModule {
return true;
}
@Override
public boolean shouldEnableIntroductionsInCore() {
return true;
}
@Override
public boolean shouldEnablePrivateGroupsInCore() {
return true;

View File

@@ -1,5 +1,6 @@
package org.briarproject.briar.introduction;
import org.briarproject.bramble.api.FeatureFlags;
import org.briarproject.bramble.api.cleanup.CleanupManager;
import org.briarproject.bramble.api.client.ClientHelper;
import org.briarproject.bramble.api.contact.ContactManager;
@@ -35,12 +36,14 @@ public class IntroductionModule {
@Singleton
IntroductionValidator provideValidator(ValidationManager validationManager,
MessageEncoder messageEncoder, MetadataEncoder metadataEncoder,
ClientHelper clientHelper, Clock clock) {
ClientHelper clientHelper, Clock clock, FeatureFlags featureFlags) {
IntroductionValidator introductionValidator =
new IntroductionValidator(messageEncoder, clientHelper,
metadataEncoder, clock);
validationManager.registerMessageValidator(CLIENT_ID, MAJOR_VERSION,
introductionValidator);
if (featureFlags.shouldEnableIntroductionsInCore()) {
validationManager.registerMessageValidator(CLIENT_ID, MAJOR_VERSION,
introductionValidator);
}
return introductionValidator;
}
@@ -52,7 +55,11 @@ public class IntroductionModule {
ConversationManager conversationManager,
ClientVersioningManager clientVersioningManager,
IntroductionManagerImpl introductionManager,
CleanupManager cleanupManager) {
CleanupManager cleanupManager,
FeatureFlags featureFlags) {
if (!featureFlags.shouldEnableIntroductionsInCore()) {
return introductionManager;
}
lifecycleManager.registerOpenDatabaseHook(introductionManager);
contactManager.registerContactHook(introductionManager);
validationManager.registerIncomingMessageHook(CLIENT_ID,

View File

@@ -107,6 +107,7 @@ internal class HeadlessModule(private val appDir: File) {
override fun shouldEnableImageAttachments() = false
override fun shouldEnableProfilePictures() = false
override fun shouldEnableDisappearingMessages() = false
override fun shouldEnableIntroductionsInCore() = false
override fun shouldEnablePrivateGroupsInCore() = false
override fun shouldEnableForumsInCore() = true
override fun shouldEnableBlogsInCore() = true