parent
c217692c76
commit
26bc564b38
|
@ -67,6 +67,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
s.UseMailservers = true
|
s.UseMailservers = true
|
||||||
|
|
||||||
s.PreviewPrivacy = true
|
s.PreviewPrivacy = true
|
||||||
|
s.PeerSyncingEnabled = false
|
||||||
s.Currency = "usd"
|
s.Currency = "usd"
|
||||||
s.LinkPreviewRequestEnabled = true
|
s.LinkPreviewRequestEnabled = true
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE settings ADD COLUMN peer_syncing_enabled BOOLEAN NOT NULL DEFAULT FALSE;
|
|
@ -310,6 +310,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
defaultSettings.UseMailservers = true
|
defaultSettings.UseMailservers = true
|
||||||
|
|
||||||
defaultSettings.PreviewPrivacy = true
|
defaultSettings.PreviewPrivacy = true
|
||||||
|
defaultSettings.PeerSyncingEnabled = false
|
||||||
defaultSettings.Currency = "usd"
|
defaultSettings.Currency = "usd"
|
||||||
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
||||||
defaultSettings.LinkPreviewRequestEnabled = true
|
defaultSettings.LinkPreviewRequestEnabled = true
|
||||||
|
|
|
@ -358,6 +358,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
defaultSettings.UseMailservers = true
|
defaultSettings.UseMailservers = true
|
||||||
|
|
||||||
defaultSettings.PreviewPrivacy = true
|
defaultSettings.PreviewPrivacy = true
|
||||||
|
defaultSettings.PeerSyncingEnabled = false
|
||||||
defaultSettings.Currency = "usd"
|
defaultSettings.Currency = "usd"
|
||||||
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
||||||
defaultSettings.LinkPreviewRequestEnabled = true
|
defaultSettings.LinkPreviewRequestEnabled = true
|
||||||
|
|
|
@ -235,6 +235,7 @@ func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derive
|
||||||
defaultSettings.UseMailservers = true
|
defaultSettings.UseMailservers = true
|
||||||
|
|
||||||
defaultSettings.PreviewPrivacy = true
|
defaultSettings.PreviewPrivacy = true
|
||||||
|
defaultSettings.PeerSyncingEnabled = false
|
||||||
defaultSettings.Currency = "usd"
|
defaultSettings.Currency = "usd"
|
||||||
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
defaultSettings.ProfilePicturesVisibility = settings.ProfilePicturesVisibilityEveryone
|
||||||
defaultSettings.LinkPreviewRequestEnabled = true
|
defaultSettings.LinkPreviewRequestEnabled = true
|
||||||
|
|
|
@ -506,13 +506,21 @@ var (
|
||||||
dBColumnName: "mnemonic_was_not_shown",
|
dBColumnName: "mnemonic_was_not_shown",
|
||||||
valueHandler: BoolHandler,
|
valueHandler: BoolHandler,
|
||||||
}
|
}
|
||||||
|
PeerSyncingEnabled = SettingField{
|
||||||
|
reactFieldName: "peer-syncing-enabled?",
|
||||||
|
dBColumnName: "peer_syncing_enabled",
|
||||||
|
valueHandler: BoolHandler,
|
||||||
|
}
|
||||||
SettingFieldRegister = []SettingField{
|
SettingFieldRegister = []SettingField{
|
||||||
AnonMetricsShouldSend,
|
AnonMetricsShouldSend,
|
||||||
Appearance,
|
Appearance,
|
||||||
AutoMessageEnabled,
|
AutoMessageEnabled,
|
||||||
BackupEnabled,
|
BackupEnabled,
|
||||||
BackupFetched,
|
BackupFetched,
|
||||||
|
Bio,
|
||||||
ChaosMode,
|
ChaosMode,
|
||||||
|
CollectibleGroupByCollection,
|
||||||
|
CollectibleGroupByCommunity,
|
||||||
Currency,
|
Currency,
|
||||||
CurrentUserStatus,
|
CurrentUserStatus,
|
||||||
CustomBootNodes,
|
CustomBootNodes,
|
||||||
|
@ -520,14 +528,16 @@ var (
|
||||||
DappsAddress,
|
DappsAddress,
|
||||||
DefaultSyncPeriod,
|
DefaultSyncPeriod,
|
||||||
DeviceName,
|
DeviceName,
|
||||||
|
DisplayAssetsBelowBalance,
|
||||||
|
DisplayAssetsBelowBalanceThreshold,
|
||||||
DisplayName,
|
DisplayName,
|
||||||
Bio,
|
|
||||||
EIP1581Address,
|
EIP1581Address,
|
||||||
Fleet,
|
Fleet,
|
||||||
GifAPIKey,
|
GifAPIKey,
|
||||||
GifFavourites,
|
GifFavourites,
|
||||||
GifRecents,
|
GifRecents,
|
||||||
HideHomeTooltip,
|
HideHomeTooltip,
|
||||||
|
IsGoerliEnabled,
|
||||||
KeycardInstanceUID,
|
KeycardInstanceUID,
|
||||||
KeycardPairedOn,
|
KeycardPairedOn,
|
||||||
KeycardPairing,
|
KeycardPairing,
|
||||||
|
@ -547,10 +557,12 @@ var (
|
||||||
NodeConfig,
|
NodeConfig,
|
||||||
NotificationsEnabled,
|
NotificationsEnabled,
|
||||||
OpenseaEnabled,
|
OpenseaEnabled,
|
||||||
|
PeerSyncingEnabled,
|
||||||
PhotoPath,
|
PhotoPath,
|
||||||
PinnedMailservers,
|
PinnedMailservers,
|
||||||
PreferredName,
|
PreferredName,
|
||||||
PreviewPrivacy,
|
PreviewPrivacy,
|
||||||
|
ProfileMigrationNeeded,
|
||||||
ProfilePicturesShowTo,
|
ProfilePicturesShowTo,
|
||||||
ProfilePicturesVisibility,
|
ProfilePicturesVisibility,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
|
@ -561,27 +573,21 @@ var (
|
||||||
RemotePushNotificationsEnabled,
|
RemotePushNotificationsEnabled,
|
||||||
SendPushNotifications,
|
SendPushNotifications,
|
||||||
SendStatusUpdates,
|
SendStatusUpdates,
|
||||||
|
ShowCommunityAssetWhenSendingTokens,
|
||||||
StickersPacksInstalled,
|
StickersPacksInstalled,
|
||||||
StickersPacksPending,
|
StickersPacksPending,
|
||||||
StickersRecentStickers,
|
StickersRecentStickers,
|
||||||
SyncingOnMobileNetwork,
|
SyncingOnMobileNetwork,
|
||||||
TelemetryServerURL,
|
TelemetryServerURL,
|
||||||
TestNetworksEnabled,
|
TestNetworksEnabled,
|
||||||
|
TokenGroupByCommunity,
|
||||||
|
URLUnfurlingMode,
|
||||||
UseMailservers,
|
UseMailservers,
|
||||||
WakuBloomFilterMode,
|
WakuBloomFilterMode,
|
||||||
WalletRootAddress,
|
WalletRootAddress,
|
||||||
WalletSetUpPassed,
|
WalletSetUpPassed,
|
||||||
WalletVisibleTokens,
|
WalletVisibleTokens,
|
||||||
WebviewAllowPermissionRequests,
|
WebviewAllowPermissionRequests,
|
||||||
ProfileMigrationNeeded,
|
|
||||||
IsGoerliEnabled,
|
|
||||||
TokenGroupByCommunity,
|
|
||||||
ShowCommunityAssetWhenSendingTokens,
|
|
||||||
DisplayAssetsBelowBalance,
|
|
||||||
DisplayAssetsBelowBalanceThreshold,
|
|
||||||
CollectibleGroupByCollection,
|
|
||||||
CollectibleGroupByCommunity,
|
|
||||||
URLUnfurlingMode,
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,8 @@ func (db *Database) GetSettings() (Settings, error) {
|
||||||
gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key,
|
gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key,
|
||||||
test_networks_enabled, mutual_contact_enabled, profile_migration_needed, is_goerli_enabled, wallet_token_preferences_group_by_community, url_unfurling_mode,
|
test_networks_enabled, mutual_contact_enabled, profile_migration_needed, is_goerli_enabled, wallet_token_preferences_group_by_community, url_unfurling_mode,
|
||||||
omit_transfers_history_scan, mnemonic_was_not_shown, wallet_show_community_asset_when_sending_tokens, wallet_display_assets_below_balance,
|
omit_transfers_history_scan, mnemonic_was_not_shown, wallet_show_community_asset_when_sending_tokens, wallet_display_assets_below_balance,
|
||||||
wallet_display_assets_below_balance_threshold, wallet_collectible_preferences_group_by_collection, wallet_collectible_preferences_group_by_community
|
wallet_display_assets_below_balance_threshold, wallet_collectible_preferences_group_by_collection, wallet_collectible_preferences_group_by_community,
|
||||||
|
peer_syncing_enabled
|
||||||
FROM
|
FROM
|
||||||
settings
|
settings
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -475,6 +476,7 @@ func (db *Database) GetSettings() (Settings, error) {
|
||||||
&s.DisplayAssetsBelowBalanceThreshold,
|
&s.DisplayAssetsBelowBalanceThreshold,
|
||||||
&s.CollectibleGroupByCollection,
|
&s.CollectibleGroupByCollection,
|
||||||
&s.CollectibleGroupByCommunity,
|
&s.CollectibleGroupByCommunity,
|
||||||
|
&s.PeerSyncingEnabled,
|
||||||
)
|
)
|
||||||
|
|
||||||
return s, err
|
return s, err
|
||||||
|
@ -763,6 +765,18 @@ func (db *Database) GetIsGoerliEnabled() (result bool, err error) {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *Database) SetPeerSyncingEnabled(value bool) error {
|
||||||
|
return db.SaveSettingField(PeerSyncingEnabled, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *Database) GetPeerSyncingEnabled() (result bool, err error) {
|
||||||
|
err = db.makeSelectRow(PeerSyncingEnabled).Scan(&result)
|
||||||
|
if err == sql.ErrNoRows {
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
|
||||||
func (db *Database) GetTokenGroupByCommunity() (result bool, err error) {
|
func (db *Database) GetTokenGroupByCommunity() (result bool, err error) {
|
||||||
err = db.makeSelectRow(TokenGroupByCommunity).Scan(&result)
|
err = db.makeSelectRow(TokenGroupByCommunity).Scan(&result)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
|
|
|
@ -49,6 +49,7 @@ type DatabaseSettingsManager interface {
|
||||||
SetPinnedMailservers(mailservers map[string]string) error
|
SetPinnedMailservers(mailservers map[string]string) error
|
||||||
SetUseMailservers(value bool) error
|
SetUseMailservers(value bool) error
|
||||||
SetTokenGroupByCommunity(value bool) error
|
SetTokenGroupByCommunity(value bool) error
|
||||||
|
SetPeerSyncingEnabled(value bool) error
|
||||||
|
|
||||||
CreateSettings(s Settings, n params.NodeConfig) error
|
CreateSettings(s Settings, n params.NodeConfig) error
|
||||||
SaveSetting(setting string, value interface{}) error
|
SaveSetting(setting string, value interface{}) error
|
||||||
|
@ -76,4 +77,5 @@ type DatabaseSettingsManager interface {
|
||||||
URLUnfurlingMode() (result int64, err error)
|
URLUnfurlingMode() (result int64, err error)
|
||||||
SubscribeToChanges() chan *SyncSettingField
|
SubscribeToChanges() chan *SyncSettingField
|
||||||
MnemonicWasShown() error
|
MnemonicWasShown() error
|
||||||
|
GetPeerSyncingEnabled() (result bool, err error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,20 @@ func (mr *MockDatabaseSettingsManagerMockRecorder) SetUseMailservers(value inter
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetUseMailservers", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).SetUseMailservers), value)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetUseMailservers", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).SetUseMailservers), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetPeerSyncingEnabled mocks base method.
|
||||||
|
func (m *MockDatabaseSettingsManager) SetPeerSyncingEnabled(value bool) error {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "SetPeerSyncingEnabled", value)
|
||||||
|
ret0, _ := ret[0].(error)
|
||||||
|
return ret0
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPeerSyncingEnabled indicates an expected call of SetPeerSyncingEnabled.
|
||||||
|
func (mr *MockDatabaseSettingsManagerMockRecorder) SetPeerSyncingEnabled(value interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPeerSyncingEnabled", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).SetPeerSyncingEnabled), value)
|
||||||
|
}
|
||||||
|
|
||||||
// ShouldBroadcastUserStatus mocks base method.
|
// ShouldBroadcastUserStatus mocks base method.
|
||||||
func (m *MockDatabaseSettingsManager) ShouldBroadcastUserStatus() (bool, error) {
|
func (m *MockDatabaseSettingsManager) ShouldBroadcastUserStatus() (bool, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -305,3 +305,18 @@ func (mr *MockDatabaseSettingsManagerMockRecorder) GetRecentStickers() *gomock.C
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRecentStickers", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetRecentStickers))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetRecentStickers", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetRecentStickers))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPeerSyncingEnabled mocks base method.
|
||||||
|
func (m *MockDatabaseSettingsManager) GetPeerSyncingEnabled() (bool, error) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
ret := m.ctrl.Call(m, "GetPeerSyncingEnabled")
|
||||||
|
ret0, _ := ret[0].(bool)
|
||||||
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPeerSyncingEnabled indicates an expected call of GetPeerSyncingEnabled.
|
||||||
|
func (mr *MockDatabaseSettingsManagerMockRecorder) GetPeerSyncingEnabled() *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeerSyncingEnabled", reflect.TypeOf((*MockDatabaseSettingsManager)(nil).GetPeerSyncingEnabled))
|
||||||
|
}
|
||||||
|
|
|
@ -213,6 +213,7 @@ type Settings struct {
|
||||||
CollectibleGroupByCollection bool `json:"collectible-group-by-collection?,omitempty"`
|
CollectibleGroupByCollection bool `json:"collectible-group-by-collection?,omitempty"`
|
||||||
CollectibleGroupByCommunity bool `json:"collectible-group-by-community?,omitempty"`
|
CollectibleGroupByCommunity bool `json:"collectible-group-by-community?,omitempty"`
|
||||||
URLUnfurlingMode URLUnfurlingModeType `json:"url-unfurling-mode,omitempty"`
|
URLUnfurlingMode URLUnfurlingModeType `json:"url-unfurling-mode,omitempty"`
|
||||||
|
PeerSyncingEnabled bool `json:"peer-syncing-enabled?,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Settings) MarshalJSON() ([]byte, error) {
|
func (s Settings) MarshalJSON() ([]byte, error) {
|
||||||
|
|
|
@ -341,6 +341,8 @@ func stickersRecentStickersProtobufFactoryStruct(s Settings, clock uint64, chatI
|
||||||
return buildRawStickersRecentStickersSyncMessage(srs, clock, chatID)
|
return buildRawStickersRecentStickersSyncMessage(srs, clock, chatID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
func assertBytes(value interface{}) ([]byte, error) {
|
func assertBytes(value interface{}) ([]byte, error) {
|
||||||
v, ok := value.([]byte)
|
v, ok := value.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -62,7 +62,15 @@ func (m *Messenger) handleDatasyncMetadata(response *common.HandleMessageRespons
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := m.OnDatasyncOffer(response)
|
isPeerSyncingEnabled, err := m.settings.GetPeerSyncingEnabled()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isPeerSyncingEnabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = m.OnDatasyncOffer(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -102,6 +110,14 @@ func (m *Messenger) sendDatasyncOffers() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isPeerSyncingEnabled, err := m.settings.GetPeerSyncingEnabled()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !isPeerSyncingEnabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
communities, err := m.communitiesManager.Joined()
|
communities, err := m.communitiesManager.Joined()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -57,3 +57,15 @@ func (m *Messenger) SetCustomizationColor(ctx context.Context, request *requests
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Messenger) TogglePeerSyncing(request *requests.TogglePeerSyncingRequest) error {
|
||||||
|
if err := request.Validate(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err := m.settings.SetPeerSyncingEnabled(request.Enabled)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package requests
|
||||||
|
|
||||||
|
type TogglePeerSyncingRequest struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *TogglePeerSyncingRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1499,6 +1499,10 @@ func (api *PublicAPI) ToggleUseMailservers(value bool) error {
|
||||||
return api.service.messenger.ToggleUseMailservers(value)
|
return api.service.messenger.ToggleUseMailservers(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *PublicAPI) TogglePeerSyncing(request *requests.TogglePeerSyncingRequest) error {
|
||||||
|
return api.service.messenger.TogglePeerSyncing(request)
|
||||||
|
}
|
||||||
|
|
||||||
func (api *PublicAPI) SetPinnedMailservers(pinnedMailservers map[string]string) error {
|
func (api *PublicAPI) SetPinnedMailservers(pinnedMailservers map[string]string) error {
|
||||||
return api.service.messenger.SetPinnedMailservers(pinnedMailservers)
|
return api.service.messenger.SetPinnedMailservers(pinnedMailservers)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue