diff --git a/VERSION b/VERSION index cf467e72d..05e39cbb4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.96.4 +0.97.0 diff --git a/api/backend.go b/api/backend.go index 4d5c8c2de..557d49b88 100644 --- a/api/backend.go +++ b/api/backend.go @@ -6,6 +6,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/services/personal" "github.com/status-im/status-go/services/typeddata" @@ -18,7 +19,7 @@ type StatusBackend interface { StartNode(config *params.NodeConfig) error // NOTE: Only used in canary StartNodeWithKey(acc multiaccounts.Account, password string, keyHex string) error StartNodeWithAccount(acc multiaccounts.Account, password string, conf *params.NodeConfig) error - StartNodeWithAccountAndInitialConfig(account multiaccounts.Account, password string, settings accounts.Settings, conf *params.NodeConfig, subaccs []accounts.Account) error + StartNodeWithAccountAndInitialConfig(account multiaccounts.Account, password string, settings settings.Settings, conf *params.NodeConfig, subaccs []accounts.Account) error StopNode() error // RestartNode() error // NOTE: Only used in tests @@ -29,7 +30,7 @@ type StatusBackend interface { OpenAccounts() error GetAccounts() ([]multiaccounts.Account, error) // SaveAccount(account multiaccounts.Account) error - SaveAccountAndStartNodeWithKey(acc multiaccounts.Account, password string, settings accounts.Settings, conf *params.NodeConfig, subaccs []accounts.Account, keyHex string) error + SaveAccountAndStartNodeWithKey(acc multiaccounts.Account, password string, settings settings.Settings, conf *params.NodeConfig, subaccs []accounts.Account, keyHex string) error Recover(rpcParams personal.RecoverParams) (types.Address, error) Logout() error diff --git a/api/backend_test.go b/api/backend_test.go index a85415758..37702effd 100644 --- a/api/backend_test.go +++ b/api/backend_test.go @@ -22,6 +22,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/node" "github.com/status-im/status-go/params" "github.com/status-im/status-go/rpc" @@ -31,8 +32,8 @@ import ( ) var ( - networks = json.RawMessage("{}") - settings = accounts.Settings{ + networks = json.RawMessage("{}") + testSettings = settings.Settings{ Address: types.HexToAddress("0xeC540f3745Ff2964AFC1171a5A0DD726d1F6B472"), CurrentNetwork: "mainnet_rpc", DappsAddress: types.HexToAddress("0xe1300f99fDF7346986CbC766903245087394ecd0"), @@ -412,7 +413,8 @@ func TestBackendGetVerifiedAccount(t *testing.T) { pkey, err := crypto.GenerateKey() require.NoError(t, err) address := crypto.PubkeyToAddress(pkey.PublicKey) - db := accounts.NewDB(backend.appDB) + db, err := accounts.NewDB(backend.appDB) + require.NoError(t, err) _, err = backend.AccountManager().ImportAccount(pkey, password) require.NoError(t, err) require.NoError(t, db.SaveAccounts([]accounts.Account{{Address: address}})) @@ -425,7 +427,8 @@ func TestBackendGetVerifiedAccount(t *testing.T) { pkey, err := crypto.GenerateKey() require.NoError(t, err) address := crypto.PubkeyToAddress(pkey.PublicKey) - db := accounts.NewDB(backend.appDB) + db, err := accounts.NewDB(backend.appDB) + require.NoError(t, err) _, err = backend.AccountManager().ImportAccount(pkey, password) require.NoError(t, err) require.NoError(t, db.SaveAccounts([]accounts.Account{{Address: address}})) @@ -460,7 +463,7 @@ func TestLoginWithKey(t *testing.T) { require.NoError(t, b.OpenAccounts()) address := crypto.PubkeyToAddress(walletKey.PublicKey) - require.NoError(t, b.SaveAccountAndStartNodeWithKey(main, "test-pass", settings, conf, []accounts.Account{{Address: address, Wallet: true}}, keyhex)) + require.NoError(t, b.SaveAccountAndStartNodeWithKey(main, "test-pass", testSettings, conf, []accounts.Account{{Address: address, Wallet: true}}, keyhex)) require.NoError(t, b.Logout()) require.NoError(t, b.StopNode()) @@ -503,7 +506,7 @@ func TestVerifyDatabasePassword(t *testing.T) { require.NoError(t, b.OpenAccounts()) address := crypto.PubkeyToAddress(walletKey.PublicKey) - require.NoError(t, b.SaveAccountAndStartNodeWithKey(main, "test-pass", settings, conf, []accounts.Account{{Address: address, Wallet: true}}, keyhex)) + require.NoError(t, b.SaveAccountAndStartNodeWithKey(main, "test-pass", testSettings, conf, []accounts.Account{{Address: address, Wallet: true}}, keyhex)) require.NoError(t, b.Logout()) require.NoError(t, b.StopNode()) @@ -547,7 +550,7 @@ func TestDeleteMulticcount(t *testing.T) { err = backend.ensureAppDBOpened(account, "123123") require.NoError(t, err) - settings := accounts.Settings{ + s := settings.Settings{ Address: types.HexToAddress(accountInfo.Address), CurrentNetwork: "mainnet_rpc", DappsAddress: types.HexToAddress(accountInfo.Address), @@ -564,7 +567,7 @@ func TestDeleteMulticcount(t *testing.T) { WalletRootAddress: types.HexToAddress(accountInfo.Address)} err = backend.saveAccountsAndSettings( - settings, + s, ¶ms.NodeConfig{}, nil) require.NoError(t, err) @@ -622,7 +625,7 @@ func TestConvertAccount(t *testing.T) { err = backend.ensureAppDBOpened(account, password) require.NoError(t, err) - settings := accounts.Settings{ + s := settings.Settings{ Address: types.HexToAddress(accountInfo.Address), CurrentNetwork: "mainnet_rpc", DappsAddress: types.HexToAddress(accountInfo.Address), @@ -639,7 +642,7 @@ func TestConvertAccount(t *testing.T) { WalletRootAddress: types.HexToAddress(accountInfo.Address)} err = backend.saveAccountsAndSettings( - settings, + s, ¶ms.NodeConfig{}, nil) require.NoError(t, err) @@ -659,7 +662,7 @@ func TestConvertAccount(t *testing.T) { keycardAccount := account keycardAccount.KeycardPairing = "pairing" - keycardSettings := accounts.Settings{ + keycardSettings := settings.Settings{ KeycardInstanceUID: "0xdeadbeef", KeycardPAiredOn: 1, KeycardPairing: "pairing", diff --git a/api/geth_backend.go b/api/geth_backend.go index ee6f0314b..e4e910911 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -27,6 +27,7 @@ import ( "github.com/status-im/status-go/logutils" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/node" "github.com/status-im/status-go/nodecfg" "github.com/status-im/status-go/params" @@ -294,7 +295,10 @@ func (b *GethStatusBackend) startNodeWithKey(acc multiaccounts.Account, password } b.account = &acc - accountsDB := accounts.NewDB(b.appDB) + accountsDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } walletAddr, err := accountsDB.GetWalletAddress() if err != nil { return err @@ -388,7 +392,10 @@ func (b *GethStatusBackend) startNodeWithAccount(acc multiaccounts.Account, pass return err } b.account = &acc - accountsDB := accounts.NewDB(b.appDB) + accountsDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } chatAddr, err := accountsDB.GetChatAddress() if err != nil { return err @@ -431,7 +438,10 @@ func (b *GethStatusBackend) MigrateKeyStoreDir(acc multiaccounts.Account, passwo return err } - accountDB := accounts.NewDB(b.appDB) + accountDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } accounts, err := accountDB.GetAccounts() if err != nil { return err @@ -535,7 +545,7 @@ func (b *GethStatusBackend) ChangeDatabasePassword(keyUID string, password strin return nil } -func (b *GethStatusBackend) ConvertToKeycardAccount(keyStoreDir string, account multiaccounts.Account, settings accounts.Settings, password string, newPassword string) error { +func (b *GethStatusBackend) ConvertToKeycardAccount(keyStoreDir string, account multiaccounts.Account, s settings.Settings, password string, newPassword string) error { err := b.multiaccountsDB.UpdateAccountKeycardPairing(account) if err != nil { return err @@ -546,23 +556,26 @@ func (b *GethStatusBackend) ConvertToKeycardAccount(keyStoreDir string, account return err } - accountDB := accounts.NewDB(b.appDB) - err = accountDB.SaveSetting("keycard-instance_uid", settings.KeycardInstanceUID) + accountDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } + err = accountDB.SaveSettingField(settings.KeycardInstanceUID, s.KeycardInstanceUID) if err != nil { return err } - err = accountDB.SaveSetting("keycard-paired_on", settings.KeycardPAiredOn) + err = accountDB.SaveSettingField(settings.KeycardPairedOn, s.KeycardPAiredOn) if err != nil { return err } - err = accountDB.SaveSetting("keycard-pairing", settings.KeycardPairing) + err = accountDB.SaveSettingField(settings.KeycardPairing, s.KeycardPairing) if err != nil { return err } - err = accountDB.SaveSetting("mnemonic", nil) + err = accountDB.SaveSettingField(settings.Mnemonic, nil) if err != nil { return err } @@ -592,7 +605,10 @@ func (b *GethStatusBackend) VerifyDatabasePassword(keyUID string, password strin return err } - accountsDB := accounts.NewDB(b.appDB) + accountsDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } _, err = accountsDB.GetWalletAddress() if err != nil { return err @@ -606,7 +622,7 @@ func (b *GethStatusBackend) VerifyDatabasePassword(keyUID string, password strin return nil } -func (b *GethStatusBackend) SaveAccountAndStartNodeWithKey(acc multiaccounts.Account, password string, settings accounts.Settings, nodecfg *params.NodeConfig, subaccs []accounts.Account, keyHex string) error { +func (b *GethStatusBackend) SaveAccountAndStartNodeWithKey(acc multiaccounts.Account, password string, settings settings.Settings, nodecfg *params.NodeConfig, subaccs []accounts.Account, keyHex string) error { err := b.SaveAccount(acc) if err != nil { return err @@ -628,7 +644,7 @@ func (b *GethStatusBackend) SaveAccountAndStartNodeWithKey(acc multiaccounts.Acc func (b *GethStatusBackend) StartNodeWithAccountAndInitialConfig( account multiaccounts.Account, password string, - settings accounts.Settings, + settings settings.Settings, nodecfg *params.NodeConfig, subaccs []accounts.Account, ) error { @@ -647,11 +663,14 @@ func (b *GethStatusBackend) StartNodeWithAccountAndInitialConfig( return b.StartNodeWithAccount(account, password, nil) } -func (b *GethStatusBackend) saveAccountsAndSettings(settings accounts.Settings, nodecfg *params.NodeConfig, subaccs []accounts.Account) error { +func (b *GethStatusBackend) saveAccountsAndSettings(settings settings.Settings, nodecfg *params.NodeConfig, subaccs []accounts.Account) error { b.mu.Lock() defer b.mu.Unlock() - accdb := accounts.NewDB(b.appDB) - err := accdb.CreateSettings(settings, *nodecfg) + accdb, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } + err = accdb.CreateSettings(settings, *nodecfg) if err != nil { return err } @@ -935,7 +954,11 @@ func (b *GethStatusBackend) HashTypedDataV4(typed signercore.TypedData) (types.H func (b *GethStatusBackend) getVerifiedWalletAccount(address, password string) (*account.SelectedExtKey, error) { config := b.StatusNode().Config() - db := accounts.NewDB(b.appDB) + db, err := accounts.NewDB(b.appDB) + if err != nil { + b.log.Error("failed to create new *Database instance", "error", err) + return nil, err + } exists, err := db.AddressExists(types.HexToAddress(address)) if err != nil { b.log.Error("failed to query db for a given address", "address", address, "error", err) @@ -1177,7 +1200,11 @@ func (b *GethStatusBackend) injectAccountsIntoWakuService(w types.WakuKeyManager // Init public status api b.statusNode.StatusPublicService().Init(messenger) // Init chat service - b.statusNode.ChatService().Init(messenger) + accDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } + b.statusNode.ChatService(accDB).Init(messenger) } return nil @@ -1246,8 +1273,12 @@ func (b *GethStatusBackend) SwitchFleet(fleet string, conf *params.NodeConfig) e return ErrDBNotAvailable } - accountDB := accounts.NewDB(b.appDB) - err := accountDB.SaveSetting("fleet", fleet) + accountDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } + + err = accountDB.SaveSetting("fleet", fleet) if err != nil { return err } diff --git a/appdatabase/database.go b/appdatabase/database.go index 7c61610ce..187d1f1e7 100644 --- a/appdatabase/database.go +++ b/appdatabase/database.go @@ -2,6 +2,9 @@ package appdatabase import ( "database/sql" + "errors" + + "github.com/ethereum/go-ethereum/log" "github.com/status-im/status-go/appdatabase/migrations" migrationsprevnodecfg "github.com/status-im/status-go/appdatabase/migrationsprevnodecfg" @@ -71,3 +74,36 @@ func EncryptDatabase(oldPath, newPath, password string) error { func ChangeDatabasePassword(path, password, newPassword string) error { return sqlite.ChangeEncryptionKey(path, password, newPassword) } + +// GetDBFilename takes an instance of sql.DB and returns the filename of the "main" database +func GetDBFilename(db *sql.DB) (string, error) { + if db == nil { + logger := log.New() + logger.Warn("GetDBFilename was passed a nil pointer sql.DB") + return "", nil + } + + var i, category, filename string + rows, err := db.Query("PRAGMA database_list;") + if err != nil { + return "", err + } + + defer rows.Close() + for rows.Next() { + err = rows.Scan(&i, &category, &filename) + if err != nil { + return "", err + } + + // The "main" database is the one we care about + if category == "main" { + return filename, nil + } + } + if err := rows.Err(); err != nil { + return "", err + } + + return "", errors.New("no main database found") +} diff --git a/appdatabase/database_test.go b/appdatabase/database_test.go new file mode 100644 index 000000000..e181d5c79 --- /dev/null +++ b/appdatabase/database_test.go @@ -0,0 +1,31 @@ +package appdatabase + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_GetDBFilename(t *testing.T) { + // Test with a temp file instance + db, stop, err := SetupTestSQLDB("test") + require.NoError(t, err) + defer func() { + require.NoError(t, stop()) + }() + + fn, err := GetDBFilename(db) + require.NoError(t, err) + require.True(t, len(fn) > 0) + + // Test with in memory instance + mdb, err := InitializeDB(":memory:", "test") + require.NoError(t, err) + defer func() { + require.NoError(t, mdb.Close()) + }() + + fn, err = GetDBFilename(mdb) + require.NoError(t, err) + require.Equal(t, "", fn) +} diff --git a/appdatabase/migrations/bindata.go b/appdatabase/migrations/bindata.go index db1802f94..248b82a71 100644 --- a/appdatabase/migrations/bindata.go +++ b/appdatabase/migrations/bindata.go @@ -10,6 +10,7 @@ // 1647860168_add_torrent_config.up.sql (211B) // 1647862837_add_communities_settings_table.up.sql (206B) // 1647862838_reset_last_backup.up.sql (37B) +// 1647871652_add_settings_sync_clock_table.up.sql (1.044kB) // doc.go (74B) package migrations @@ -94,7 +95,7 @@ func _1640111208_dummyUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3e, 0xf0, 0xae, 0x20, 0x6e, 0x75, 0xd1, 0x36, 0x14, 0xf2, 0x40, 0xe5, 0xd6, 0x7a, 0xc4, 0xa5, 0x72, 0xaa, 0xb5, 0x4d, 0x71, 0x97, 0xb8, 0xe8, 0x95, 0x22, 0x95, 0xa2, 0xac, 0xaf, 0x48, 0x58}} return a, nil } @@ -114,7 +115,7 @@ func _1642666031_add_removed_clock_to_bookmarksUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(0644), modTime: time.Unix(1647602241, 0)} + info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(0644), modTime: time.Unix(1646739279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x84, 0x4e, 0x38, 0x99, 0x7a, 0xc, 0x90, 0x13, 0xec, 0xfe, 0x2f, 0x55, 0xff, 0xb7, 0xb6, 0xaa, 0x96, 0xc6, 0x92, 0x79, 0xcc, 0xee, 0x4e, 0x99, 0x53, 0xfe, 0x1c, 0xbb, 0x32, 0x2, 0xa4, 0x27}} return a, nil } @@ -134,7 +135,7 @@ func _1643644541_gif_api_key_settingUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(0644), modTime: time.Unix(1646739279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1b, 0x94, 0x28, 0xfb, 0x66, 0xd1, 0x7c, 0xb8, 0x89, 0xe2, 0xb4, 0x71, 0x65, 0x24, 0x57, 0x22, 0x95, 0x38, 0x97, 0x3, 0x9b, 0xc6, 0xa4, 0x41, 0x7b, 0xba, 0xf7, 0xdb, 0x70, 0xf7, 0x20, 0x3a}} return a, nil } @@ -154,7 +155,7 @@ func _1644188994_recent_stickersUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(0644), modTime: time.Unix(1647521077, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1e, 0xad, 0xaa, 0x30, 0xbf, 0x4, 0x7, 0xf8, 0xc3, 0x3, 0xb8, 0x97, 0x23, 0x2b, 0xbd, 0x1c, 0x60, 0x69, 0xb0, 0x42, 0x5e, 0x6b, 0xd, 0xa7, 0xa3, 0x6b, 0x2e, 0xdc, 0x70, 0x13, 0x72, 0x7}} return a, nil } @@ -174,7 +175,7 @@ func _1646659233_add_address_to_dapp_permisssionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(0644), modTime: time.Unix(1647533729, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xed, 0xb0, 0x35, 0xcc, 0x2e, 0x16, 0xe6, 0x15, 0x86, 0x2c, 0x37, 0x80, 0xae, 0xa3, 0xc5, 0x31, 0x78, 0x5, 0x9d, 0xcd, 0x7b, 0xeb, 0x5f, 0xf2, 0xb3, 0x74, 0x72, 0xdf, 0xcf, 0x88, 0xb, 0x40}} return a, nil } @@ -194,7 +195,7 @@ func _1646841105_add_emoji_accountUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(0644), modTime: time.Unix(1647533729, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe6, 0x77, 0x29, 0x95, 0x18, 0x64, 0x82, 0x63, 0xe7, 0xaf, 0x6c, 0xa9, 0x15, 0x7d, 0x46, 0xa6, 0xbc, 0xdf, 0xa7, 0xd, 0x2b, 0xd2, 0x2d, 0x97, 0x4d, 0xa, 0x6b, 0xd, 0x6e, 0x90, 0x42, 0x5c}} return a, nil } @@ -214,7 +215,7 @@ func _1647278782_display_nameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1647948124, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf4, 0xa1, 0x1f, 0x3e, 0x61, 0x65, 0x8d, 0xff, 0xee, 0xde, 0xc5, 0x91, 0xd9, 0x5c, 0xb5, 0xe2, 0xf0, 0xb7, 0xe7, 0x5c, 0x5c, 0x16, 0x25, 0x89, 0xee, 0x78, 0x12, 0xea, 0x3e, 0x48, 0x41, 0xa6}} return a, nil } @@ -234,7 +235,7 @@ func _1647860168_add_torrent_configUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647860168_add_torrent_config.up.sql", size: 211, mode: os.FileMode(0644), modTime: time.Unix(1647872405, 0)} + info := bindataFileInfo{name: "1647860168_add_torrent_config.up.sql", size: 211, mode: os.FileMode(0644), modTime: time.Unix(1647948124, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0x92, 0x22, 0x37, 0x96, 0xf3, 0xb5, 0x5b, 0x27, 0xd0, 0x7d, 0x43, 0x5, 0x4e, 0x9d, 0xe2, 0x49, 0xbe, 0x86, 0x31, 0xa1, 0x89, 0xff, 0xd6, 0x51, 0xe0, 0x9c, 0xb, 0xda, 0xfc, 0xf2, 0x93}} return a, nil } @@ -254,7 +255,7 @@ func _1647862837_add_communities_settings_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647862837_add_communities_settings_table.up.sql", size: 206, mode: os.FileMode(0644), modTime: time.Unix(1648028540, 0)} + info := bindataFileInfo{name: "1647862837_add_communities_settings_table.up.sql", size: 206, mode: os.FileMode(0644), modTime: time.Unix(1647955855, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbd, 0x87, 0x78, 0x99, 0xd9, 0x5d, 0xbd, 0xf7, 0x57, 0x9c, 0xca, 0x97, 0xbd, 0xb3, 0xe9, 0xb5, 0x89, 0x31, 0x3f, 0xf6, 0x5c, 0x13, 0xb, 0xc3, 0x54, 0x93, 0x18, 0x40, 0x7, 0x82, 0xfe, 0x7e}} return a, nil } @@ -274,11 +275,31 @@ func _1647862838_reset_last_backupUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1647862838_reset_last_backup.up.sql", size: 37, mode: os.FileMode(0644), modTime: time.Unix(1648041903, 0)} + info := bindataFileInfo{name: "1647862838_reset_last_backup.up.sql", size: 37, mode: os.FileMode(0644), modTime: time.Unix(1648051622, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x21, 0xe3, 0xd5, 0xf6, 0x5f, 0xfe, 0x65, 0xfa, 0x1d, 0x88, 0xf8, 0x5f, 0x24, 0x71, 0x34, 0x68, 0x96, 0x2a, 0x60, 0x87, 0x15, 0x82, 0x4d, 0x8a, 0x59, 0x3d, 0x1f, 0xd8, 0x56, 0xd4, 0xfb, 0xda}} return a, nil } +var __1647871652_add_settings_sync_clock_tableUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x92\xcd\x6e\xdb\x30\x10\x84\xef\x7e\x8a\xbd\x25\x06\x78\xc8\x3d\x27\x35\x61\x1b\xa1\xaa\x5d\x30\x74\x82\x9c\x16\x2c\xb5\x52\x16\x96\x49\x81\x4b\x29\xf0\xdb\x17\xfd\x49\x7f\x52\xb9\x92\xc1\x13\xb1\x33\x58\x72\xe6\xbb\x31\xba\xb0\x1a\x6c\xf1\xae\xd2\x20\x94\x33\x87\x56\x50\x8e\xc1\xa3\xef\xa2\xdf\xc3\xe5\x0a\x00\xc0\x0f\x29\x51\xf0\x47\x28\x37\x56\x7f\xd0\x06\x36\x5b\x0b\x9b\x5d\x55\xc1\xad\x7e\x5f\xec\x2a\x0b\x57\xea\xbb\xb0\xe5\x06\x13\x79\x0a\x59\x16\x69\x1b\x37\xc6\xc4\x99\xe6\xd5\x07\x12\x71\x2d\x09\x36\x29\x1e\xd0\xc7\x90\x9d\xcf\x82\x31\x74\xf3\xaf\xea\x13\x35\x94\x12\xd5\x18\xdc\x81\x96\xc8\x47\xa6\x17\xec\x13\x8f\x6e\xc1\xa7\xfb\x14\x1b\xee\x08\x7b\xf6\x79\x48\x24\x28\xcf\xf1\x05\x73\x3c\xdf\x38\xb2\xf0\x17\xee\x38\xcf\x2f\x15\x0a\x35\x4a\x76\x79\x10\x1c\xfa\xda\x2d\xc9\x50\x32\xfb\x3d\x25\xc1\xde\xf9\xbd\x20\x07\xc9\xae\xeb\xa8\x3e\xd7\xd8\x53\xa8\x39\xb4\xcb\x6d\x3f\x90\xc0\xd7\xfb\xbc\xf1\x18\xf2\x33\x65\xf6\xc8\x35\x3c\x14\xe6\xe6\xae\x30\xbf\x34\x17\x5c\x5f\xc0\x67\x53\x7e\x2a\xcc\x13\x7c\xd4\x4f\xab\x35\x3c\x96\xf6\x6e\xbb\xb3\x60\xb6\x8f\xe5\xed\xf5\xaa\xdc\xdc\x6b\x63\xbf\x6d\xd9\x4e\x43\xfd\xca\xb3\xfa\x13\x58\xf5\x37\x91\xea\x7f\xc8\xa9\x37\x4c\xa9\xb7\xd0\xa8\x93\x54\x4c\x4c\x7e\xd7\xae\xa6\x7a\x55\x27\x8b\xfb\x67\xf2\xb3\x19\x75\x32\xfa\x35\x3c\x14\xd5\x4e\xdf\xc3\xe5\x95\x9a\x3c\xeb\xeb\xaf\x01\x00\x00\xff\xff\xf3\x53\x0f\x1c\x14\x04\x00\x00") + +func _1647871652_add_settings_sync_clock_tableUpSqlBytes() ([]byte, error) { + return bindataRead( + __1647871652_add_settings_sync_clock_tableUpSql, + "1647871652_add_settings_sync_clock_table.up.sql", + ) +} + +func _1647871652_add_settings_sync_clock_tableUpSql() (*asset, error) { + bytes, err := _1647871652_add_settings_sync_clock_tableUpSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "1647871652_add_settings_sync_clock_table.up.sql", size: 1044, mode: os.FileMode(0644), modTime: time.Unix(1648051875, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd8, 0x58, 0xec, 0x85, 0x90, 0xfa, 0x30, 0x98, 0x98, 0x9a, 0xa6, 0xa8, 0x96, 0x2b, 0x38, 0x93, 0xf3, 0xae, 0x46, 0x74, 0xa4, 0x41, 0x62, 0x9b, 0x2, 0x86, 0xbf, 0xe5, 0x2a, 0xce, 0xe2, 0xc0}} + return a, nil +} + var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x2c\xc9\xb1\x0d\xc4\x20\x0c\x05\xd0\x9e\x29\xfe\x02\xd8\xfd\x6d\xe3\x4b\xac\x2f\x44\x82\x09\x78\x7f\xa5\x49\xfd\xa6\x1d\xdd\xe8\xd8\xcf\x55\x8a\x2a\xe3\x47\x1f\xbe\x2c\x1d\x8c\xfa\x6f\xe3\xb4\x34\xd4\xd9\x89\xbb\x71\x59\xb6\x18\x1b\x35\x20\xa2\x9f\x0a\x03\xa2\xe5\x0d\x00\x00\xff\xff\x60\xcd\x06\xbe\x4a\x00\x00\x00") func docGoBytes() ([]byte, error) { @@ -294,7 +315,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x7c, 0x28, 0xcd, 0x47, 0xf2, 0xfa, 0x7c, 0x51, 0x2d, 0xd8, 0x38, 0xb, 0xb0, 0x34, 0x9d, 0x4c, 0x62, 0xa, 0x9e, 0x28, 0xc3, 0x31, 0x23, 0xd9, 0xbb, 0x89, 0x9f, 0xa0, 0x89, 0x1f, 0xe8}} return a, nil } @@ -410,6 +431,8 @@ var _bindata = map[string]func() (*asset, error){ "1647862838_reset_last_backup.up.sql": _1647862838_reset_last_backupUpSql, + "1647871652_add_settings_sync_clock_table.up.sql": _1647871652_add_settings_sync_clock_tableUpSql, + "doc.go": docGo, } @@ -464,7 +487,8 @@ var _bintree = &bintree{nil, map[string]*bintree{ "1647860168_add_torrent_config.up.sql": &bintree{_1647860168_add_torrent_configUpSql, map[string]*bintree{}}, "1647862837_add_communities_settings_table.up.sql": &bintree{_1647862837_add_communities_settings_tableUpSql, map[string]*bintree{}}, "1647862838_reset_last_backup.up.sql": &bintree{_1647862838_reset_last_backupUpSql, map[string]*bintree{}}, - "doc.go": &bintree{docGo, map[string]*bintree{}}, + "1647871652_add_settings_sync_clock_table.up.sql": &bintree{_1647871652_add_settings_sync_clock_tableUpSql, map[string]*bintree{}}, + "doc.go": &bintree{docGo, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory. diff --git a/appdatabase/migrations/sql/1647871652_add_settings_sync_clock_table.up.sql b/appdatabase/migrations/sql/1647871652_add_settings_sync_clock_table.up.sql new file mode 100644 index 000000000..6267ed016 --- /dev/null +++ b/appdatabase/migrations/sql/1647871652_add_settings_sync_clock_table.up.sql @@ -0,0 +1,16 @@ +CREATE TABLE settings_sync_clock ( + currency INTEGER NOT NULL DEFAULT 0, + gif_recents INTEGER NOT NULL DEFAULT 0, + gif_favorites INTEGER NOT NULL DEFAULT 0, + messages_from_contacts_only INTEGER NOT NULL DEFAULT 0, + preferred_name INTEGER NOT NULL DEFAULT 0, + preview_privacy INTEGER NOT NULL DEFAULT 0, + profile_pictures_show_to INTEGER NOT NULL DEFAULT 0, + profile_pictures_visibility INTEGER NOT NULL DEFAULT 0, + send_status_updates INTEGER NOT NULL DEFAULT 0, + stickers_packs_installed INTEGER NOT NULL DEFAULT 0, + stickers_packs_pending INTEGER NOT NULL DEFAULT 0, + stickers_recent_stickers INTEGER NOT NULL DEFAULT 0, + synthetic_id VARCHAR DEFAULT 'id' PRIMARY KEY +) WITHOUT ROWID; +INSERT INTO settings_sync_clock (currency, gif_recents, gif_favorites, messages_from_contacts_only, preferred_name, preview_privacy, profile_pictures_show_to, profile_pictures_visibility, send_status_updates, stickers_packs_installed, stickers_packs_pending, stickers_recent_stickers) VALUES (0,0,0,0,0,0,0,0,0,0,0,0); \ No newline at end of file diff --git a/appdatabase/migrationsprevnodecfg/bindata.go b/appdatabase/migrationsprevnodecfg/bindata.go index 5362802b8..cbee9fc7c 100644 --- a/appdatabase/migrationsprevnodecfg/bindata.go +++ b/appdatabase/migrationsprevnodecfg/bindata.go @@ -137,7 +137,7 @@ func _0001_appDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0001_app.down.sql", size: 356, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0001_app.down.sql", size: 356, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb5, 0x25, 0xa0, 0xf8, 0x7d, 0x2d, 0xd, 0xcf, 0x18, 0xe4, 0x73, 0xc3, 0x95, 0xf5, 0x24, 0x20, 0xa9, 0xe6, 0x9e, 0x1d, 0x93, 0xe5, 0xc5, 0xad, 0x93, 0x8f, 0x5e, 0x40, 0xb5, 0x30, 0xaa, 0x25}} return a, nil } @@ -157,7 +157,7 @@ func _0001_appUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0001_app.up.sql", size: 2967, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0001_app.up.sql", size: 2967, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf7, 0x3a, 0xa7, 0xf2, 0x8f, 0xfa, 0x82, 0x7c, 0xc5, 0x49, 0xac, 0xac, 0xf, 0xc, 0x77, 0xe2, 0xba, 0xe8, 0x4d, 0xe, 0x6f, 0x5d, 0x2c, 0x2c, 0x18, 0x80, 0xc2, 0x1d, 0xe, 0x25, 0xe, 0x18}} return a, nil } @@ -177,7 +177,7 @@ func _0002_tokensDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0002_tokens.down.sql", size: 19, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0002_tokens.down.sql", size: 19, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd1, 0x31, 0x2, 0xcc, 0x2f, 0x38, 0x90, 0xf7, 0x58, 0x37, 0x47, 0xf4, 0x18, 0xf7, 0x72, 0x74, 0x67, 0x14, 0x7e, 0xf3, 0xb1, 0xd6, 0x5f, 0xb0, 0xd5, 0xe7, 0x91, 0xf4, 0x26, 0x77, 0x8e, 0x68}} return a, nil } @@ -197,7 +197,7 @@ func _0002_tokensUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0002_tokens.up.sql", size: 248, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0002_tokens.up.sql", size: 248, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xcc, 0xd6, 0xde, 0xd3, 0x7b, 0xee, 0x92, 0x11, 0x38, 0xa4, 0xeb, 0x84, 0xca, 0xcb, 0x37, 0x75, 0x5, 0x77, 0x7f, 0x14, 0x39, 0xee, 0xa1, 0x8b, 0xd4, 0x5c, 0x6e, 0x55, 0x6, 0x50, 0x16, 0xd4}} return a, nil } @@ -217,7 +217,7 @@ func _0003_settingsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0003_settings.down.sql", size: 118, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0003_settings.down.sql", size: 118, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe5, 0xa6, 0xf5, 0xc0, 0x60, 0x64, 0x77, 0xe2, 0xe7, 0x3c, 0x9b, 0xb1, 0x52, 0xa9, 0x95, 0x16, 0xf8, 0x60, 0x2f, 0xa5, 0xeb, 0x46, 0xb9, 0xb9, 0x8f, 0x4c, 0xf4, 0xfd, 0xbb, 0xe7, 0xe5, 0xe5}} return a, nil } @@ -237,7 +237,7 @@ func _0003_settingsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0003_settings.up.sql", size: 1311, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0003_settings.up.sql", size: 1311, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xea, 0x35, 0x0, 0xeb, 0xe2, 0x33, 0x68, 0xb9, 0xf4, 0xf6, 0x8e, 0x9e, 0x10, 0xe9, 0x58, 0x68, 0x28, 0xb, 0xcd, 0xec, 0x74, 0x71, 0xa7, 0x9a, 0x5a, 0x77, 0x59, 0xb1, 0x13, 0x1c, 0xa1, 0x5b}} return a, nil } @@ -257,7 +257,7 @@ func _0004_pending_stickersDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0004_pending_stickers.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0004_pending_stickers.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -277,7 +277,7 @@ func _0004_pending_stickersUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0004_pending_stickers.up.sql", size: 61, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0004_pending_stickers.up.sql", size: 61, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3c, 0xed, 0x25, 0xdf, 0x75, 0x2, 0x6c, 0xf0, 0xa2, 0xa8, 0x37, 0x62, 0x65, 0xad, 0xfd, 0x98, 0xa0, 0x9d, 0x63, 0x94, 0xdf, 0x6b, 0x46, 0xe0, 0x68, 0xec, 0x9c, 0x7f, 0x77, 0xdd, 0xb3, 0x6}} return a, nil } @@ -297,7 +297,7 @@ func _0005_waku_modeDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0005_waku_mode.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0005_waku_mode.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -317,7 +317,7 @@ func _0005_waku_modeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0005_waku_mode.up.sql", size: 146, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0005_waku_mode.up.sql", size: 146, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa6, 0x91, 0xc, 0xd7, 0x89, 0x61, 0x2e, 0x4c, 0x5a, 0xb6, 0x67, 0xd1, 0xc1, 0x42, 0x24, 0x38, 0xd6, 0x1b, 0x75, 0x41, 0x9c, 0x23, 0xb0, 0xca, 0x5c, 0xf1, 0x5c, 0xd0, 0x13, 0x92, 0x3e, 0xe1}} return a, nil } @@ -337,7 +337,7 @@ func _0006_appearanceUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0006_appearance.up.sql", size: 67, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0006_appearance.up.sql", size: 67, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xae, 0x6, 0x25, 0x6c, 0xe4, 0x9d, 0xa7, 0x72, 0xe8, 0xbc, 0xe4, 0x1f, 0x1e, 0x2d, 0x7c, 0xb7, 0xf6, 0xa3, 0xec, 0x3b, 0x4e, 0x93, 0x2e, 0xa4, 0xec, 0x6f, 0xe5, 0x95, 0x94, 0xe8, 0x4, 0xfb}} return a, nil } @@ -357,7 +357,7 @@ func _0007_enable_waku_defaultUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0007_enable_waku_default.up.sql", size: 38, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0007_enable_waku_default.up.sql", size: 38, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd4, 0x42, 0xb6, 0xe5, 0x48, 0x41, 0xeb, 0xc0, 0x7e, 0x3b, 0xe6, 0x8e, 0x96, 0x33, 0x20, 0x92, 0x24, 0x5a, 0x60, 0xfa, 0xa0, 0x3, 0x5e, 0x76, 0x4b, 0x89, 0xaa, 0x37, 0x66, 0xbc, 0x26, 0x11}} return a, nil } @@ -377,7 +377,7 @@ func _0008_add_push_notificationsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0008_add_push_notifications.up.sql", size: 349, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0008_add_push_notifications.up.sql", size: 349, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5a, 0x0, 0xbf, 0xd0, 0xdd, 0xcd, 0x73, 0xe0, 0x7c, 0x56, 0xef, 0xdc, 0x57, 0x61, 0x94, 0x64, 0x70, 0xb9, 0xfa, 0xa1, 0x2a, 0x36, 0xc, 0x2f, 0xf8, 0x95, 0xa, 0x57, 0x3e, 0x7a, 0xd7, 0x12}} return a, nil } @@ -397,7 +397,7 @@ func _0009_enable_sending_push_notificationsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0009_enable_sending_push_notifications.down.sql", size: 49, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0009_enable_sending_push_notifications.down.sql", size: 49, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe9, 0xae, 0x1b, 0x41, 0xcb, 0x9c, 0x2c, 0x93, 0xc6, 0x2a, 0x77, 0x3, 0xb9, 0x51, 0xe0, 0x68, 0x68, 0x0, 0xf7, 0x5b, 0xb3, 0x1e, 0x94, 0x44, 0xba, 0x9c, 0xd0, 0x3b, 0x80, 0x21, 0x6f, 0xb5}} return a, nil } @@ -417,7 +417,7 @@ func _0009_enable_sending_push_notificationsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0009_enable_sending_push_notifications.up.sql", size: 49, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0009_enable_sending_push_notifications.up.sql", size: 49, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1b, 0x80, 0xe4, 0x9c, 0xc8, 0xb8, 0xd5, 0xef, 0xce, 0x74, 0x9b, 0x7b, 0xdd, 0xa, 0x99, 0x1e, 0xef, 0x7f, 0xb8, 0x99, 0x84, 0x4, 0x0, 0x6b, 0x1d, 0x2c, 0xa, 0xf8, 0x2c, 0x4f, 0xb5, 0x44}} return a, nil } @@ -437,7 +437,7 @@ func _0010_add_block_mentionsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0010_add_block_mentions.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0010_add_block_mentions.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6d, 0x9e, 0x27, 0x1e, 0xba, 0x9f, 0xca, 0xae, 0x98, 0x2e, 0x6e, 0xe3, 0xdd, 0xac, 0x73, 0x34, 0x4e, 0x69, 0x92, 0xb5, 0xf6, 0x9, 0xab, 0x50, 0x35, 0xd, 0xee, 0xeb, 0x3e, 0xcc, 0x7e, 0xce}} return a, nil } @@ -457,7 +457,7 @@ func _0010_add_block_mentionsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0010_add_block_mentions.up.sql", size: 89, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0010_add_block_mentions.up.sql", size: 89, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd7, 0x23, 0x85, 0xa2, 0xb5, 0xb6, 0xb4, 0x3f, 0xdc, 0x4e, 0xff, 0xe2, 0x6b, 0x66, 0x68, 0x5e, 0xb2, 0xb4, 0x14, 0xb2, 0x1b, 0x4d, 0xb1, 0xce, 0xf7, 0x6, 0x58, 0xa7, 0xaf, 0x93, 0x3f, 0x25}} return a, nil } @@ -477,7 +477,7 @@ func _0011_allow_webview_permission_requestsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0011_allow_webview_permission_requests.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0011_allow_webview_permission_requests.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -497,7 +497,7 @@ func _0011_allow_webview_permission_requestsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0011_allow_webview_permission_requests.up.sql", size: 88, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0011_allow_webview_permission_requests.up.sql", size: 88, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x43, 0x5f, 0x22, 0x4c, 0x98, 0x1d, 0xc6, 0xf4, 0x89, 0xaf, 0xf4, 0x44, 0xba, 0xf8, 0x28, 0xa7, 0xb5, 0xb9, 0xf0, 0xf2, 0xcb, 0x5, 0x59, 0x7a, 0xc, 0xdf, 0xd3, 0x38, 0xa4, 0xb8, 0x98, 0xc2}} return a, nil } @@ -517,7 +517,7 @@ func _0012_pending_transactionsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0012_pending_transactions.down.sql", size: 33, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0012_pending_transactions.down.sql", size: 33, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7e, 0x41, 0xfe, 0x5c, 0xd8, 0xc3, 0x29, 0xfd, 0x31, 0x78, 0x99, 0x7a, 0xeb, 0x17, 0x62, 0x88, 0x41, 0xb3, 0xe7, 0xb5, 0x5, 0x0, 0x90, 0xa1, 0x7, 0x1a, 0x23, 0x88, 0x81, 0xba, 0x56, 0x9d}} return a, nil } @@ -537,7 +537,7 @@ func _0012_pending_transactionsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0012_pending_transactions.up.sql", size: 321, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0012_pending_transactions.up.sql", size: 321, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd, 0x17, 0xff, 0xd7, 0xa7, 0x49, 0x1e, 0x7b, 0x34, 0x63, 0x7c, 0x53, 0xaa, 0x6b, 0x2d, 0xc8, 0xe0, 0x82, 0x21, 0x90, 0x3a, 0x94, 0xf1, 0xa6, 0xe4, 0x70, 0xe5, 0x85, 0x1a, 0x48, 0x25, 0xb}} return a, nil } @@ -557,7 +557,7 @@ func _0013_favouritesDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0013_favourites.down.sql", size: 23, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0013_favourites.down.sql", size: 23, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x32, 0xf8, 0x55, 0x13, 0x4f, 0x4a, 0x19, 0x83, 0x9c, 0xda, 0x34, 0xb8, 0x3, 0x54, 0x82, 0x1e, 0x99, 0x36, 0x6b, 0x42, 0x3, 0xf6, 0x43, 0xde, 0xe6, 0x32, 0xb6, 0xdf, 0xe2, 0x59, 0x8c, 0x84}} return a, nil } @@ -577,7 +577,7 @@ func _0013_favouritesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0013_favourites.up.sql", size: 132, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0013_favourites.up.sql", size: 132, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbe, 0x1, 0x27, 0x38, 0x76, 0xf5, 0xcb, 0x61, 0xda, 0x5b, 0xce, 0xd9, 0x8b, 0x18, 0x77, 0x61, 0x84, 0xe7, 0x22, 0xe2, 0x13, 0x99, 0xab, 0x32, 0xbc, 0xbe, 0xed, 0x1f, 0x2f, 0xb0, 0xe4, 0x8d}} return a, nil } @@ -597,7 +597,7 @@ func _0014_add_use_mailserversDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0014_add_use_mailservers.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0014_add_use_mailservers.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -617,7 +617,7 @@ func _0014_add_use_mailserversUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0014_add_use_mailservers.up.sql", size: 111, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0014_add_use_mailservers.up.sql", size: 111, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc9, 0xba, 0x65, 0xbf, 0x1b, 0xc9, 0x6d, 0x45, 0xf2, 0xf5, 0x30, 0x7c, 0xc1, 0xde, 0xb8, 0xe3, 0x3f, 0xa9, 0x2f, 0x9f, 0xea, 0x1, 0x29, 0x29, 0x65, 0xe7, 0x38, 0xab, 0xa4, 0x62, 0xf, 0xd0}} return a, nil } @@ -637,7 +637,7 @@ func _0015_link_previewsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0015_link_previews.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0015_link_previews.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -657,7 +657,7 @@ func _0015_link_previewsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0015_link_previews.up.sql", size: 203, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0015_link_previews.up.sql", size: 203, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb1, 0xf7, 0x38, 0x25, 0xa6, 0xfc, 0x6b, 0x9, 0xe4, 0xd9, 0xbf, 0x58, 0x7b, 0x80, 0xd8, 0x48, 0x63, 0xde, 0xa5, 0x5e, 0x30, 0xa3, 0xeb, 0x68, 0x8e, 0x6a, 0x9f, 0xfd, 0xf4, 0x46, 0x41, 0x34}} return a, nil } @@ -677,7 +677,7 @@ func _0016_local_notifications_preferencesDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0016_local_notifications_preferences.down.sql", size: 43, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0016_local_notifications_preferences.down.sql", size: 43, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe0, 0x50, 0xc7, 0xdd, 0x53, 0x9c, 0x5d, 0x1e, 0xb5, 0x71, 0x25, 0x50, 0x58, 0xcf, 0x6d, 0xbe, 0x5a, 0x8, 0x12, 0xc9, 0x13, 0xd, 0x9a, 0x3d, 0x4b, 0x7a, 0x2f, 0x1b, 0xe5, 0x23, 0x52, 0x78}} return a, nil } @@ -697,7 +697,7 @@ func _0016_local_notifications_preferencesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0016_local_notifications_preferences.up.sql", size: 204, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0016_local_notifications_preferences.up.sql", size: 204, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3f, 0x3a, 0x16, 0x25, 0xdf, 0xba, 0x62, 0xd3, 0x81, 0x73, 0xc, 0x10, 0x85, 0xbc, 0x8d, 0xe, 0x1d, 0x62, 0xcb, 0xb, 0x6d, 0x8c, 0x4f, 0x63, 0x5f, 0xe2, 0xd, 0xc5, 0x46, 0xa8, 0x35, 0x5b}} return a, nil } @@ -717,7 +717,7 @@ func _0017_bookmarksDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0017_bookmarks.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0017_bookmarks.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9a, 0x13, 0x2a, 0x44, 0xb0, 0x3, 0x18, 0x63, 0xb8, 0x33, 0xda, 0x3a, 0xeb, 0xb8, 0xcb, 0xd1, 0x98, 0x29, 0xa7, 0xf0, 0x6, 0x9d, 0xc9, 0x62, 0xe7, 0x89, 0x7f, 0x77, 0xaf, 0xec, 0x6b, 0x8f}} return a, nil } @@ -737,7 +737,7 @@ func _0017_bookmarksUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0017_bookmarks.up.sql", size: 147, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0017_bookmarks.up.sql", size: 147, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbc, 0x47, 0xe1, 0xe3, 0xd8, 0xc6, 0x4, 0x6d, 0x5f, 0x2f, 0xa, 0x51, 0xa6, 0x8c, 0x6a, 0xe0, 0x3d, 0x8c, 0x91, 0x47, 0xbc, 0x1, 0x75, 0x46, 0x92, 0x2, 0x18, 0x6e, 0xe3, 0x4f, 0x18, 0x57}} return a, nil } @@ -757,7 +757,7 @@ func _0018_profile_pictures_visibilityUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0018_profile_pictures_visibility.up.sql", size: 84, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0018_profile_pictures_visibility.up.sql", size: 84, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc9, 0xe3, 0xc5, 0xec, 0x83, 0x55, 0x45, 0x57, 0x7a, 0xaa, 0xd2, 0xa7, 0x59, 0xa7, 0x87, 0xef, 0x63, 0x19, 0x9c, 0x46, 0x9c, 0xc5, 0x32, 0x89, 0xa4, 0x68, 0x70, 0xd8, 0x83, 0x43, 0xa4, 0x72}} return a, nil } @@ -777,7 +777,7 @@ func _0019_blocks_ranges_extra_dataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0019_blocks_ranges_extra_data.up.sql", size: 89, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0019_blocks_ranges_extra_data.up.sql", size: 89, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa3, 0x96, 0x32, 0x58, 0xf0, 0xb9, 0xe1, 0x70, 0x81, 0xca, 0x8d, 0x45, 0x57, 0x8a, 0x7, 0x5d, 0x9e, 0x2a, 0x30, 0xb, 0xad, 0x5f, 0xf8, 0xd4, 0x30, 0x94, 0x73, 0x37, 0x8d, 0xc1, 0x9a, 0xed}} return a, nil } @@ -797,7 +797,7 @@ func _0020_metricsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0020_metrics.up.sql", size: 235, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0020_metrics.up.sql", size: 235, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe8, 0x32, 0xbc, 0xb6, 0x9b, 0x5a, 0x8f, 0x9f, 0x4c, 0x90, 0x81, 0x3e, 0x2e, 0xd1, 0x23, 0xcd, 0xf1, 0x83, 0x35, 0xca, 0x66, 0x87, 0x52, 0x4e, 0x30, 0x3e, 0x4f, 0xa8, 0xfd, 0x30, 0x16, 0xbd}} return a, nil } @@ -817,7 +817,7 @@ func _0021_add_session_id_to_metricsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0021_add_session_id_to_metrics.up.sql", size: 55, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0021_add_session_id_to_metrics.up.sql", size: 55, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb7, 0x81, 0xfc, 0x97, 0xd1, 0x8b, 0xea, 0x8e, 0xd7, 0xc2, 0x53, 0x62, 0xe9, 0xbc, 0xf, 0x8c, 0x46, 0x41, 0x41, 0xb7, 0x6, 0x35, 0xf5, 0xba, 0xbb, 0x28, 0x50, 0x48, 0xbf, 0x36, 0x90, 0x5c}} return a, nil } @@ -837,7 +837,7 @@ func _0022_pending_transfersUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0022_pending_transfers.up.sql", size: 706, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "0022_pending_transfers.up.sql", size: 706, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6a, 0x9, 0xe6, 0x6, 0xae, 0x60, 0xdd, 0xbb, 0x76, 0xac, 0xe0, 0x57, 0x30, 0x67, 0x37, 0x93, 0x40, 0x13, 0xec, 0xf2, 0x6e, 0x61, 0xa, 0x14, 0xb2, 0xb1, 0xbd, 0x91, 0xf8, 0x89, 0xb3, 0xe3}} return a, nil } @@ -857,7 +857,7 @@ func _1618237885_settings_anon_metrics_should_sendUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1618237885_settings_anon_metrics_should_send.up.sql", size: 80, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1618237885_settings_anon_metrics_should_send.up.sql", size: 80, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xea, 0x6c, 0x1d, 0x1f, 0x54, 0x62, 0x18, 0x22, 0x5c, 0xa7, 0x8c, 0x59, 0x24, 0xd3, 0x4d, 0x55, 0xc4, 0x2a, 0x9e, 0x4c, 0x37, 0x6b, 0xfd, 0xac, 0xec, 0xb7, 0x68, 0x21, 0x26, 0x26, 0xf3, 0x92}} return a, nil } @@ -877,7 +877,7 @@ func _1618395756_contacts_onlyUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1618395756_contacts_only.up.sql", size: 136, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1618395756_contacts_only.up.sql", size: 136, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0xe3, 0xd0, 0xe7, 0xf2, 0x6e, 0xbf, 0x27, 0xf6, 0xe2, 0x2e, 0x16, 0x4b, 0x52, 0x3b, 0xcf, 0x63, 0x52, 0xfc, 0x1d, 0x43, 0xba, 0x42, 0xf9, 0x1e, 0x1e, 0x39, 0x40, 0xed, 0x0, 0x20, 0xa8}} return a, nil } @@ -897,7 +897,7 @@ func _1622184614_add_default_sync_periodUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1622184614_add_default_sync_period.up.sql", size: 125, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1622184614_add_default_sync_period.up.sql", size: 125, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x60, 0x39, 0xeb, 0x8f, 0xdc, 0x1, 0x56, 0xc1, 0x9b, 0xaa, 0xda, 0x44, 0xe0, 0xdb, 0xda, 0x2c, 0xe7, 0x71, 0x8d, 0xbc, 0xc1, 0x9a, 0x4f, 0x48, 0xe0, 0x5e, 0x81, 0x1e, 0x8e, 0x6a, 0x4d, 0x3}} return a, nil } @@ -917,7 +917,7 @@ func _1625872445_user_statusUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1625872445_user_status.up.sql", size: 351, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1625872445_user_status.up.sql", size: 351, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0xa, 0xfe, 0x7a, 0xcc, 0x9e, 0x35, 0x26, 0xb, 0xc8, 0xf2, 0x7d, 0xfa, 0x4b, 0xcf, 0x53, 0x20, 0x76, 0xc7, 0xd, 0xbc, 0x78, 0x4f, 0x74, 0x2d, 0x2e, 0x2e, 0x7e, 0x62, 0xae, 0x78, 0x1f}} return a, nil } @@ -937,7 +937,7 @@ func _1627983977_add_gif_to_settingsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1627983977_add_gif_to_settings.up.sql", size: 102, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1627983977_add_gif_to_settings.up.sql", size: 102, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x63, 0xe6, 0xe1, 0x97, 0x64, 0x4c, 0xe2, 0x14, 0xb1, 0x96, 0x3a, 0xb0, 0xb9, 0xb7, 0xb5, 0x78, 0x4a, 0x39, 0x69, 0x89, 0xb7, 0x89, 0x19, 0xb8, 0x89, 0x1, 0xc5, 0xc2, 0x85, 0x53, 0xe2, 0x83}} return a, nil } @@ -957,7 +957,7 @@ func _1628580203_add_hidden_accountUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1628580203_add_hidden_account.up.sql", size: 67, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1628580203_add_hidden_account.up.sql", size: 67, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xcb, 0x30, 0xf1, 0xd4, 0x60, 0xe2, 0x28, 0x14, 0xcb, 0x16, 0xb, 0x9, 0xea, 0x17, 0xa, 0x9e, 0x89, 0xa8, 0x32, 0x32, 0xf8, 0x4d, 0xa0, 0xe1, 0xe5, 0x79, 0xbd, 0x7d, 0x79, 0xe9, 0x4c, 0x9e}} return a, nil } @@ -977,7 +977,7 @@ func _1629123384_add_id_to_app_metricsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1629123384_add_id_to_app_metrics.up.sql", size: 589, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1629123384_add_id_to_app_metrics.up.sql", size: 589, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xdf, 0x66, 0xc0, 0x69, 0xb, 0xad, 0x49, 0x7c, 0x8c, 0x67, 0xb8, 0xd6, 0x8d, 0x5d, 0x86, 0x1f, 0xa4, 0x53, 0xf5, 0x8, 0x1, 0xfd, 0x38, 0x49, 0xee, 0x84, 0xc0, 0xd8, 0x17, 0x72, 0x3, 0xb3}} return a, nil } @@ -997,7 +997,7 @@ func _1630401853_add_opensea_enabled_to_settingsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1630401853_add_opensea_enabled_to_settings.up.sql", size: 70, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1630401853_add_opensea_enabled_to_settings.up.sql", size: 70, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6, 0x91, 0x86, 0x15, 0xc8, 0x99, 0xe3, 0xae, 0xa, 0x6e, 0x94, 0x48, 0x51, 0x5b, 0x18, 0xe0, 0xbc, 0xaf, 0x34, 0x75, 0x55, 0x61, 0xd4, 0xc1, 0x85, 0xc7, 0x3d, 0x99, 0x9e, 0x1f, 0x37, 0x56}} return a, nil } @@ -1017,7 +1017,7 @@ func _1630464455_createSaved_addressesTableDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1630464455_create-saved_addresses-table.down.sql", size: 28, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1630464455_create-saved_addresses-table.down.sql", size: 28, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x23, 0x52, 0x39, 0xb5, 0x42, 0xac, 0xcb, 0xa1, 0x44, 0xb7, 0x94, 0x26, 0x24, 0xb2, 0x12, 0xc, 0xc5, 0xbf, 0x63, 0x13, 0x6f, 0x3c, 0x4, 0x7b, 0xf0, 0xd, 0xfa, 0x55, 0x9e, 0x51, 0xf9, 0x7a}} return a, nil } @@ -1037,7 +1037,7 @@ func _1630464455_createSaved_addressesTableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1630464455_create-saved_addresses-table.up.sql", size: 187, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1630464455_create-saved_addresses-table.up.sql", size: 187, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x32, 0xf, 0x56, 0x18, 0xeb, 0x4e, 0xac, 0xd8, 0xd6, 0x91, 0xae, 0x83, 0xcf, 0x91, 0x9e, 0x4, 0x4b, 0x2, 0x1f, 0x6d, 0xba, 0xf6, 0x3, 0xf2, 0x98, 0x72, 0xf6, 0x91, 0x29, 0x96, 0x0, 0x35}} return a, nil } @@ -1057,7 +1057,7 @@ func _1630485153_networksDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1630485153_networks.down.sql", size: 21, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1630485153_networks.down.sql", size: 21, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xbb, 0x3e, 0x57, 0xb7, 0xf7, 0x8, 0xbd, 0xb5, 0xc2, 0xea, 0xc, 0x45, 0xb7, 0x7, 0x9, 0xca, 0xe7, 0x48, 0x7e, 0x56, 0x4e, 0x44, 0x78, 0x8e, 0xe3, 0x87, 0x63, 0xaf, 0x16, 0x3f, 0xf9, 0x71}} return a, nil } @@ -1077,7 +1077,7 @@ func _1630485153_networksUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1630485153_networks.up.sql", size: 394, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1630485153_networks.up.sql", size: 394, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xed, 0x9, 0x1d, 0x3, 0x86, 0xbd, 0xc5, 0xde, 0x3c, 0x1b, 0x40, 0x41, 0x7c, 0x61, 0x8, 0x80, 0x53, 0x87, 0x1b, 0x5a, 0x56, 0xd, 0x88, 0x1d, 0x60, 0x24, 0xce, 0x7b, 0x8f, 0xff, 0xaf, 0x36}} return a, nil } @@ -1097,7 +1097,7 @@ func _1632262444_profile_pictures_show_toUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1632262444_profile_pictures_show_to.up.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1632262444_profile_pictures_show_to.up.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc3, 0xa2, 0x5a, 0x94, 0xde, 0x86, 0x2a, 0x29, 0xf5, 0xb3, 0x36, 0xe7, 0x53, 0x81, 0x55, 0xc9, 0xb5, 0xc3, 0xf4, 0x8c, 0x65, 0x2c, 0x4c, 0x48, 0xfd, 0x3c, 0xb7, 0x14, 0xb4, 0xea, 0x7a, 0x13}} return a, nil } @@ -1117,7 +1117,7 @@ func _1635942153_add_telemetry_server_url_to_settingsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1635942153_add_telemetry_server_url_to_settings.up.sql", size: 128, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1635942153_add_telemetry_server_url_to_settings.up.sql", size: 128, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6e, 0x9b, 0x1d, 0x39, 0x9c, 0x8d, 0x50, 0x86, 0xdf, 0xe5, 0x81, 0x55, 0xdc, 0x31, 0xcd, 0xb7, 0xc7, 0x5a, 0x67, 0x3b, 0x21, 0x99, 0xa5, 0x74, 0xb8, 0xd3, 0x58, 0xae, 0x29, 0x68, 0x2a, 0x8d}} return a, nil } @@ -1137,7 +1137,7 @@ func _1635942154_add_backup_settingUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1635942154_add_backup_setting.up.sql", size: 287, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1635942154_add_backup_setting.up.sql", size: 287, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb7, 0xe7, 0xfb, 0x70, 0x80, 0x5, 0xb4, 0x7b, 0x67, 0x8, 0x6e, 0x5f, 0x45, 0x17, 0xd9, 0x5f, 0x18, 0x66, 0x2f, 0x8a, 0x4f, 0xd4, 0x15, 0xe5, 0x2b, 0xbb, 0x25, 0x7a, 0x30, 0xad, 0x4c, 0x1a}} return a, nil } @@ -1157,7 +1157,7 @@ func _1637745568_add_auto_message_settingUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1637745568_add_auto_message_setting.up.sql", size: 122, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1637745568_add_auto_message_setting.up.sql", size: 122, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1d, 0xd8, 0xd2, 0xc2, 0x3a, 0xd7, 0xf1, 0x96, 0x6a, 0x35, 0xe5, 0x5c, 0xb9, 0xed, 0x4b, 0xf2, 0x5f, 0x80, 0x43, 0xca, 0x40, 0x57, 0x7e, 0xd7, 0x41, 0x9f, 0x70, 0x9f, 0xaf, 0x2a, 0xfc, 0x8f}} return a, nil } @@ -1177,7 +1177,7 @@ func _1640111208_nodeconfigUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1640111208_nodeconfig.up.sql", size: 7659, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "1640111208_nodeconfig.up.sql", size: 7659, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8e, 0x5a, 0xc6, 0xed, 0x6, 0xcb, 0x51, 0x8b, 0x78, 0xe9, 0x10, 0x37, 0xd1, 0xad, 0x9b, 0x76, 0x9a, 0xb9, 0x72, 0x85, 0xe7, 0x8a, 0x7f, 0xf0, 0x81, 0xf8, 0x33, 0x59, 0x67, 0x8e, 0xeb, 0xb1}} return a, nil } @@ -1197,7 +1197,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 85, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "doc.go", size: 85, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe5, 0xd2, 0xea, 0xc5, 0xd, 0xc4, 0x7f, 0x95, 0x8e, 0xd5, 0xf5, 0x96, 0xf2, 0x1b, 0xcb, 0xc7, 0xc2, 0x46, 0x1, 0x78, 0x1d, 0x5d, 0x59, 0x19, 0x99, 0xdd, 0x5b, 0xf5, 0x63, 0xa5, 0x25, 0xb8}} return a, nil } diff --git a/appdatabase/test_helpers.go b/appdatabase/test_helpers.go new file mode 100644 index 000000000..09f32e68c --- /dev/null +++ b/appdatabase/test_helpers.go @@ -0,0 +1,38 @@ +package appdatabase + +import ( + "database/sql" + "io/ioutil" + "os" + + "github.com/status-im/status-go/protocol/sqlite" +) + +// SetupTestSQLDB creates a temporary sqlite database file, initialises and then returns with a teardown func +func SetupTestSQLDB(prefix string) (*sql.DB, func() error, error) { + tmpfile, err := ioutil.TempFile("", prefix) + if err != nil { + return nil, nil, err + } + db, err := InitializeDB(tmpfile.Name(), prefix) + if err != nil { + return nil, nil, err + } + + return db, func() error { + err := db.Close() + if err != nil { + return err + } + return os.Remove(tmpfile.Name()) + }, nil +} + +func SetupTestMemorySQLDB(prefix string) (*sql.DB, error) { + db, err := InitializeDB(sqlite.InMemoryPath, prefix) + if err != nil { + return nil, err + } + + return db, nil +} diff --git a/cmd/ping-community/main.go b/cmd/ping-community/main.go index 376113d68..ca2964c9a 100644 --- a/cmd/ping-community/main.go +++ b/cmd/ping-community/main.go @@ -9,7 +9,6 @@ import ( "os" "path/filepath" "runtime" - "strings" "time" @@ -23,6 +22,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/logutils" "github.com/status-im/status-go/params" @@ -262,10 +262,10 @@ const pathDefaultWallet = pathWalletRoot + "/0" var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWallet} -func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*accounts.Settings, error) { +func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) { chatKeyString := derivedAddresses[pathDefaultChat].PublicKey - settings := &accounts.Settings{} + settings := &settings.Settings{} settings.KeyUID = generatedAccountInfo.KeyUID settings.Address = types.HexToAddress(generatedAccountInfo.Address) settings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address) diff --git a/cmd/populate-db/main.go b/cmd/populate-db/main.go index 4ace380e0..2d3b6e921 100644 --- a/cmd/populate-db/main.go +++ b/cmd/populate-db/main.go @@ -10,7 +10,6 @@ import ( "os" "path/filepath" "runtime" - "strings" "time" @@ -21,14 +20,12 @@ import ( "github.com/status-im/status-go/account/generator" "github.com/status-im/status-go/api" + "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/logutils" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" - - //"github.com/status-im/status-go/appdatabase" - //gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" - "github.com/status-im/status-go/eth-node/crypto" - "github.com/status-im/status-go/logutils" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol" "github.com/status-im/status-go/protocol/common" @@ -313,10 +310,10 @@ const pathDefaultWallet = pathWalletRoot + "/0" var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWallet} -func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*accounts.Settings, error) { +func defaultSettings(generatedAccountInfo generator.GeneratedAccountInfo, derivedAddresses map[string]generator.AccountInfo, mnemonic *string) (*settings.Settings, error) { chatKeyString := derivedAddresses[pathDefaultChat].PublicKey - settings := &accounts.Settings{} + settings := &settings.Settings{} settings.KeyUID = generatedAccountInfo.KeyUID settings.Address = types.HexToAddress(generatedAccountInfo.Address) settings.WalletRootAddress = types.HexToAddress(derivedAddresses[pathWalletRoot].Address) diff --git a/mailserver/migrations/bindata.go b/mailserver/migrations/bindata.go index deebe082d..4334db7ab 100644 --- a/mailserver/migrations/bindata.go +++ b/mailserver/migrations/bindata.go @@ -86,7 +86,7 @@ func _1557732988_initialize_dbDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1557732988_initialize_db.down.sql", size: 72, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "1557732988_initialize_db.down.sql", size: 72, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x77, 0x40, 0x78, 0xb7, 0x71, 0x3c, 0x20, 0x3b, 0xc9, 0xb, 0x2f, 0x49, 0xe4, 0xff, 0x1c, 0x84, 0x54, 0xa1, 0x30, 0xe3, 0x90, 0xf8, 0x73, 0xda, 0xb0, 0x2a, 0xea, 0x8e, 0xf1, 0x82, 0xe7, 0xd2}} return a, nil } @@ -106,7 +106,7 @@ func _1557732988_initialize_dbUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1557732988_initialize_db.up.sql", size: 278, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1557732988_initialize_db.up.sql", size: 278, mode: os.FileMode(0644), modTime: time.Unix(1633078517, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x85, 0x41, 0x7a, 0xba, 0x4f, 0xa3, 0x43, 0xc0, 0x63, 0xfa, 0x2c, 0xd1, 0xc5, 0xbb, 0x20, 0xa0, 0x64, 0xa8, 0x3b, 0x65, 0x82, 0xa2, 0x14, 0x28, 0x18, 0x7c, 0x8b, 0x3a, 0x7a, 0xfd, 0xe0}} return a, nil } @@ -126,7 +126,7 @@ func staticGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "static.go", size: 178, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "static.go", size: 178, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xab, 0x8a, 0xf4, 0x27, 0x24, 0x9d, 0x2a, 0x1, 0x7b, 0x54, 0xea, 0xae, 0x4a, 0x35, 0x40, 0x92, 0xb5, 0xf9, 0xb3, 0x54, 0x3e, 0x3a, 0x1a, 0x2b, 0xae, 0xfb, 0x9e, 0x82, 0xeb, 0x4c, 0xf, 0x6}} return a, nil } diff --git a/mobile/status.go b/mobile/status.go index 052e396ba..ed656f264 100644 --- a/mobile/status.go +++ b/mobile/status.go @@ -23,6 +23,7 @@ import ( "github.com/status-im/status-go/extkeys" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/profiling" protocol "github.com/status-im/status-go/protocol" @@ -261,7 +262,7 @@ func SaveAccountAndLogin(accountData, password, settingsJSON, configJSON, subacc if err != nil { return makeJSONResponse(err) } - var settings accounts.Settings + var settings settings.Settings err = json.Unmarshal([]byte(settingsJSON), &settings) if err != nil { return makeJSONResponse(err) @@ -322,7 +323,7 @@ func SaveAccountAndLoginWithKeycard(accountData, password, settingsJSON, configJ if err != nil { return makeJSONResponse(err) } - var settings accounts.Settings + var settings settings.Settings err = json.Unmarshal([]byte(settingsJSON), &settings) if err != nil { return makeJSONResponse(err) @@ -733,7 +734,7 @@ func ConvertToKeycardAccount(keyStoreDir, accountData, settingsJSON, password, n if err != nil { return makeJSONResponse(err) } - var settings accounts.Settings + var settings settings.Settings err = json.Unmarshal([]byte(settingsJSON), &settings) if err != nil { return makeJSONResponse(err) diff --git a/multiaccounts/accounts/database.go b/multiaccounts/accounts/database.go index 87c5a39d7..d147e4d9b 100644 --- a/multiaccounts/accounts/database.go +++ b/multiaccounts/accounts/database.go @@ -1,15 +1,11 @@ package accounts import ( - "context" "database/sql" - "encoding/json" - "errors" "github.com/status-im/status-go/eth-node/types" - "github.com/status-im/status-go/nodecfg" - "github.com/status-im/status-go/params" - "github.com/status-im/status-go/sqlite" + "github.com/status-im/status-go/multiaccounts/errors" + "github.com/status-im/status-go/multiaccounts/settings" ) const ( @@ -17,31 +13,6 @@ const ( uniqueWalletConstraint = "UNIQUE constraint failed: accounts.wallet" ) -type ProfilePicturesVisibilityType int - -const ( - ProfilePicturesVisibilityContactsOnly ProfilePicturesVisibilityType = iota + 1 - ProfilePicturesVisibilityEveryone - ProfilePicturesVisibilityNone -) - -type ProfilePicturesShowToType int - -const ( - ProfilePicturesShowToContactsOnly ProfilePicturesShowToType = iota + 1 - ProfilePicturesShowToEveryone - ProfilePicturesShowToNone -) - -var ( - // ErrWalletNotUnique returned if another account has `wallet` field set to true. - ErrWalletNotUnique = errors.New("another account is set to be default wallet. disable it before using new") - // ErrChatNotUnique returned if another account has `chat` field set to true. - ErrChatNotUnique = errors.New("another account is set to be default chat. disable it before using new") - // ErrInvalidConfig returned if config isn't allowed - ErrInvalidConfig = errors.New("configuration value not allowed") -) - type Account struct { Address types.Address `json:"address"` Wallet bool `json:"wallet"` @@ -70,93 +41,23 @@ func (a *Account) IsOwnAccount() bool { return a.Wallet || a.Type == accountTypeSeed || a.Type == accountTypeGenerated || a.Type == accountTypeKey } -type Settings struct { - // required - Address types.Address `json:"address"` - AnonMetricsShouldSend bool `json:"anon-metrics/should-send?,omitempty"` - ChaosMode bool `json:"chaos-mode?,omitempty"` - Currency string `json:"currency,omitempty"` - CurrentNetwork string `json:"networks/current-network"` - CustomBootnodes *json.RawMessage `json:"custom-bootnodes,omitempty"` - CustomBootnodesEnabled *json.RawMessage `json:"custom-bootnodes-enabled?,omitempty"` - DappsAddress types.Address `json:"dapps-address"` - DisplayName string `json:"display-name"` - EIP1581Address types.Address `json:"eip1581-address"` - Fleet *string `json:"fleet,omitempty"` - HideHomeTooltip bool `json:"hide-home-tooltip?,omitempty"` - InstallationID string `json:"installation-id"` - KeyUID string `json:"key-uid"` - KeycardInstanceUID string `json:"keycard-instance-uid,omitempty"` - KeycardPAiredOn int64 `json:"keycard-paired-on,omitempty"` - KeycardPairing string `json:"keycard-pairing,omitempty"` - LastUpdated *int64 `json:"last-updated,omitempty"` - LatestDerivedPath uint `json:"latest-derived-path"` - LinkPreviewRequestEnabled bool `json:"link-preview-request-enabled,omitempty"` - LinkPreviewsEnabledSites *json.RawMessage `json:"link-previews-enabled-sites,omitempty"` - LogLevel *string `json:"log-level,omitempty"` - MessagesFromContactsOnly bool `json:"messages-from-contacts-only"` - Mnemonic *string `json:"mnemonic,omitempty"` - Name string `json:"name,omitempty"` - Networks *json.RawMessage `json:"networks/networks"` - // NotificationsEnabled indicates whether local notifications should be enabled (android only) - NotificationsEnabled bool `json:"notifications-enabled?,omitempty"` - PhotoPath string `json:"photo-path"` - PinnedMailserver *json.RawMessage `json:"pinned-mailservers,omitempty"` - PreferredName *string `json:"preferred-name,omitempty"` - PreviewPrivacy bool `json:"preview-privacy?"` - PublicKey string `json:"public-key"` - // PushNotificationsServerEnabled indicates whether we should be running a push notification server - PushNotificationsServerEnabled bool `json:"push-notifications-server-enabled?,omitempty"` - // PushNotificationsFromContactsOnly indicates whether we should only receive push notifications from contacts - PushNotificationsFromContactsOnly bool `json:"push-notifications-from-contacts-only?,omitempty"` - // PushNotificationsBlockMentions indicates whether we should receive notifications for mentions - PushNotificationsBlockMentions bool `json:"push-notifications-block-mentions?,omitempty"` - RememberSyncingChoice bool `json:"remember-syncing-choice?,omitempty"` - // RemotePushNotificationsEnabled indicates whether we should be using remote notifications (ios only for now) - RemotePushNotificationsEnabled bool `json:"remote-push-notifications-enabled?,omitempty"` - SigningPhrase string `json:"signing-phrase"` - StickerPacksInstalled *json.RawMessage `json:"stickers/packs-installed,omitempty"` - StickerPacksPending *json.RawMessage `json:"stickers/packs-pending,omitempty"` - StickersRecentStickers *json.RawMessage `json:"stickers/recent-stickers,omitempty"` - SyncingOnMobileNetwork bool `json:"syncing-on-mobile-network?,omitempty"` - // DefaultSyncPeriod is how far back in seconds we should pull messages from a mailserver - DefaultSyncPeriod uint `json:"default-sync-period"` - // SendPushNotifications indicates whether we should send push notifications for other clients - SendPushNotifications bool `json:"send-push-notifications?,omitempty"` - Appearance uint `json:"appearance"` - // ProfilePicturesShowTo indicates to whom the user shows their profile picture to (contacts, everyone) - ProfilePicturesShowTo ProfilePicturesShowToType `json:"profile-pictures-show-to"` - // ProfilePicturesVisibility indicates who we want to see profile pictures of (contacts, everyone or none) - ProfilePicturesVisibility ProfilePicturesVisibilityType `json:"profile-pictures-visibility"` - UseMailservers bool `json:"use-mailservers?"` - Usernames *json.RawMessage `json:"usernames,omitempty"` - WalletRootAddress types.Address `json:"wallet-root-address,omitempty"` - WalletSetUpPassed bool `json:"wallet-set-up-passed?,omitempty"` - WalletVisibleTokens *json.RawMessage `json:"wallet/visible-tokens,omitempty"` - WakuBloomFilterMode bool `json:"waku-bloom-filter-mode,omitempty"` - WebViewAllowPermissionRequests bool `json:"webview-allow-permission-requests?,omitempty"` - SendStatusUpdates bool `json:"send-status-updates?,omitempty"` - CurrentUserStatus *json.RawMessage `json:"current-user-status"` - GifRecents *json.RawMessage `json:"gifs/recent-gifs"` - GifFavorites *json.RawMessage `json:"gifs/favorite-gifs"` - OpenseaEnabled bool `json:"opensea-enabled?,omitempty"` - TelemetryServerURL string `json:"telemetry-server-url,omitempty"` - LastBackup uint64 `json:"last-backup,omitempty"` - BackupEnabled bool `json:"backup-enabled?,omitempty"` - AutoMessageEnabled bool `json:"auto-message-enabled?,omitempty"` - GifAPIKey string `json:"gifs/api-key"` -} - -func NewDB(db *sql.DB) *Database { - return &Database{db: db} -} - // Database sql wrapper for operations with browser objects. type Database struct { + *settings.Database db *sql.DB } -// Get database +// NewDB returns a new instance of *Database +func NewDB(db *sql.DB) (*Database, error) { + sDB, err := settings.MakeNewDB(db) + if err != nil { + return nil, err + } + + return &Database{sDB, db}, nil +} + +// DB Gets db sql.DB func (db Database) DB() *sql.DB { return db.db } @@ -166,416 +67,6 @@ func (db Database) Close() error { return db.db.Close() } -// TODO remove photoPath from settings -func (db *Database) CreateSettings(s Settings, n params.NodeConfig) error { - tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) - if err != nil { - return err - } - - defer func() { - if err == nil { - err = tx.Commit() - return - } - // don't shadow original error - _ = tx.Rollback() - }() - - _, err = tx.Exec(` -INSERT INTO settings ( - address, - currency, - current_network, - dapps_address, - display_name, - eip1581_address, - installation_id, - key_uid, - keycard_instance_uid, - keycard_paired_on, - keycard_pairing, - latest_derived_path, - mnemonic, - name, - networks, - photo_path, - preview_privacy, - public_key, - signing_phrase, - wallet_root_address, - synthetic_id -) VALUES ( -?,?,?,?,?,?,?,?,?,?,?, -?,?,?,?,?,?,?,?,?,'id')`, - s.Address, - s.Currency, - s.CurrentNetwork, - s.DappsAddress, - s.DisplayName, - s.EIP1581Address, - s.InstallationID, - s.KeyUID, - s.KeycardInstanceUID, - s.KeycardPAiredOn, - s.KeycardPairing, - s.LatestDerivedPath, - s.Mnemonic, - s.Name, - s.Networks, - s.PhotoPath, - s.PreviewPrivacy, - s.PublicKey, - s.SigningPhrase, - s.WalletRootAddress, - ) - if err != nil { - return err - } - - return nodecfg.SaveConfigWithTx(tx, &n) -} - -func (db *Database) SaveSetting(setting string, value interface{}) error { - var ( - update *sql.Stmt - err error - ) - - switch setting { - case "chaos-mode?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET chaos_mode = ? WHERE synthetic_id = 'id'") - case "currency": - update, err = db.db.Prepare("UPDATE settings SET currency = ? WHERE synthetic_id = 'id'") - case "custom-bootnodes": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET custom_bootnodes = ? WHERE synthetic_id = 'id'") - case "custom-bootnodes-enabled?": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET custom_bootnodes_enabled = ? WHERE synthetic_id = 'id'") - case "dapps-address": - str, ok := value.(string) - if ok { - value = types.HexToAddress(str) - } else { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET dapps_address = ? WHERE synthetic_id = 'id'") - case "display-name": - update, err = db.db.Prepare("UPDATE settings SET display_name = ? WHERE synthetic_id = 'id'") - case "eip1581-address": - str, ok := value.(string) - if ok { - value = types.HexToAddress(str) - } else { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET eip1581_address = ? WHERE synthetic_id = 'id'") - case "fleet": - update, err = db.db.Prepare("UPDATE settings SET fleet = ? WHERE synthetic_id = 'id'") - case "hide-home-tooltip?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET hide_home_tooltip = ? WHERE synthetic_id = 'id'") - case "messages-from-contacts-only": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET messages_from_contacts_only = ? WHERE synthetic_id = 'id'") - case "keycard-instance_uid": - update, err = db.db.Prepare("UPDATE settings SET keycard_instance_uid = ? WHERE synthetic_id = 'id'") - case "keycard-paired_on": - update, err = db.db.Prepare("UPDATE settings SET keycard_paired_on = ? WHERE synthetic_id = 'id'") - case "keycard-pairing": - update, err = db.db.Prepare("UPDATE settings SET keycard_pairing = ? WHERE synthetic_id = 'id'") - case "last-updated": - update, err = db.db.Prepare("UPDATE settings SET last_updated = ? WHERE synthetic_id = 'id'") - case "latest-derived-path": - update, err = db.db.Prepare("UPDATE settings SET latest_derived_path = ? WHERE synthetic_id = 'id'") - case "link-preview-request-enabled": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET link_preview_request_enabled = ? WHERE synthetic_id = 'id'") - case "link-previews-enabled-sites": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET link_previews_enabled_sites = ? WHERE synthetic_id = 'id'") - case "log-level": - update, err = db.db.Prepare("UPDATE settings SET log_level = ? WHERE synthetic_id = 'id'") - case "mnemonic": - update, err = db.db.Prepare("UPDATE settings SET mnemonic = ? WHERE synthetic_id = 'id'") - case "name": - update, err = db.db.Prepare("UPDATE settings SET name = ? WHERE synthetic_id = 'id'") - case "networks/current-network": - update, err = db.db.Prepare("UPDATE settings SET current_network = ? WHERE synthetic_id = 'id'") - case "networks/networks": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET networks = ? WHERE synthetic_id = 'id'") - case "node-config": - var jsonString []byte - jsonString, err = json.Marshal(value) - if err != nil { - return err - } - var nodeConfig params.NodeConfig - err = json.Unmarshal(jsonString, &nodeConfig) - if err != nil { - return err - } - if err = nodecfg.SaveNodeConfig(db.db, &nodeConfig); err != nil { - return err - } - value = nil - update, err = db.db.Prepare("UPDATE settings SET node_config = ? WHERE synthetic_id = 'id'") - case "notifications-enabled?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET notifications_enabled = ? WHERE synthetic_id = 'id'") - case "photo-path": - update, err = db.db.Prepare("UPDATE settings SET photo_path = ? WHERE synthetic_id = 'id'") - case "pinned-mailservers": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET pinned_mailservers = ? WHERE synthetic_id = 'id'") - case "preferred-name": - update, err = db.db.Prepare("UPDATE settings SET preferred_name = ? WHERE synthetic_id = 'id'") - case "preview-privacy?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET preview_privacy = ? WHERE synthetic_id = 'id'") - case "public-key": - update, err = db.db.Prepare("UPDATE settings SET public_key = ? WHERE synthetic_id = 'id'") - case "remember-syncing-choice?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET remember_syncing_choice = ? WHERE synthetic_id = 'id'") - case "remote-push-notifications-enabled?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET remote_push_notifications_enabled = ? WHERE synthetic_id = 'id'") - case "push-notifications-server-enabled?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET push_notifications_server_enabled = ? WHERE synthetic_id = 'id'") - case "push-notifications-from-contacts-only?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET push_notifications_from_contacts_only = ? WHERE synthetic_id = 'id'") - case "push-notifications-block-mentions?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET push_notifications_block_mentions = ? WHERE synthetic_id = 'id'") - case "send-push-notifications?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET send_push_notifications = ? WHERE synthetic_id = 'id'") - case "stickers/packs-installed": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET stickers_packs_installed = ? WHERE synthetic_id = 'id'") - case "stickers/packs-pending": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET stickers_packs_pending = ? WHERE synthetic_id = 'id'") - case "stickers/recent-stickers": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET stickers_recent_stickers = ? WHERE synthetic_id = 'id'") - case "syncing-on-mobile-network?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET syncing_on_mobile_network = ? WHERE synthetic_id = 'id'") - case "use-mailservers?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET use_mailservers = ? WHERE synthetic_id = 'id'") - case "default-sync-period": - update, err = db.db.Prepare("UPDATE settings SET default_sync_period = ? WHERE synthetic_id = 'id'") - case "usernames": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET usernames = ? WHERE synthetic_id = 'id'") - case "wallet-set-up-passed?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET wallet_set_up_passed = ? WHERE synthetic_id = 'id'") - case "wallet/visible-tokens": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET wallet_visible_tokens = ? WHERE synthetic_id = 'id'") - case "appearance": - update, err = db.db.Prepare("UPDATE settings SET appearance = ? WHERE synthetic_id = 'id'") - case "profile-pictures-show-to": - update, err = db.db.Prepare("UPDATE settings SET profile_pictures_show_to = ? WHERE synthetic_id = 'id'") - case "profile-pictures-visibility": - update, err = db.db.Prepare("UPDATE settings SET profile_pictures_visibility = ? WHERE synthetic_id = 'id'") - case "waku-bloom-filter-mode": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET waku_bloom_filter_mode = ? WHERE synthetic_id = 'id'") - case "webview-allow-permission-requests?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET webview_allow_permission_requests = ? WHERE synthetic_id = 'id'") - case "anon-metrics/should-send?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET anon_metrics_should_send = ? WHERE synthetic_id = 'id'") - case "current-user-status": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET current_user_status = ? WHERE synthetic_id = 'id'") - case "send-status-updates?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET send_status_updates = ? WHERE synthetic_id = 'id'") - case "gifs/recent-gifs": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET gif_recents = ? WHERE synthetic_id = 'id'") - case "gifs/favorite-gifs": - value = &sqlite.JSONBlob{Data: value} - update, err = db.db.Prepare("UPDATE settings SET gif_favorites = ? WHERE synthetic_id = 'id'") - case "opensea-enabled?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET opensea_enabled = ? WHERE synthetic_id = 'id'") - case "telemetry-server-url": - update, err = db.db.Prepare("UPDATE settings SET telemetry_server_url = ? WHERE synthetic_id = 'id'") - case "backup-enabled?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET backup_enabled = ? WHERE synthetic_id = 'id'") - case "auto-message-enabled?": - _, ok := value.(bool) - if !ok { - return ErrInvalidConfig - } - - update, err = db.db.Prepare("UPDATE settings SET auto_message_enabled = ? WHERE synthetic_id = 'id'") - case "gifs/api-key": - _, ok := value.(string) - if !ok { - return ErrInvalidConfig - } - update, err = db.db.Prepare("UPDATE settings SET gif_api_key = ? WHERE synthetic_id = 'id'") - default: - return ErrInvalidConfig - } - if err != nil { - return err - } - - _, err = update.Exec(value) - return err -} - -func (db *Database) GetSettings() (Settings, error) { - var s Settings - err := db.db.QueryRow("SELECT address, anon_metrics_should_send, chaos_mode, currency, current_network, custom_bootnodes, custom_bootnodes_enabled, dapps_address, display_name, eip1581_address, fleet, hide_home_tooltip, installation_id, key_uid, keycard_instance_uid, keycard_paired_on, keycard_pairing, last_updated, latest_derived_path, link_preview_request_enabled, link_previews_enabled_sites, log_level, mnemonic, name, networks, notifications_enabled, push_notifications_server_enabled, push_notifications_from_contacts_only, remote_push_notifications_enabled, send_push_notifications, push_notifications_block_mentions, photo_path, pinned_mailservers, preferred_name, preview_privacy, public_key, remember_syncing_choice, signing_phrase, stickers_packs_installed, stickers_packs_pending, stickers_recent_stickers, syncing_on_mobile_network, default_sync_period, use_mailservers, messages_from_contacts_only, usernames, appearance, profile_pictures_show_to, profile_pictures_visibility, wallet_root_address, wallet_set_up_passed, wallet_visible_tokens, waku_bloom_filter_mode, webview_allow_permission_requests, current_user_status, send_status_updates, gif_recents, gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key FROM settings WHERE synthetic_id = 'id'").Scan( - &s.Address, - &s.AnonMetricsShouldSend, - &s.ChaosMode, - &s.Currency, - &s.CurrentNetwork, - &s.CustomBootnodes, - &s.CustomBootnodesEnabled, - &s.DappsAddress, - &s.DisplayName, - &s.EIP1581Address, - &s.Fleet, - &s.HideHomeTooltip, - &s.InstallationID, - &s.KeyUID, - &s.KeycardInstanceUID, - &s.KeycardPAiredOn, - &s.KeycardPairing, - &s.LastUpdated, - &s.LatestDerivedPath, - &s.LinkPreviewRequestEnabled, - &s.LinkPreviewsEnabledSites, - &s.LogLevel, - &s.Mnemonic, - &s.Name, - &s.Networks, - &s.NotificationsEnabled, - &s.PushNotificationsServerEnabled, - &s.PushNotificationsFromContactsOnly, - &s.RemotePushNotificationsEnabled, - &s.SendPushNotifications, - &s.PushNotificationsBlockMentions, - &s.PhotoPath, - &s.PinnedMailserver, - &s.PreferredName, - &s.PreviewPrivacy, - &s.PublicKey, - &s.RememberSyncingChoice, - &s.SigningPhrase, - &s.StickerPacksInstalled, - &s.StickerPacksPending, - &s.StickersRecentStickers, - &s.SyncingOnMobileNetwork, - &s.DefaultSyncPeriod, - &s.UseMailservers, - &s.MessagesFromContactsOnly, - &s.Usernames, - &s.Appearance, - &s.ProfilePicturesShowTo, - &s.ProfilePicturesVisibility, - &s.WalletRootAddress, - &s.WalletSetUpPassed, - &s.WalletVisibleTokens, - &s.WakuBloomFilterMode, - &s.WebViewAllowPermissionRequests, - &sqlite.JSONBlob{Data: &s.CurrentUserStatus}, - &s.SendStatusUpdates, - &sqlite.JSONBlob{Data: &s.GifRecents}, - &sqlite.JSONBlob{Data: &s.GifFavorites}, - &s.OpenseaEnabled, - &s.LastBackup, - &s.BackupEnabled, - &s.TelemetryServerURL, - &s.AutoMessageEnabled, - &s.GifAPIKey, - ) - - return s, err -} - func (db *Database) GetAccounts() ([]Account, error) { rows, err := db.db.Query("SELECT address, wallet, chat, type, storage, pubkey, path, name, emoji, color, hidden FROM accounts ORDER BY created_at") if err != nil { @@ -654,9 +145,9 @@ func (db *Database) SaveAccounts(accounts []Account) (err error) { if err != nil { switch err.Error() { case uniqueChatConstraint: - err = ErrChatNotUnique + err = errors.ErrChatNotUnique case uniqueWalletConstraint: - err = ErrWalletNotUnique + err = errors.ErrWalletNotUnique } return } @@ -674,137 +165,6 @@ func (db *Database) DeleteSeedAndKeyAccounts() error { return err } -func (db *Database) GetNotificationsEnabled() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT notifications_enabled FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return result, nil - } - return result, err -} - -func (db *Database) GetProfilePicturesVisibility() (int, error) { - var result int - err := db.db.QueryRow("SELECT profile_pictures_visibility FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return result, nil - } - return result, err -} - -func (db *Database) GetPublicKey() (rst string, err error) { - err = db.db.QueryRow("SELECT public_key FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - if err == sql.ErrNoRows { - return rst, nil - } - return -} - -func (db *Database) GetPreferredUsername() (rst string, err error) { - err = db.db.QueryRow("SELECT preferred_name FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - if err == sql.ErrNoRows { - return rst, nil - } - return -} - -func (db *Database) GetFleet() (rst string, err error) { - err = db.db.QueryRow("SELECT COALESCE(fleet, '') FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - if err == sql.ErrNoRows { - return rst, nil - } - return -} - -func (db *Database) GetDappsAddress() (rst types.Address, err error) { - err = db.db.QueryRow("SELECT dapps_address FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - if err == sql.ErrNoRows { - return rst, nil - } - return -} - -func (db *Database) GetPinnedMailservers() (rst map[string]string, err error) { - rst = make(map[string]string) - var pinnedMailservers string - err = db.db.QueryRow("SELECT COALESCE(pinned_mailservers, '') FROM settings WHERE synthetic_id = 'id'").Scan(&pinnedMailservers) - if err == sql.ErrNoRows || pinnedMailservers == "" { - return rst, nil - } - - err = json.Unmarshal([]byte(pinnedMailservers), &rst) - if err != nil { - return nil, err - } - return -} - -func (db *Database) SetPinnedMailservers(mailservers map[string]string) error { - jsonString, err := json.Marshal(mailservers) - if err != nil { - return err - } - - _, err = db.db.Exec("UPDATE settings SET pinned_mailservers = ? WHERE synthetic_id = 'id'", jsonString) - return err -} - -func (db *Database) CanUseMailservers() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT use_mailservers FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return result, nil - } - return result, err -} - -func (db *Database) SetUseMailservers(value bool) error { - _, err := db.db.Exec("UPDATE settings SET use_mailservers = ?", value) - return err -} - -func (db *Database) CanSyncOnMobileNetwork() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT syncing_on_mobile_network FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return result, nil - } - return result, err -} - -func (db *Database) GetDefaultSyncPeriod() (uint32, error) { - var result uint32 - err := db.db.QueryRow("SELECT default_sync_period FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return result, nil - } - return result, err -} - -func (db *Database) GetMessagesFromContactsOnly() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT messages_from_contacts_only FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return result, nil - } - return result, err -} - -func (db *Database) GetInstalledStickerPacks() (rst *json.RawMessage, err error) { - err = db.db.QueryRow("SELECT stickers_packs_installed FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - return -} - -func (db *Database) GetPendingStickerPacks() (rst *json.RawMessage, err error) { - err = db.db.QueryRow("SELECT stickers_packs_pending FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - return -} - -func (db *Database) GetRecentStickers() (rst *json.RawMessage, err error) { - err = db.db.QueryRow("SELECT stickers_recent_stickers FROM settings WHERE synthetic_id = 'id'").Scan(&rst) - return -} - func (db *Database) GetWalletAddress() (rst types.Address, err error) { err = db.db.QueryRow("SELECT address FROM accounts WHERE wallet = 1").Scan(&rst) return @@ -832,12 +192,6 @@ func (db *Database) GetChatAddress() (rst types.Address, err error) { return } -func (db *Database) GetLatestDerivedPath() (uint, error) { - var result uint - err := db.db.QueryRow("SELECT latest_derived_path FROM settings WHERE synthetic_id = 'id'").Scan(&result) - return result, err -} - func (db *Database) GetAddresses() (rst []types.Address, err error) { rows, err := db.db.Query("SELECT address FROM accounts ORDER BY created_at") if err != nil { @@ -860,120 +214,3 @@ func (db *Database) AddressExists(address types.Address) (exists bool, err error err = db.db.QueryRow("SELECT EXISTS (SELECT 1 FROM accounts WHERE address = ?)", address).Scan(&exists) return exists, err } - -func (db *Database) GetCurrentStatus(status interface{}) error { - err := db.db.QueryRow("SELECT current_user_status FROM settings WHERE synthetic_id = 'id'").Scan(&sqlite.JSONBlob{Data: &status}) - if err == sql.ErrNoRows { - return nil - } - return err -} - -func (db *Database) ShouldBroadcastUserStatus() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT send_status_updates FROM settings WHERE synthetic_id = 'id'").Scan(&result) - // If the `send_status_updates` value is nil the sql.ErrNoRows will be returned - // because this feature is opt out, `true` should be returned in the case where no value is found - if err == sql.ErrNoRows { - return true, nil - } - return result, err -} - -func (db *Database) BackupEnabled() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT backup_enabled FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return true, nil - } - return result, err -} - -func (db *Database) AutoMessageEnabled() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT auto_message_enabled FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return true, nil - } - return result, err -} - -func (db *Database) LastBackup() (uint64, error) { - var result uint64 - err := db.db.QueryRow("SELECT last_backup FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return 0, nil - } - return result, err -} - -func (db *Database) SetLastBackup(time uint64) error { - _, err := db.db.Exec("UPDATE settings SET last_backup = ?", time) - return err -} - -func (db *Database) SetBackupFetched(fetched bool) error { - _, err := db.db.Exec("UPDATE settings SET backup_fetched = ?", fetched) - return err -} - -func (db *Database) BackupFetched() (bool, error) { - var result bool - err := db.db.QueryRow("SELECT backup_fetched FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return true, nil - } - return result, err -} - -func (db *Database) ENSName() (string, error) { - var result sql.NullString - err := db.db.QueryRow("SELECT preferred_name FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return "", nil - } - if result.Valid { - return result.String, nil - } - return "", err -} - -func (db *Database) DisplayName() (string, error) { - var result sql.NullString - err := db.db.QueryRow("SELECT display_name FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return "", nil - } - if result.Valid { - return result.String, nil - } - return "", err -} - -func (db *Database) GifAPIKey() (string, error) { - var result sql.NullString - err := db.db.QueryRow("SELECT gif_api_key FROM settings WHERE synthetic_id = 'id'").Scan(&result) - if err == sql.ErrNoRows { - return "", nil - } - if result.Valid { - return result.String, nil - } - return "", err -} - -func (db *Database) GifRecents() (recents json.RawMessage, err error) { - err = db.db.QueryRow("SELECT gif_recents FROM settings WHERE synthetic_id = 'id'").Scan(&sqlite.JSONBlob{Data: &recents}) - if err == sql.ErrNoRows { - return nil, err - } - return recents, nil -} - -func (db *Database) GifFavorites() (favorites json.RawMessage, err error) { - err = db.db.QueryRow("SELECT gif_favorites FROM settings WHERE synthetic_id = 'id'").Scan(&sqlite.JSONBlob{Data: &favorites}) - if err == sql.ErrNoRows { - return nil, err - } - return favorites, nil -} diff --git a/multiaccounts/accounts/database_test.go b/multiaccounts/accounts/database_test.go index beb562997..df1a93fd2 100644 --- a/multiaccounts/accounts/database_test.go +++ b/multiaccounts/accounts/database_test.go @@ -2,82 +2,31 @@ package accounts import ( "database/sql" - "encoding/json" - "io/ioutil" - "os" "testing" "github.com/stretchr/testify/require" "github.com/status-im/status-go/appdatabase" "github.com/status-im/status-go/eth-node/types" - "github.com/status-im/status-go/params" -) - -var ( - config = params.NodeConfig{ - NetworkID: 10, - DataDir: "test", - } - - networks = json.RawMessage("{}") - settings = Settings{ - Address: types.HexToAddress("0xdC540f3745Ff2964AFC1171a5A0DD726d1F6B472"), - AnonMetricsShouldSend: false, - CurrentNetwork: "mainnet_rpc", - DappsAddress: types.HexToAddress("0xD1300f99fDF7346986CbC766903245087394ecd0"), - InstallationID: "d3efcff6-cffa-560e-a547-21d3858cbc51", - KeyUID: "0x4e8129f3edfc004875be17bf468a784098a9f69b53c095be1f52deff286935ab", - BackupEnabled: true, - LatestDerivedPath: 0, - Name: "Jittery Cornflowerblue Kingbird", - Networks: &networks, - PhotoPath: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAjklEQVR4nOzXwQmFMBAAUZXUYh32ZB32ZB02sxYQQSZGsod55/91WFgSS0RM+SyjA56ZRZhFmEWYRRT6h+M6G16zrxv6fdJpmUWYRbxsYr13dKfanpN0WmYRZhGzXz6AWYRZRIfbaX26fT9Jk07LLMIsosPt9I/dTDotswizCG+nhFmEWYRZhFnEHQAA///z1CFkYamgfQAAAABJRU5ErkJggg==", - PreviewPrivacy: false, - PublicKey: "0x04211fe0f69772ecf7eb0b5bfc7678672508a9fb01f2d699096f0d59ef7fe1a0cb1e648a80190db1c0f5f088872444d846f2956d0bd84069f3f9f69335af852ac0", - SigningPhrase: "yurt joey vibe", - SendPushNotifications: true, - ProfilePicturesShowTo: ProfilePicturesShowToContactsOnly, - ProfilePicturesVisibility: ProfilePicturesVisibilityContactsOnly, - DefaultSyncPeriod: 86400, - UseMailservers: true, - LinkPreviewRequestEnabled: true, - SendStatusUpdates: true, - WalletRootAddress: types.HexToAddress("0x3B591fd819F86D0A6a2EF2Bcb94f77807a7De1a6")} + "github.com/status-im/status-go/multiaccounts/errors" ) func setupTestDB(t *testing.T) (*Database, func()) { - tmpfile, err := ioutil.TempFile("", "settings-tests-") - require.NoError(t, err) - db, err := appdatabase.InitializeDB(tmpfile.Name(), "settings-tests") - require.NoError(t, err) - - return NewDB(db), func() { - require.NoError(t, db.Close()) - require.NoError(t, os.Remove(tmpfile.Name())) + db, stop, err := appdatabase.SetupTestSQLDB("settings-tests-") + if err != nil { + require.NoError(t, stop()) } -} - -func TestCreateSettings(t *testing.T) { - db, stop := setupTestDB(t) - defer stop() - - require.NoError(t, db.CreateSettings(settings, config)) - - s, err := db.GetSettings() require.NoError(t, err) - require.Equal(t, settings, s) -} -func TestSaveSetting(t *testing.T) { - db, stop := setupTestDB(t) - defer stop() - - require.NoError(t, db.CreateSettings(settings, config)) - require.NoError(t, db.SaveSetting("currency", "usd")) - - _, err := db.GetSettings() + d, err := NewDB(db) + if err != nil { + require.NoError(t, stop()) + } require.NoError(t, err) + + return d, func() { + require.NoError(t, stop()) + } } func TestSaveAccounts(t *testing.T) { @@ -100,7 +49,7 @@ func TestSaveAccounts(t *testing.T) { {Address: types.Address{0x01}, Chat: true}, {Address: types.Address{0x02}, Chat: true}, }, - err: ErrChatNotUnique, + err: errors.ErrChatNotUnique, }, { description: "UniqueWallet", @@ -108,7 +57,7 @@ func TestSaveAccounts(t *testing.T) { {Address: types.Address{0x01}, Wallet: true}, {Address: types.Address{0x02}, Wallet: true}, }, - err: ErrWalletNotUnique, + err: errors.ErrWalletNotUnique, }, } { t.Run(tc.description, func(t *testing.T) { diff --git a/multiaccounts/errors/errors.go b/multiaccounts/errors/errors.go new file mode 100644 index 000000000..bd62027c0 --- /dev/null +++ b/multiaccounts/errors/errors.go @@ -0,0 +1,18 @@ +package errors + +import ( + "github.com/pkg/errors" +) + +var ( + // ErrWalletNotUnique returned if another account has `wallet` field set to true. + ErrWalletNotUnique = errors.New("another account is set to be default wallet. disable it before using new") + // ErrChatNotUnique returned if another account has `chat` field set to true. + ErrChatNotUnique = errors.New("another account is set to be default chat. disable it before using new") + // ErrInvalidConfig returned if config isn't allowed + ErrInvalidConfig = errors.New("configuration value not allowed") + // ErrNewClockOlderThanCurrent returned if a given clock is older than the current clock + ErrNewClockOlderThanCurrent = errors.New("the new clock value is older than the current clock value") + // ErrUnrecognisedSyncSettingProtobufType returned if there is no handler or record of a given protobuf.SyncSetting_Type + ErrUnrecognisedSyncSettingProtobufType = errors.New("unrecognised protobuf.SyncSetting_Type") +) diff --git a/multiaccounts/migrations/bindata.go b/multiaccounts/migrations/bindata.go index e5dc39f99..f28355f6f 100644 --- a/multiaccounts/migrations/bindata.go +++ b/multiaccounts/migrations/bindata.go @@ -90,7 +90,7 @@ func _0001_accountsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0001_accounts.down.sql", size: 21, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "0001_accounts.down.sql", size: 21, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd2, 0x61, 0x4c, 0x18, 0xfc, 0xc, 0xdf, 0x5c, 0x1f, 0x5e, 0xd3, 0xbd, 0xfa, 0x12, 0x5e, 0x8d, 0x8d, 0x8b, 0xb9, 0x5f, 0x99, 0x46, 0x63, 0xa5, 0xe3, 0xa6, 0x8a, 0x4, 0xf1, 0x73, 0x8a, 0xe9}} return a, nil } @@ -110,7 +110,7 @@ func _0001_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "0001_accounts.up.sql", size: 163, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "0001_accounts.up.sql", size: 163, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf2, 0xfa, 0x99, 0x8e, 0x96, 0xb3, 0x13, 0x6c, 0x1f, 0x6, 0x27, 0xc5, 0xd2, 0xd4, 0xe0, 0xa5, 0x26, 0x82, 0xa7, 0x26, 0xf2, 0x68, 0x9d, 0xed, 0x9c, 0x3d, 0xbb, 0xdc, 0x37, 0x28, 0xbc, 0x1}} return a, nil } @@ -130,7 +130,7 @@ func _1605007189_identity_imagesDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1605007189_identity_images.down.sql", size: 29, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1605007189_identity_images.down.sql", size: 29, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2f, 0xcf, 0xa7, 0xae, 0xd5, 0x4f, 0xcd, 0x14, 0x63, 0x9, 0xbe, 0x39, 0x49, 0x18, 0x96, 0xb2, 0xa3, 0x8, 0x7d, 0x41, 0xdb, 0x50, 0x5d, 0xf5, 0x4d, 0xa2, 0xd, 0x8f, 0x57, 0x79, 0x77, 0x67}} return a, nil } @@ -150,7 +150,7 @@ func _1605007189_identity_imagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1605007189_identity_images.up.sql", size: 268, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1605007189_identity_images.up.sql", size: 268, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x50, 0xb6, 0xc1, 0x5c, 0x76, 0x72, 0x6b, 0x22, 0x34, 0xdc, 0x96, 0xdc, 0x2b, 0xfd, 0x2d, 0xbe, 0xcc, 0x1e, 0xd4, 0x5, 0x93, 0xd, 0xc2, 0x51, 0xf3, 0x1a, 0xef, 0x2b, 0x26, 0xa4, 0xeb, 0x65}} return a, nil } @@ -170,7 +170,7 @@ func _1606224181_drop_photo_path_from_accountsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.down.sql", size: 892, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.down.sql", size: 892, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x90, 0x24, 0x17, 0x7, 0x80, 0x93, 0x6f, 0x8d, 0x5d, 0xaa, 0x8c, 0x79, 0x15, 0x5d, 0xb3, 0x19, 0xd7, 0xd8, 0x39, 0xf9, 0x3a, 0x63, 0x8f, 0x81, 0x15, 0xb6, 0xd6, 0x9a, 0x37, 0xa8, 0x8e, 0x9b}} return a, nil } @@ -190,7 +190,7 @@ func _1606224181_drop_photo_path_from_accountsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.up.sql", size: 866, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1606224181_drop_photo_path_from_accounts.up.sql", size: 866, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xff, 0x4c, 0x97, 0xee, 0xef, 0x82, 0xb8, 0x6c, 0x71, 0xbb, 0x50, 0x7b, 0xe6, 0xd9, 0x22, 0x31, 0x7c, 0x1a, 0xfe, 0x91, 0x28, 0xf6, 0x6, 0x36, 0xe, 0xb1, 0xf1, 0xc8, 0x25, 0xac, 0x7e, 0xd6}} return a, nil } @@ -210,7 +210,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x7c, 0x28, 0xcd, 0x47, 0xf2, 0xfa, 0x7c, 0x51, 0x2d, 0xd8, 0x38, 0xb, 0xb0, 0x34, 0x9d, 0x4c, 0x62, 0xa, 0x9e, 0x28, 0xc3, 0x31, 0x23, 0xd9, 0xbb, 0x89, 0x9f, 0xa0, 0x89, 0x1f, 0xe8}} return a, nil } diff --git a/multiaccounts/settings/columns.go b/multiaccounts/settings/columns.go new file mode 100644 index 000000000..4eaa17a72 --- /dev/null +++ b/multiaccounts/settings/columns.go @@ -0,0 +1,465 @@ +package settings + +import ( + "github.com/status-im/status-go/multiaccounts/errors" + "github.com/status-im/status-go/protocol/protobuf" +) + +var ( + AnonMetricsShouldSend = SettingField{ + reactFieldName: "anon-metrics/should-send?", + dBColumnName: "anon_metrics_should_send", + valueHandler: BoolHandler, + } + Appearance = SettingField{ + reactFieldName: "appearance", + dBColumnName: "appearance", + } + AutoMessageEnabled = SettingField{ + reactFieldName: "auto-message-enabled?", + dBColumnName: "auto_message_enabled", + valueHandler: BoolHandler, + } + BackupEnabled = SettingField{ + reactFieldName: "backup-enabled?", + dBColumnName: "backup_enabled", + valueHandler: BoolHandler, + } + BackupFetched = SettingField{ + reactFieldName: "backup-fetched?", + dBColumnName: "backup_fetched", + valueHandler: BoolHandler, + } + ChaosMode = SettingField{ + reactFieldName: "chaos-mode?", + dBColumnName: "chaos_mode", + valueHandler: BoolHandler, + } + Currency = SettingField{ + reactFieldName: "currency", + dBColumnName: "currency", + // TODO resolve issue 6 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: currencyProtobufFactory, + fromStruct: currencyProtobufFactoryStruct, + valueFromProtobuf: StringFromSyncProtobuf, + protobufType: protobuf.SyncSetting_CURRENCY, + }, + } + CurrentUserStatus = SettingField{ + reactFieldName: "current-user-status", + dBColumnName: "current_user_status", + valueHandler: JSONBlobHandler, + } + CustomBootNodes = SettingField{ + reactFieldName: "custom-bootnodes", + dBColumnName: "custom_bootnodes", + valueHandler: JSONBlobHandler, + } + CustomBootNodesEnabled = SettingField{ + reactFieldName: "custom-bootnodes-enabled?", + dBColumnName: "custom_bootnodes_enabled", + valueHandler: JSONBlobHandler, + } + DappsAddress = SettingField{ + reactFieldName: "dapps-address", + dBColumnName: "dapps_address", + valueHandler: AddressHandler, + } + DefaultSyncPeriod = SettingField{ + reactFieldName: "default-sync-period", + dBColumnName: "default_sync_period", + } + DisplayName = SettingField{ + reactFieldName: "display-name", + dBColumnName: "display_name", + } + EIP1581Address = SettingField{ + reactFieldName: "eip1581-address", + dBColumnName: "eip1581_address", + valueHandler: AddressHandler, + } + Fleet = SettingField{ + reactFieldName: "fleet", + dBColumnName: "fleet", + } + GifAPIKey = SettingField{ + reactFieldName: "gifs/api-key", + dBColumnName: "gif_api_key", + } + GifFavourites = SettingField{ + reactFieldName: "gifs/favorite-gifs", + dBColumnName: "gif_favorites", + valueHandler: JSONBlobHandler, + // TODO resolve issue 8 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + // The reported issue is not directly related, but I suspect that gifs suffer the same issue + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: gifFavouritesProtobufFactory, + fromStruct: gifFavouritesProtobufFactoryStruct, + valueFromProtobuf: BytesFromSyncProtobuf, + protobufType: protobuf.SyncSetting_GIF_FAVOURITES, + }, + } + GifRecents = SettingField{ + reactFieldName: "gifs/recent-gifs", + dBColumnName: "gif_recents", + valueHandler: JSONBlobHandler, + // TODO resolve issue 8 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + // The reported issue is not directly related, but I suspect that gifs suffer the same issue + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: gifRecentsProtobufFactory, + fromStruct: gifRecentsProtobufFactoryStruct, + valueFromProtobuf: BytesFromSyncProtobuf, + protobufType: protobuf.SyncSetting_GIF_RECENTS, + }, + } + HideHomeTooltip = SettingField{ + reactFieldName: "hide-home-tooltip?", + dBColumnName: "hide_home_tooltip", + valueHandler: BoolHandler, + } + KeycardInstanceUID = SettingField{ + reactFieldName: "keycard-instance_uid", + dBColumnName: "keycard_instance_uid", + } + KeycardPairedOn = SettingField{ + reactFieldName: "keycard-paired_on", + dBColumnName: "keycard_paired_on", + } + KeycardPairing = SettingField{ + reactFieldName: "keycard-pairing", + dBColumnName: "keycard_pairing", + } + LastBackup = SettingField{ + reactFieldName: "last-backup", + dBColumnName: "last_backup", + } + LastUpdated = SettingField{ + reactFieldName: "last-updated", + dBColumnName: "last_updated", + } + LatestDerivedPath = SettingField{ + reactFieldName: "latest-derived-path", + dBColumnName: "latest_derived_path", + } + LinkPreviewRequestEnabled = SettingField{ + reactFieldName: "link-preview-request-enabled", + dBColumnName: "link_preview_request_enabled", + valueHandler: BoolHandler, + } + LinkPreviewsEnabledSites = SettingField{ + reactFieldName: "link-previews-enabled-sites", + dBColumnName: "link_previews_enabled_sites", + valueHandler: JSONBlobHandler, + } + LogLevel = SettingField{ + reactFieldName: "log-level", + dBColumnName: "log_level", + } + MessagesFromContactsOnly = SettingField{ + reactFieldName: "messages-from-contacts-only", + dBColumnName: "messages_from_contacts_only", + valueHandler: BoolHandler, + syncProtobufFactory: &SyncProtobufFactory{ + fromInterface: messagesFromContactsOnlyProtobufFactory, + fromStruct: messagesFromContactsOnlyProtobufFactoryStruct, + valueFromProtobuf: BoolFromSyncProtobuf, + protobufType: protobuf.SyncSetting_MESSAGES_FROM_CONTACTS_ONLY, + }, + } + Mnemonic = SettingField{ + reactFieldName: "mnemonic", + dBColumnName: "mnemonic", + } + Name = SettingField{ + reactFieldName: "name", + dBColumnName: "name", + } + NetworksCurrentNetwork = SettingField{ + reactFieldName: "networks/current-network", + dBColumnName: "current_network", + } + NetworksNetworks = SettingField{ + reactFieldName: "networks/networks", + dBColumnName: "networks", + valueHandler: JSONBlobHandler, + } + NodeConfig = SettingField{ + reactFieldName: "node-config", + dBColumnName: "node_config", + valueHandler: NodeConfigHandler, + } + NotificationsEnabled = SettingField{ + reactFieldName: "notifications-enabled?", + dBColumnName: "notifications_enabled", + valueHandler: BoolHandler, + } + OpenseaEnabled = SettingField{ + reactFieldName: "opensea-enabled?", + dBColumnName: "opensea_enabled", + valueHandler: BoolHandler, + } + PhotoPath = SettingField{ + reactFieldName: "photo-path", + dBColumnName: "photo_path", + } + PinnedMailservers = SettingField{ + reactFieldName: "pinned-mailservers", + dBColumnName: "pinned_mailservers", + valueHandler: JSONBlobHandler, + } + PreferredName = SettingField{ + reactFieldName: "preferred-name", + dBColumnName: "preferred_name", + // TODO resolve issue 9 https://github.com/status-im/status-react/pull/13053#issuecomment-1075336559 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: preferredNameProtobufFactory, + fromStruct: preferredNameProtobufFactoryStruct, + valueFromProtobuf: StringFromSyncProtobuf, + protobufType: protobuf.SyncSetting_PREFERRED_NAME, + }, + } + PreviewPrivacy = SettingField{ + reactFieldName: "preview-privacy?", + dBColumnName: "preview_privacy", + valueHandler: BoolHandler, + // TODO resolved issue 7 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: previewPrivacyProtobufFactory, + fromStruct: previewPrivacyProtobufFactoryStruct, + valueFromProtobuf: BoolFromSyncProtobuf, + protobufType: protobuf.SyncSetting_PREVIEW_PRIVACY, + }, + } + ProfilePicturesShowTo = SettingField{ + reactFieldName: "profile-pictures-show-to", + dBColumnName: "profile_pictures_show_to", + syncProtobufFactory: &SyncProtobufFactory{ + fromInterface: profilePicturesShowToProtobufFactory, + fromStruct: profilePicturesShowToProtobufFactoryStruct, + valueFromProtobuf: Int64FromSyncProtobuf, + protobufType: protobuf.SyncSetting_PROFILE_PICTURES_SHOW_TO, + }, + } + ProfilePicturesVisibility = SettingField{ + reactFieldName: "profile-pictures-visibility", + dBColumnName: "profile_pictures_visibility", + syncProtobufFactory: &SyncProtobufFactory{ + fromInterface: profilePicturesVisibilityProtobufFactory, + fromStruct: profilePicturesVisibilityProtobufFactoryStruct, + valueFromProtobuf: Int64FromSyncProtobuf, + protobufType: protobuf.SyncSetting_PROFILE_PICTURES_VISIBILITY, + }, + } + PublicKey = SettingField{ + reactFieldName: "public-key", + dBColumnName: "public_key", + } + PushNotificationsBlockMentions = SettingField{ + reactFieldName: "push-notifications-block-mentions?", + dBColumnName: "push_notifications_block_mentions", + valueHandler: BoolHandler, + } + PushNotificationsFromContactsOnly = SettingField{ + reactFieldName: "push-notifications-from-contacts-only?", + dBColumnName: "push_notifications_from_contacts_only", + valueHandler: BoolHandler, + } + PushNotificationsServerEnabled = SettingField{ + reactFieldName: "push-notifications-server-enabled?", + dBColumnName: "push_notifications_server_enabled", + valueHandler: BoolHandler, + } + RememberSyncingChoice = SettingField{ + reactFieldName: "remember-syncing-choice?", + dBColumnName: "remember_syncing_choice", + valueHandler: BoolHandler, + } + RemotePushNotificationsEnabled = SettingField{ + reactFieldName: "remote-push-notifications-enabled?", + dBColumnName: "remote_push_notifications_enabled", + valueHandler: BoolHandler, + } + SendPushNotifications = SettingField{ + reactFieldName: "send-push-notifications?", + dBColumnName: "send_push_notifications", + valueHandler: BoolHandler, + } + SendStatusUpdates = SettingField{ + reactFieldName: "send-status-updates?", + dBColumnName: "send_status_updates", + valueHandler: BoolHandler, + // TODO resolve issue 10 https://github.com/status-im/status-react/pull/13053#issuecomment-1075352256 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: sendStatusUpdatesProtobufFactory, + fromStruct: sendStatusUpdatesProtobufFactoryStruct, + valueFromProtobuf: BoolFromSyncProtobuf, + protobufType: protobuf.SyncSetting_SEND_STATUS_UPDATES, + }, + } + StickersPacksInstalled = SettingField{ + reactFieldName: "stickers/packs-installed", + dBColumnName: "stickers_packs_installed", + valueHandler: JSONBlobHandler, + // TODO resolve issue 8 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: stickersPacksInstalledProtobufFactory, + fromStruct: stickersPacksInstalledProtobufFactoryStruct, + valueFromProtobuf: BytesFromSyncProtobuf, + protobufType: protobuf.SyncSetting_STICKERS_PACKS_INSTALLED, + }, + } + StickersPacksPending = SettingField{ + reactFieldName: "stickers/packs-pending", + dBColumnName: "stickers_packs_pending", + valueHandler: JSONBlobHandler, + // TODO resolve issue 8 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: stickersPacksPendingProtobufFactory, + fromStruct: stickersPacksPendingProtobufFactoryStruct, + valueFromProtobuf: BytesFromSyncProtobuf, + protobufType: protobuf.SyncSetting_STICKERS_PACKS_PENDING, + }, + } + StickersRecentStickers = SettingField{ + reactFieldName: "stickers/recent-stickers", + dBColumnName: "stickers_recent_stickers", + valueHandler: JSONBlobHandler, + // TODO resolve issue 8 https://github.com/status-im/status-react/pull/13053#issuecomment-1065179963 + syncProtobufFactory: &SyncProtobufFactory{ + inactive: true, // Remove after issue is resolved + fromInterface: stickersRecentStickersProtobufFactory, + fromStruct: stickersRecentStickersProtobufFactoryStruct, + valueFromProtobuf: BytesFromSyncProtobuf, + protobufType: protobuf.SyncSetting_STICKERS_RECENT_STICKERS, + }, + } + SyncingOnMobileNetwork = SettingField{ + reactFieldName: "syncing-on-mobile-network?", + dBColumnName: "syncing_on_mobile_network", + valueHandler: BoolHandler, + } + TelemetryServerURL = SettingField{ + reactFieldName: "telemetry-server-url", + dBColumnName: "telemetry_server_url", + } + UseMailservers = SettingField{ + reactFieldName: "use-mailservers?", + dBColumnName: "use_mailservers", + valueHandler: BoolHandler, + } + Usernames = SettingField{ + reactFieldName: "usernames", + dBColumnName: "usernames", + valueHandler: JSONBlobHandler, + } + WakuBloomFilterMode = SettingField{ + reactFieldName: "waku-bloom-filter-mode", + dBColumnName: "waku_bloom_filter_mode", + valueHandler: BoolHandler, + } + WalletSetUpPassed = SettingField{ + reactFieldName: "wallet-set-up-passed?", + dBColumnName: "wallet_set_up_passed", + valueHandler: BoolHandler, + } + WalletVisibleTokens = SettingField{ + reactFieldName: "wallet/visible-tokens", + dBColumnName: "wallet_visible_tokens", + valueHandler: JSONBlobHandler, + } + WebviewAllowPermissionRequests = SettingField{ + reactFieldName: "webview-allow-permission-requests?", + dBColumnName: "webview_allow_permission_requests", + valueHandler: BoolHandler, + } + + SettingFieldRegister = []SettingField{ + AnonMetricsShouldSend, + Appearance, + AutoMessageEnabled, + BackupEnabled, + BackupFetched, + ChaosMode, + Currency, + CurrentUserStatus, + CustomBootNodes, + CustomBootNodesEnabled, + DappsAddress, + DefaultSyncPeriod, + DisplayName, + EIP1581Address, + Fleet, + GifAPIKey, + GifFavourites, + GifRecents, + HideHomeTooltip, + KeycardInstanceUID, + KeycardPairedOn, + KeycardPairing, + LastBackup, + LastUpdated, + LatestDerivedPath, + LinkPreviewRequestEnabled, + LinkPreviewsEnabledSites, + LogLevel, + MessagesFromContactsOnly, + Mnemonic, + Name, + NetworksCurrentNetwork, + NetworksNetworks, + NodeConfig, + NotificationsEnabled, + OpenseaEnabled, + PhotoPath, + PinnedMailservers, + PreferredName, + PreviewPrivacy, + ProfilePicturesShowTo, + ProfilePicturesVisibility, + PublicKey, + PushNotificationsBlockMentions, + PushNotificationsFromContactsOnly, + PushNotificationsServerEnabled, + RememberSyncingChoice, + RemotePushNotificationsEnabled, + SendPushNotifications, + SendStatusUpdates, + StickersPacksInstalled, + StickersPacksPending, + StickersRecentStickers, + SyncingOnMobileNetwork, + TelemetryServerURL, + UseMailservers, + Usernames, + WakuBloomFilterMode, + WalletSetUpPassed, + WalletVisibleTokens, + WebviewAllowPermissionRequests, + } +) + +func GetFieldFromProtobufType(pbt protobuf.SyncSetting_Type) (SettingField, error) { + if pbt == protobuf.SyncSetting_UNKNOWN { + return SettingField{}, errors.ErrUnrecognisedSyncSettingProtobufType + } + + for _, s := range SettingFieldRegister { + if s.SyncProtobufFactory() == nil { + continue + } + if s.SyncProtobufFactory().SyncSettingProtobufType() == pbt { + return s, nil + } + } + + return SettingField{}, errors.ErrUnrecognisedSyncSettingProtobufType +} diff --git a/multiaccounts/settings/columns_test.go b/multiaccounts/settings/columns_test.go new file mode 100644 index 000000000..849a93096 --- /dev/null +++ b/multiaccounts/settings/columns_test.go @@ -0,0 +1,59 @@ +package settings + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/status-im/status-go/protocol/protobuf" +) + +func TestSyncSettingField_MarshalJSON(t *testing.T) { + cs := []struct { + Field SyncSettingField + Expected []byte + }{ + { + Field: SyncSettingField{ + Currency, + "eth", + }, + Expected: []byte("{\"name\":\"currency\",\"value\":\"eth\"}"), + }, + { + Field: SyncSettingField{ + ProfilePicturesShowTo, + ProfilePicturesShowToNone, + }, + Expected: []byte("{\"name\":\"profile-pictures-show-to\",\"value\":3}"), + }, + { + Field: SyncSettingField{ + MessagesFromContactsOnly, + false, + }, + Expected: []byte("{\"name\":\"messages-from-contacts-only\",\"value\":false}"), + }, + } + + for _, c := range cs { + js, err := json.Marshal(c.Field) + require.NoError(t, err) + require.Equal(t, c.Expected, js) + } +} + +// TestGetFieldFromProtobufType checks if all the protobuf.SyncSetting_Type_value are assigned to a SettingField +func TestGetFieldFromProtobufType(t *testing.T) { + for _, sst := range protobuf.SyncSetting_Type_value { + _, err := GetFieldFromProtobufType(protobuf.SyncSetting_Type(sst)) + if sst == 0 { + require.Error(t, err, "do not have a SettingField for the unknown type") + continue + } + if err != nil { + require.NoError(t, err) + } + } +} diff --git a/multiaccounts/settings/database.go b/multiaccounts/settings/database.go new file mode 100644 index 000000000..ff68549b6 --- /dev/null +++ b/multiaccounts/settings/database.go @@ -0,0 +1,538 @@ +package settings + +import ( + "context" + "database/sql" + "encoding/json" + "fmt" + "sync" + + "github.com/status-im/status-go/appdatabase" + "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/multiaccounts/errors" + "github.com/status-im/status-go/nodecfg" + "github.com/status-im/status-go/params" + "github.com/status-im/status-go/sqlite" +) + +var ( + // dbInstances holds a map of singleton instances of Database + dbInstances map[string]*Database + + // mutex guards the instantiation of the dbInstances values, to prevent any concurrent instantiations + mutex sync.Mutex +) + +// Database sql wrapper for operations with browser objects. +type Database struct { + db *sql.DB + SyncQueue chan SyncSettingField +} + +// MakeNewDB ensures that a singleton instance of Database is returned per sqlite db file +func MakeNewDB(db *sql.DB) (*Database, error) { + filename, err := appdatabase.GetDBFilename(db) + if err != nil { + return nil, err + } + + d := &Database{ + db: db, + SyncQueue: make(chan SyncSettingField, 100), + } + + // An empty filename means that the sqlite database is held in memory + // In this case we don't want to restrict the instantiation + if filename == "" { + return d, nil + } + + // Lock to protect the map from concurrent access + mutex.Lock() + defer mutex.Unlock() + + // init dbInstances if it hasn't been already + if dbInstances == nil { + dbInstances = map[string]*Database{} + } + + // If we haven't seen this database file before make an instance + if _, ok := dbInstances[filename]; !ok { + dbInstances[filename] = d + } + + // Check if the current dbInstance is closed, if closed assign new Database + if err := dbInstances[filename].db.Ping(); err != nil { + dbInstances[filename] = d + } + + return dbInstances[filename], nil +} + +// TODO remove photoPath from settings +func (db *Database) CreateSettings(s Settings, n params.NodeConfig) error { + tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) + if err != nil { + return err + } + + defer func() { + if err == nil { + err = tx.Commit() + return + } + // don't shadow original error + _ = tx.Rollback() + }() + + _, err = tx.Exec(` +INSERT INTO settings ( + address, + currency, + current_network, + dapps_address, + display_name, + eip1581_address, + installation_id, + key_uid, + keycard_instance_uid, + keycard_paired_on, + keycard_pairing, + latest_derived_path, + mnemonic, + name, + networks, + photo_path, + preview_privacy, + public_key, + signing_phrase, + wallet_root_address, + synthetic_id +) VALUES ( +?,?,?,?,?,?,?,?,?,?,?, +?,?,?,?,?,?,?,?,?,'id')`, + s.Address, + s.Currency, + s.CurrentNetwork, + s.DappsAddress, + s.DisplayName, + s.EIP1581Address, + s.InstallationID, + s.KeyUID, + s.KeycardInstanceUID, + s.KeycardPAiredOn, + s.KeycardPairing, + s.LatestDerivedPath, + s.Mnemonic, + s.Name, + s.Networks, + s.PhotoPath, + s.PreviewPrivacy, + s.PublicKey, + s.SigningPhrase, + s.WalletRootAddress, + ) + if err != nil { + return err + } + + return nodecfg.SaveConfigWithTx(tx, &n) +} + +func (db *Database) getSettingFieldFromReactName(reactName string) (SettingField, error) { + for _, s := range SettingFieldRegister { + if s.GetReactName() == reactName { + return s, nil + } + } + return SettingField{}, errors.ErrInvalidConfig +} + +func (db *Database) makeSelectRow(setting SettingField) *sql.Row { + query := "SELECT %s FROM settings WHERE synthetic_id = 'id'" + query = fmt.Sprintf(query, setting.GetDBName()) + return db.db.QueryRow(query) +} + +func (db *Database) makeSelectString(setting SettingField) (string, error) { + var result sql.NullString + err := db.makeSelectRow(setting).Scan(&result) + if err == sql.ErrNoRows { + return "", nil + } + if result.Valid { + return result.String, nil + } + return "", err +} + +func (db *Database) saveSetting(setting SettingField, value interface{}) error { + query := "UPDATE settings SET %s = ? WHERE synthetic_id = 'id'" + query = fmt.Sprintf(query, setting.GetDBName()) + + update, err := db.db.Prepare(query) + if err != nil { + return err + } + + _, err = update.Exec(value) + return err +} + +func (db *Database) parseSaveAndSyncSetting(sf SettingField, value interface{}) (err error) { + if sf.ValueHandler() != nil { + value, err = sf.ValueHandler()(value) + if err != nil { + return err + } + } + + // TODO(samyoul) this is ugly as hell need a more elegant solution + if NodeConfig.GetReactName() == sf.GetReactName() { + if err = nodecfg.SaveNodeConfig(db.db, value.(*params.NodeConfig)); err != nil { + return err + } + value = nil + } + + err = db.saveSetting(sf, value) + if err != nil { + return err + } + + if sf.CanSync(FromInterface) { + db.SyncQueue <- SyncSettingField{sf, value} + } + return nil +} + +// SaveSetting stores data from any non-sync source +// If the field requires syncing the field data is pushed on to the SyncQueue +func (db *Database) SaveSetting(setting string, value interface{}) error { + sf, err := db.getSettingFieldFromReactName(setting) + if err != nil { + return err + } + + return db.parseSaveAndSyncSetting(sf, value) +} + +// SaveSettingField is identical in functionality to SaveSetting, except the setting parameter is a SettingField and +// doesn't require any SettingFieldRegister lookup. +// This func is useful if you already know the SettingField to save +func (db *Database) SaveSettingField(sf SettingField, value interface{}) error { + return db.parseSaveAndSyncSetting(sf, value) +} + +// SaveSyncSetting stores setting data from a sync protobuf source, note it does not call SettingField.ValueHandler() +// nor does this function attempt to write to the Database.SyncQueue +func (db *Database) SaveSyncSetting(setting SettingField, value interface{}, clock uint64) error { + ls, err := db.GetSettingLastSynced(setting) + if err != nil { + return err + } + if clock <= ls { + return errors.ErrNewClockOlderThanCurrent + } + + err = db.SetSettingLastSynced(setting, clock) + if err != nil { + return err + } + + return db.saveSetting(setting, value) +} + +func (db *Database) GetSettingLastSynced(setting SettingField) (result uint64, err error) { + query := "SELECT %s FROM settings_sync_clock WHERE synthetic_id = 'id'" + query = fmt.Sprintf(query, setting.GetDBName()) + + err = db.db.QueryRow(query).Scan(&result) + if err != nil { + return 0, err + } + + return result, nil +} + +func (db *Database) SetSettingLastSynced(setting SettingField, clock uint64) error { + query := "UPDATE settings_sync_clock SET %s = ? WHERE synthetic_id = 'id' AND %s < ?" + query = fmt.Sprintf(query, setting.GetDBName(), setting.GetDBName()) + + _, err := db.db.Exec(query, clock, clock) + return err +} + +func (db *Database) GetSettings() (Settings, error) { + var s Settings + err := db.db.QueryRow("SELECT address, anon_metrics_should_send, chaos_mode, currency, current_network, custom_bootnodes, custom_bootnodes_enabled, dapps_address, display_name, eip1581_address, fleet, hide_home_tooltip, installation_id, key_uid, keycard_instance_uid, keycard_paired_on, keycard_pairing, last_updated, latest_derived_path, link_preview_request_enabled, link_previews_enabled_sites, log_level, mnemonic, name, networks, notifications_enabled, push_notifications_server_enabled, push_notifications_from_contacts_only, remote_push_notifications_enabled, send_push_notifications, push_notifications_block_mentions, photo_path, pinned_mailservers, preferred_name, preview_privacy, public_key, remember_syncing_choice, signing_phrase, stickers_packs_installed, stickers_packs_pending, stickers_recent_stickers, syncing_on_mobile_network, default_sync_period, use_mailservers, messages_from_contacts_only, usernames, appearance, profile_pictures_show_to, profile_pictures_visibility, wallet_root_address, wallet_set_up_passed, wallet_visible_tokens, waku_bloom_filter_mode, webview_allow_permission_requests, current_user_status, send_status_updates, gif_recents, gif_favorites, opensea_enabled, last_backup, backup_enabled, telemetry_server_url, auto_message_enabled, gif_api_key FROM settings WHERE synthetic_id = 'id'").Scan( + &s.Address, + &s.AnonMetricsShouldSend, + &s.ChaosMode, + &s.Currency, + &s.CurrentNetwork, + &s.CustomBootnodes, + &s.CustomBootnodesEnabled, + &s.DappsAddress, + &s.DisplayName, + &s.EIP1581Address, + &s.Fleet, + &s.HideHomeTooltip, + &s.InstallationID, + &s.KeyUID, + &s.KeycardInstanceUID, + &s.KeycardPAiredOn, + &s.KeycardPairing, + &s.LastUpdated, + &s.LatestDerivedPath, + &s.LinkPreviewRequestEnabled, + &s.LinkPreviewsEnabledSites, + &s.LogLevel, + &s.Mnemonic, + &s.Name, + &s.Networks, + &s.NotificationsEnabled, + &s.PushNotificationsServerEnabled, + &s.PushNotificationsFromContactsOnly, + &s.RemotePushNotificationsEnabled, + &s.SendPushNotifications, + &s.PushNotificationsBlockMentions, + &s.PhotoPath, + &s.PinnedMailserver, + &s.PreferredName, + &s.PreviewPrivacy, + &s.PublicKey, + &s.RememberSyncingChoice, + &s.SigningPhrase, + &s.StickerPacksInstalled, + &s.StickerPacksPending, + &s.StickersRecentStickers, + &s.SyncingOnMobileNetwork, + &s.DefaultSyncPeriod, + &s.UseMailservers, + &s.MessagesFromContactsOnly, + &s.Usernames, + &s.Appearance, + &s.ProfilePicturesShowTo, + &s.ProfilePicturesVisibility, + &s.WalletRootAddress, + &s.WalletSetUpPassed, + &s.WalletVisibleTokens, + &s.WakuBloomFilterMode, + &s.WebViewAllowPermissionRequests, + &sqlite.JSONBlob{Data: &s.CurrentUserStatus}, + &s.SendStatusUpdates, + &sqlite.JSONBlob{Data: &s.GifRecents}, + &sqlite.JSONBlob{Data: &s.GifFavorites}, + &s.OpenseaEnabled, + &s.LastBackup, + &s.BackupEnabled, + &s.TelemetryServerURL, + &s.AutoMessageEnabled, + &s.GifAPIKey, + ) + + return s, err +} + +func (db *Database) GetNotificationsEnabled() (result bool, err error) { + err = db.makeSelectRow(NotificationsEnabled).Scan(&result) + if err == sql.ErrNoRows { + return result, nil + } + return result, err +} + +func (db *Database) GetProfilePicturesVisibility() (result int, err error) { + err = db.makeSelectRow(ProfilePicturesVisibility).Scan(&result) + if err == sql.ErrNoRows { + return result, nil + } + return result, err +} + +func (db *Database) GetPublicKey() (string, error) { + return db.makeSelectString(PublicKey) +} + +func (db *Database) GetFleet() (string, error) { + return db.makeSelectString(Fleet) +} + +func (db *Database) GetDappsAddress() (rst types.Address, err error) { + err = db.makeSelectRow(DappsAddress).Scan(&rst) + if err == sql.ErrNoRows { + return rst, nil + } + return +} + +func (db *Database) GetPinnedMailservers() (rst map[string]string, err error) { + rst = make(map[string]string) + var pinnedMailservers string + err = db.db.QueryRow("SELECT COALESCE(pinned_mailservers, '') FROM settings WHERE synthetic_id = 'id'").Scan(&pinnedMailservers) + if err == sql.ErrNoRows || pinnedMailservers == "" { + return rst, nil + } + + err = json.Unmarshal([]byte(pinnedMailservers), &rst) + if err != nil { + return nil, err + } + return +} + +func (db *Database) CanUseMailservers() (result bool, err error) { + err = db.makeSelectRow(UseMailservers).Scan(&result) + if err == sql.ErrNoRows { + return result, nil + } + return result, err +} + +func (db *Database) CanSyncOnMobileNetwork() (result bool, err error) { + err = db.makeSelectRow(SyncingOnMobileNetwork).Scan(&result) + if err == sql.ErrNoRows { + return result, nil + } + return result, err +} + +func (db *Database) GetDefaultSyncPeriod() (result uint32, err error) { + err = db.makeSelectRow(DefaultSyncPeriod).Scan(&result) + if err == sql.ErrNoRows { + return result, nil + } + return result, err +} + +func (db *Database) GetMessagesFromContactsOnly() (result bool, err error) { + err = db.makeSelectRow(MessagesFromContactsOnly).Scan(&result) + if err == sql.ErrNoRows { + return result, nil + } + return result, err +} + +func (db *Database) GetLatestDerivedPath() (result uint, err error) { + err = db.makeSelectRow(LatestDerivedPath).Scan(&result) + return +} + +func (db *Database) GetCurrentStatus(status interface{}) error { + err := db.makeSelectRow(CurrentUserStatus).Scan(&sqlite.JSONBlob{Data: &status}) + if err == sql.ErrNoRows { + return nil + } + return err +} + +func (db *Database) ShouldBroadcastUserStatus() (result bool, err error) { + err = db.makeSelectRow(SendStatusUpdates).Scan(&result) + // If the `send_status_updates` value is nil the sql.ErrNoRows will be returned + // because this feature is opt out, `true` should be returned in the case where no value is found + if err == sql.ErrNoRows { + return true, nil + } + return result, err +} + +func (db *Database) BackupEnabled() (result bool, err error) { + err = db.makeSelectRow(BackupEnabled).Scan(&result) + if err == sql.ErrNoRows { + return true, nil + } + return result, err +} + +func (db *Database) AutoMessageEnabled() (result bool, err error) { + err = db.makeSelectRow(AutoMessageEnabled).Scan(&result) + if err == sql.ErrNoRows { + return true, nil + } + return result, err +} + +func (db *Database) LastBackup() (result uint64, err error) { + err = db.makeSelectRow(LastBackup).Scan(&result) + if err == sql.ErrNoRows { + return 0, nil + } + return result, err +} + +func (db *Database) SetLastBackup(time uint64) error { + return db.SaveSettingField(LastBackup, time) +} + +func (db *Database) SetBackupFetched(fetched bool) error { + return db.SaveSettingField(BackupFetched, fetched) +} + +func (db *Database) BackupFetched() (result bool, err error) { + err = db.makeSelectRow(BackupFetched).Scan(&result) + if err == sql.ErrNoRows { + return true, nil + } + return result, err +} + +func (db *Database) ENSName() (string, error) { + return db.makeSelectString(PreferredName) +} + +func (db *Database) DisplayName() (string, error) { + return db.makeSelectString(DisplayName) +} + +func (db *Database) GifAPIKey() (string, error) { + return db.makeSelectString(GifAPIKey) +} + +func (db *Database) GifRecents() (recents json.RawMessage, err error) { + err = db.makeSelectRow(GifRecents).Scan(&sqlite.JSONBlob{Data: &recents}) + if err == sql.ErrNoRows { + return nil, err + } + return recents, nil +} + +func (db *Database) GifFavorites() (favorites json.RawMessage, err error) { + err = db.makeSelectRow(GifFavourites).Scan(&sqlite.JSONBlob{Data: &favorites}) + if err == sql.ErrNoRows { + return nil, err + } + return favorites, nil +} + +func (db *Database) GetPreferredUsername() (string, error) { + return db.makeSelectString(PreferredName) +} + +func (db *Database) GetInstalledStickerPacks() (rst *json.RawMessage, err error) { + err = db.makeSelectRow(StickersPacksInstalled).Scan(&rst) + return +} + +func (db *Database) GetPendingStickerPacks() (rst *json.RawMessage, err error) { + err = db.makeSelectRow(StickersPacksPending).Scan(&rst) + return +} + +func (db *Database) GetRecentStickers() (rst *json.RawMessage, err error) { + err = db.makeSelectRow(StickersRecentStickers).Scan(&rst) + return +} + +func (db *Database) SetPinnedMailservers(mailservers map[string]string) error { + jsonString, err := json.Marshal(mailservers) + if err != nil { + return err + } + + return db.SaveSettingField(PinnedMailservers, jsonString) +} + +func (db *Database) SetUseMailservers(value bool) error { + return db.SaveSettingField(UseMailservers, value) +} diff --git a/multiaccounts/settings/database_test.go b/multiaccounts/settings/database_test.go new file mode 100644 index 000000000..9bb72151f --- /dev/null +++ b/multiaccounts/settings/database_test.go @@ -0,0 +1,187 @@ +package settings + +import ( + "encoding/json" + "os" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/status-im/status-go/appdatabase" + "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/multiaccounts/errors" + "github.com/status-im/status-go/params" +) + +var ( + config = params.NodeConfig{ + NetworkID: 10, + DataDir: "test", + } + + networks = json.RawMessage("{}") + settings = Settings{ + Address: types.HexToAddress("0xdC540f3745Ff2964AFC1171a5A0DD726d1F6B472"), + AnonMetricsShouldSend: false, + CurrentNetwork: "mainnet_rpc", + DappsAddress: types.HexToAddress("0xD1300f99fDF7346986CbC766903245087394ecd0"), + InstallationID: "d3efcff6-cffa-560e-a547-21d3858cbc51", + KeyUID: "0x4e8129f3edfc004875be17bf468a784098a9f69b53c095be1f52deff286935ab", + BackupEnabled: true, + LatestDerivedPath: 0, + Name: "Jittery Cornflowerblue Kingbird", + Networks: &networks, + PhotoPath: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAjklEQVR4nOzXwQmFMBAAUZXUYh32ZB32ZB02sxYQQSZGsod55/91WFgSS0RM+SyjA56ZRZhFmEWYRRT6h+M6G16zrxv6fdJpmUWYRbxsYr13dKfanpN0WmYRZhGzXz6AWYRZRIfbaX26fT9Jk07LLMIsosPt9I/dTDotswizCG+nhFmEWYRZhFnEHQAA///z1CFkYamgfQAAAABJRU5ErkJggg==", + PreviewPrivacy: false, + PublicKey: "0x04211fe0f69772ecf7eb0b5bfc7678672508a9fb01f2d699096f0d59ef7fe1a0cb1e648a80190db1c0f5f088872444d846f2956d0bd84069f3f9f69335af852ac0", + SigningPhrase: "yurt joey vibe", + SendPushNotifications: true, + ProfilePicturesShowTo: ProfilePicturesShowToContactsOnly, + ProfilePicturesVisibility: ProfilePicturesVisibilityContactsOnly, + DefaultSyncPeriod: 86400, + UseMailservers: true, + LinkPreviewRequestEnabled: true, + SendStatusUpdates: true, + WalletRootAddress: types.HexToAddress("0x3B591fd819F86D0A6a2EF2Bcb94f77807a7De1a6")} +) + +func setupTestDB(t *testing.T) (*Database, func()) { + db, stop, err := appdatabase.SetupTestSQLDB("settings-tests-") + if err != nil { + require.NoError(t, stop()) + } + require.NoError(t, err) + + d, err := MakeNewDB(db) + if err != nil { + require.NoError(t, stop()) + } + require.NoError(t, err) + + return d, func() { + require.NoError(t, stop()) + } +} + +func TestClosingsqlDB(t *testing.T) { + testFileName := "./test.db" + password := "settings-tests" + + // Make connection with sql.DB + db, err := appdatabase.InitializeDB(testFileName, password) + + // handle removing the test file on any exit + defer func() { + require.NoError(t, os.Remove(testFileName)) + require.NoError(t, os.Remove(testFileName+"-shm")) + require.NoError(t, os.Remove(testFileName+"-wal")) + }() + + // Then check the first error + require.NoError(t, err) + + // Init settings.Database struct + d, err := MakeNewDB(db) + require.NoError(t, err) + + // Add settings data to the db + err = d.CreateSettings(settings, config) + require.NoError(t, err) + + // close the sql.DB connection + err = db.Close() + require.NoError(t, err) + + // Make another connection with sql.DB + db2, err := appdatabase.InitializeDB(testFileName, password) + require.NoError(t, err) + + // Init settings.Database struct using second connection + d, err = MakeNewDB(db2) + require.NoError(t, err) + + // Ping db expect no error + err = d.db.Ping() + require.NoError(t, err) +} + +func TestNewDB(t *testing.T) { + // TODO test that + // - multiple different in memory dbs can be inited + // - only one instance per file name can be inited +} + +func TestCreateSettings(t *testing.T) { + db, stop := setupTestDB(t) + defer stop() + + require.NoError(t, db.CreateSettings(settings, config)) + + s, err := db.GetSettings() + require.NoError(t, err) + require.Equal(t, settings, s) +} + +func TestSaveSetting(t *testing.T) { + db, stop := setupTestDB(t) + defer stop() + + require.NoError(t, db.CreateSettings(settings, config)) + require.NoError(t, db.SaveSetting(Currency.GetReactName(), "usd")) + + _, err := db.GetSettings() + require.NoError(t, err) + + require.Equal(t, errors.ErrInvalidConfig, db.SaveSetting("a_column_that_does_n0t_exist", "random value")) +} + +func TestDatabase_SetSettingLastSynced(t *testing.T) { + db, stop := setupTestDB(t) + defer stop() + + tm := uint64(0) + + // Default value should be `0` + ct, err := db.GetSettingLastSynced(Currency) + require.NoError(t, err) + require.Equal(t, tm, ct) + + // Test setting clock value to something greater than `0` + tm += 123 + err = db.SetSettingLastSynced(Currency, tm) + require.NoError(t, err) + + ct, err = db.GetSettingLastSynced(Currency) + require.NoError(t, err) + require.Equal(t, tm, ct) + + // Test setting clock to greater than `123` + now := uint64(321) + err = db.SetSettingLastSynced(Currency, now) + require.NoError(t, err) + + ct, err = db.GetSettingLastSynced(Currency) + require.NoError(t, err) + require.Equal(t, now, ct) + + // Test setting clock to something less than `321` + earlier := uint64(231) + err = db.SetSettingLastSynced(Currency, earlier) + require.NoError(t, err) + + ct, err = db.GetSettingLastSynced(Currency) + require.NoError(t, err) + require.Equal(t, now, ct) +} + +func TestSyncColumnsSet(t *testing.T) { + db, stop := setupTestDB(t) + defer stop() + + for _, sf := range SettingFieldRegister { + if sf.SyncProtobufFactory() != nil { + _, err := db.GetSettingLastSynced(sf) + require.NoError(t, err) + } + } +} diff --git a/multiaccounts/settings/enums.go b/multiaccounts/settings/enums.go new file mode 100644 index 000000000..be5d4fd7b --- /dev/null +++ b/multiaccounts/settings/enums.go @@ -0,0 +1,24 @@ +package settings + +type SyncSource int + +const ( + FromInterface SyncSource = iota + 1 + FromStruct +) + +type ProfilePicturesVisibilityType int + +const ( + ProfilePicturesVisibilityContactsOnly ProfilePicturesVisibilityType = iota + 1 + ProfilePicturesVisibilityEveryone + ProfilePicturesVisibilityNone +) + +type ProfilePicturesShowToType int + +const ( + ProfilePicturesShowToContactsOnly ProfilePicturesShowToType = iota + 1 + ProfilePicturesShowToEveryone + ProfilePicturesShowToNone +) diff --git a/multiaccounts/settings/structs.go b/multiaccounts/settings/structs.go new file mode 100644 index 000000000..38b2b828c --- /dev/null +++ b/multiaccounts/settings/structs.go @@ -0,0 +1,186 @@ +package settings + +import ( + "encoding/json" + + "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/protocol/common" + "github.com/status-im/status-go/protocol/protobuf" +) + +type ValueHandler func(interface{}) (interface{}, error) +type SyncSettingProtobufFactoryInterface func(interface{}, uint64, string) (*common.RawMessage, error) +type SyncSettingProtobufFactoryStruct func(Settings, uint64, string) (*common.RawMessage, error) +type SyncSettingProtobufToValue func(setting *protobuf.SyncSetting) interface{} + +// SyncProtobufFactory represents a collection of functionality to generate and parse *protobuf.SyncSetting +type SyncProtobufFactory struct { + inactive bool + fromInterface SyncSettingProtobufFactoryInterface + fromStruct SyncSettingProtobufFactoryStruct + valueFromProtobuf SyncSettingProtobufToValue + protobufType protobuf.SyncSetting_Type +} + +func (spf *SyncProtobufFactory) Inactive() bool { + return spf.inactive +} + +func (spf *SyncProtobufFactory) FromInterface() SyncSettingProtobufFactoryInterface { + return spf.fromInterface +} + +func (spf *SyncProtobufFactory) FromStruct() SyncSettingProtobufFactoryStruct { + return spf.fromStruct +} + +func (spf *SyncProtobufFactory) ExtractValueFromProtobuf() SyncSettingProtobufToValue { + return spf.valueFromProtobuf +} + +func (spf *SyncProtobufFactory) SyncSettingProtobufType() protobuf.SyncSetting_Type { + return spf.protobufType +} + +// SyncSettingField represents a binding between a Value and a SettingField +type SyncSettingField struct { + SettingField + Value interface{} +} + +func (s SyncSettingField) MarshalJSON() ([]byte, error) { + alias := struct { + Name string `json:"name"` + Value interface{} `json:"value"` + }{ + s.reactFieldName, + s.Value, + } + + return json.Marshal(alias) +} + +// SettingField represents an individual setting in the database, it contains context dependant names and optional +// pre-store value parsing, along with optional *SyncProtobufFactory +type SettingField struct { + reactFieldName string + dBColumnName string + valueHandler ValueHandler + syncProtobufFactory *SyncProtobufFactory +} + +func (s SettingField) GetReactName() string { + return s.reactFieldName +} + +func (s SettingField) GetDBName() string { + return s.dBColumnName +} + +func (s SettingField) ValueHandler() ValueHandler { + return s.valueHandler +} + +func (s SettingField) SyncProtobufFactory() *SyncProtobufFactory { + return s.syncProtobufFactory +} + +// CanSync checks if a SettingField has functions supporting the syncing of +func (s SettingField) CanSync(source SyncSource) bool { + spf := s.syncProtobufFactory + + if spf == nil { + return false + } + + if spf.inactive { + return false + } + + switch source { + case FromInterface: + return spf.fromInterface != nil + case FromStruct: + return spf.fromStruct != nil + default: + return false + } +} + +// Settings represents the entire setting row stored in the application db +type Settings struct { + // required + Address types.Address `json:"address"` + AnonMetricsShouldSend bool `json:"anon-metrics/should-send?,omitempty"` + ChaosMode bool `json:"chaos-mode?,omitempty"` + Currency string `json:"currency,omitempty"` + CurrentNetwork string `json:"networks/current-network"` + CustomBootnodes *json.RawMessage `json:"custom-bootnodes,omitempty"` + CustomBootnodesEnabled *json.RawMessage `json:"custom-bootnodes-enabled?,omitempty"` + DappsAddress types.Address `json:"dapps-address"` + DisplayName string `json:"display-name"` + EIP1581Address types.Address `json:"eip1581-address"` + Fleet *string `json:"fleet,omitempty"` + HideHomeTooltip bool `json:"hide-home-tooltip?,omitempty"` + InstallationID string `json:"installation-id"` + KeyUID string `json:"key-uid"` + KeycardInstanceUID string `json:"keycard-instance-uid,omitempty"` + KeycardPAiredOn int64 `json:"keycard-paired-on,omitempty"` + KeycardPairing string `json:"keycard-pairing,omitempty"` + LastUpdated *int64 `json:"last-updated,omitempty"` + LatestDerivedPath uint `json:"latest-derived-path"` + LinkPreviewRequestEnabled bool `json:"link-preview-request-enabled,omitempty"` + LinkPreviewsEnabledSites *json.RawMessage `json:"link-previews-enabled-sites,omitempty"` + LogLevel *string `json:"log-level,omitempty"` + MessagesFromContactsOnly bool `json:"messages-from-contacts-only"` + Mnemonic *string `json:"mnemonic,omitempty"` + Name string `json:"name,omitempty"` + Networks *json.RawMessage `json:"networks/networks"` + // NotificationsEnabled indicates whether local notifications should be enabled (android only) + NotificationsEnabled bool `json:"notifications-enabled?,omitempty"` + PhotoPath string `json:"photo-path"` + PinnedMailserver *json.RawMessage `json:"pinned-mailservers,omitempty"` + PreferredName *string `json:"preferred-name,omitempty"` + PreviewPrivacy bool `json:"preview-privacy?"` + PublicKey string `json:"public-key"` + // PushNotificationsServerEnabled indicates whether we should be running a push notification server + PushNotificationsServerEnabled bool `json:"push-notifications-server-enabled?,omitempty"` + // PushNotificationsFromContactsOnly indicates whether we should only receive push notifications from contacts + PushNotificationsFromContactsOnly bool `json:"push-notifications-from-contacts-only?,omitempty"` + // PushNotificationsBlockMentions indicates whether we should receive notifications for mentions + PushNotificationsBlockMentions bool `json:"push-notifications-block-mentions?,omitempty"` + RememberSyncingChoice bool `json:"remember-syncing-choice?,omitempty"` + // RemotePushNotificationsEnabled indicates whether we should be using remote notifications (ios only for now) + RemotePushNotificationsEnabled bool `json:"remote-push-notifications-enabled?,omitempty"` + SigningPhrase string `json:"signing-phrase"` + StickerPacksInstalled *json.RawMessage `json:"stickers/packs-installed,omitempty"` + StickerPacksPending *json.RawMessage `json:"stickers/packs-pending,omitempty"` + StickersRecentStickers *json.RawMessage `json:"stickers/recent-stickers,omitempty"` + SyncingOnMobileNetwork bool `json:"syncing-on-mobile-network?,omitempty"` + // DefaultSyncPeriod is how far back in seconds we should pull messages from a mailserver + DefaultSyncPeriod uint `json:"default-sync-period"` + // SendPushNotifications indicates whether we should send push notifications for other clients + SendPushNotifications bool `json:"send-push-notifications?,omitempty"` + Appearance uint `json:"appearance"` + // ProfilePicturesShowTo indicates to whom the user shows their profile picture to (contacts, everyone) + ProfilePicturesShowTo ProfilePicturesShowToType `json:"profile-pictures-show-to"` + // ProfilePicturesVisibility indicates who we want to see profile pictures of (contacts, everyone or none) + ProfilePicturesVisibility ProfilePicturesVisibilityType `json:"profile-pictures-visibility"` + UseMailservers bool `json:"use-mailservers?"` + Usernames *json.RawMessage `json:"usernames,omitempty"` + WalletRootAddress types.Address `json:"wallet-root-address,omitempty"` + WalletSetUpPassed bool `json:"wallet-set-up-passed?,omitempty"` + WalletVisibleTokens *json.RawMessage `json:"wallet/visible-tokens,omitempty"` + WakuBloomFilterMode bool `json:"waku-bloom-filter-mode,omitempty"` + WebViewAllowPermissionRequests bool `json:"webview-allow-permission-requests?,omitempty"` + SendStatusUpdates bool `json:"send-status-updates?,omitempty"` + CurrentUserStatus *json.RawMessage `json:"current-user-status"` + GifRecents *json.RawMessage `json:"gifs/recent-gifs"` + GifFavorites *json.RawMessage `json:"gifs/favorite-gifs"` + OpenseaEnabled bool `json:"opensea-enabled?,omitempty"` + TelemetryServerURL string `json:"telemetry-server-url,omitempty"` + LastBackup uint64 `json:"last-backup,omitempty"` + BackupEnabled bool `json:"backup-enabled?,omitempty"` + AutoMessageEnabled bool `json:"auto-message-enabled?,omitempty"` + GifAPIKey string `json:"gifs/api-key"` +} diff --git a/multiaccounts/settings/sync_protobuf_factories.go b/multiaccounts/settings/sync_protobuf_factories.go new file mode 100644 index 000000000..0e7523a98 --- /dev/null +++ b/multiaccounts/settings/sync_protobuf_factories.go @@ -0,0 +1,424 @@ +package settings + +import ( + "bytes" + "encoding/json" + "reflect" + + "github.com/golang/protobuf/proto" + "github.com/pkg/errors" + + "github.com/status-im/status-go/protocol/common" + "github.com/status-im/status-go/protocol/protobuf" + "github.com/status-im/status-go/sqlite" +) + +var ( + ErrTypeAssertionFailed = errors.New("type assertion of interface value failed") +) + +func buildRawSyncSettingMessage(msg *protobuf.SyncSetting, chatID string) (*common.RawMessage, error) { + encodedMessage, err := proto.Marshal(msg) + if err != nil { + return nil, err + } + + return &common.RawMessage{ + LocalChatID: chatID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_SYNC_SETTING, + ResendAutomatically: true, + }, nil +} + +// Currency + +func buildRawCurrencySyncMessage(v string, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_CURRENCY, + Value: &protobuf.SyncSetting_ValueString{ValueString: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func currencyProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertString(value) + if err != nil { + return nil, err + } + + return buildRawCurrencySyncMessage(v, clock, chatID) +} + +func currencyProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + return buildRawCurrencySyncMessage(s.Currency, clock, chatID) +} + +// GifFavorites + +func buildRawGifFavoritesSyncMessage(v []byte, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_GIF_FAVOURITES, + Value: &protobuf.SyncSetting_ValueBytes{ValueBytes: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func gifFavouritesProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertBytes(value) + if err != nil { + return nil, err + } + + return buildRawGifFavoritesSyncMessage(v, clock, chatID) +} + +func gifFavouritesProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + gf := extractJSONRawMessage(s.GifFavorites) + return buildRawGifFavoritesSyncMessage(gf, clock, chatID) +} + +// GifRecents + +func buildRawGifRecentsSyncMessage(v []byte, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_GIF_RECENTS, + Value: &protobuf.SyncSetting_ValueBytes{ValueBytes: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func gifRecentsProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertBytes(value) + if err != nil { + return nil, err + } + + return buildRawGifRecentsSyncMessage(v, clock, chatID) +} + +func gifRecentsProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + gr := extractJSONRawMessage(s.GifRecents) + return buildRawGifRecentsSyncMessage(gr, clock, chatID) +} + +// MessagesFromContactsOnly + +func buildRawMessagesFromContactsOnlySyncMessage(v bool, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_MESSAGES_FROM_CONTACTS_ONLY, + Value: &protobuf.SyncSetting_ValueBool{ValueBool: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func messagesFromContactsOnlyProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertBool(value) + if err != nil { + return nil, err + } + + return buildRawMessagesFromContactsOnlySyncMessage(v, clock, chatID) +} + +func messagesFromContactsOnlyProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + return buildRawMessagesFromContactsOnlySyncMessage(s.MessagesFromContactsOnly, clock, chatID) +} + +// PreferredName + +func buildRawPreferredNameSyncMessage(v string, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_PREFERRED_NAME, + Value: &protobuf.SyncSetting_ValueString{ValueString: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func preferredNameProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertString(value) + if err != nil { + return nil, err + } + + return buildRawPreferredNameSyncMessage(v, clock, chatID) +} + +func preferredNameProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + var pn string + if s.PreferredName != nil { + pn = *s.PreferredName + } + + return buildRawPreferredNameSyncMessage(pn, clock, chatID) +} + +// PreviewPrivacy + +func buildRawPreviewPrivacySyncMessage(v bool, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_PREVIEW_PRIVACY, + Value: &protobuf.SyncSetting_ValueBool{ValueBool: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func previewPrivacyProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertBool(value) + if err != nil { + return nil, err + } + + return buildRawPreviewPrivacySyncMessage(v, clock, chatID) +} + +func previewPrivacyProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + return buildRawPreviewPrivacySyncMessage(s.PreviewPrivacy, clock, chatID) +} + +// ProfilePicturesShowTo + +func buildRawProfilePicturesShowToSyncMessage(v int64, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_PROFILE_PICTURES_SHOW_TO, + Value: &protobuf.SyncSetting_ValueInt64{ValueInt64: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func profilePicturesShowToProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := parseNumberToInt64(value) + if err != nil { + return nil, err + } + + return buildRawProfilePicturesShowToSyncMessage(v, clock, chatID) +} + +func profilePicturesShowToProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + return buildRawProfilePicturesShowToSyncMessage(int64(s.ProfilePicturesShowTo), clock, chatID) +} + +// ProfilePicturesVisibility + +func buildRawProfilePicturesVisibilitySyncMessage(v int64, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_PROFILE_PICTURES_VISIBILITY, + Value: &protobuf.SyncSetting_ValueInt64{ValueInt64: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func profilePicturesVisibilityProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := parseNumberToInt64(value) + if err != nil { + return nil, err + } + + return buildRawProfilePicturesVisibilitySyncMessage(v, clock, chatID) +} + +func profilePicturesVisibilityProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + return buildRawProfilePicturesVisibilitySyncMessage(int64(s.ProfilePicturesVisibility), clock, chatID) +} + +// SendStatusUpdates + +func buildRawSendStatusUpdatesSyncMessage(v bool, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_SEND_STATUS_UPDATES, + Value: &protobuf.SyncSetting_ValueBool{ValueBool: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func sendStatusUpdatesProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := assertBool(value) + if err != nil { + return nil, err + } + + return buildRawSendStatusUpdatesSyncMessage(v, clock, chatID) +} + +func sendStatusUpdatesProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + return buildRawSendStatusUpdatesSyncMessage(s.SendStatusUpdates, clock, chatID) +} + +// StickerPacksInstalled + +func buildRawStickerPacksInstalledSyncMessage(v []byte, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_STICKERS_PACKS_INSTALLED, + Value: &protobuf.SyncSetting_ValueBytes{ValueBytes: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func stickersPacksInstalledProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := parseJSONBlobData(value) + if err != nil { + return nil, err + } + + return buildRawStickerPacksInstalledSyncMessage(v, clock, chatID) +} + +func stickersPacksInstalledProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + spi := extractJSONRawMessage(s.StickerPacksInstalled) + return buildRawStickerPacksInstalledSyncMessage(spi, clock, chatID) +} + +// StickerPacksPending + +func buildRawStickerPacksPendingSyncMessage(v []byte, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_STICKERS_PACKS_PENDING, + Value: &protobuf.SyncSetting_ValueBytes{ValueBytes: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func stickersPacksPendingProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := parseJSONBlobData(value) + if err != nil { + return nil, err + } + + return buildRawStickerPacksPendingSyncMessage(v, clock, chatID) +} + +func stickersPacksPendingProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + spp := extractJSONRawMessage(s.StickerPacksPending) + return buildRawStickerPacksPendingSyncMessage(spp, clock, chatID) +} + +// StickersRecentStickers + +func buildRawStickersRecentStickersSyncMessage(v []byte, clock uint64, chatID string) (*common.RawMessage, error) { + pb := &protobuf.SyncSetting{ + Type: protobuf.SyncSetting_STICKERS_RECENT_STICKERS, + Value: &protobuf.SyncSetting_ValueBytes{ValueBytes: v}, + Clock: clock, + } + return buildRawSyncSettingMessage(pb, chatID) +} + +func stickersRecentStickersProtobufFactory(value interface{}, clock uint64, chatID string) (*common.RawMessage, error) { + v, err := parseJSONBlobData(value) + if err != nil { + return nil, err + } + + return buildRawStickersRecentStickersSyncMessage(v, clock, chatID) +} + +func stickersRecentStickersProtobufFactoryStruct(s Settings, clock uint64, chatID string) (*common.RawMessage, error) { + srs := extractJSONRawMessage(s.StickersRecentStickers) + return buildRawStickersRecentStickersSyncMessage(srs, clock, chatID) +} + +func assertBytes(value interface{}) ([]byte, error) { + v, ok := value.([]byte) + if !ok { + return nil, errors.Wrapf(ErrTypeAssertionFailed, "expected '[]byte', received %T", value) + } + return v, nil +} + +func assertBool(value interface{}) (bool, error) { + v, ok := value.(bool) + if !ok { + return false, errors.Wrapf(ErrTypeAssertionFailed, "expected 'bool', received %T", value) + } + return v, nil +} + +func assertString(value interface{}) (string, error) { + rv := reflect.ValueOf(value) + if rv.Kind() == reflect.Ptr { + value = *value.(*string) + } + v, ok := value.(string) + if !ok { + return "", errors.Wrapf(ErrTypeAssertionFailed, "expected 'string', received %T", value) + } + return v, nil +} + +func parseJSONBlobData(value interface{}) ([]byte, error) { + switch v := value.(type) { + case []byte: + return v, nil + case *sqlite.JSONBlob: + return extractJSONBlob(v) + default: + return nil, errors.Wrapf(ErrTypeAssertionFailed, "expected []byte or *sqlite.JSONBlob, received %T", value) + } +} + +func parseNumberToInt64(value interface{}) (int64, error) { + switch v := value.(type) { + case float32: + return int64(v), nil + case float64: + return int64(v), nil + case int: + return int64(v), nil + case int8: + return int64(v), nil + case int16: + return int64(v), nil + case int32: + return int64(v), nil + case int64: + return v, nil + case uint: + return int64(v), nil + case uint8: + return int64(v), nil + case uint16: + return int64(v), nil + case uint32: + return int64(v), nil + case uint64: + return int64(v), nil + case ProfilePicturesShowToType: + return int64(v), nil + case ProfilePicturesVisibilityType: + return int64(v), nil + default: + return 0, errors.Wrapf(ErrTypeAssertionFailed, "expected a numeric type, received %T", value) + } +} + +func extractJSONBlob(jb *sqlite.JSONBlob) ([]byte, error) { + value, err := jb.Value() + if err != nil { + return nil, err + } + + return value.([]byte), nil +} + +func extractJSONRawMessage(jrm *json.RawMessage) []byte { + if jrm == nil { + return nil + } + out, _ := jrm.MarshalJSON() // Don't need to parse error because it is always nil + if len(out) == 0 || bytes.Equal(out, []byte("null")) { + return nil + } + return out +} diff --git a/multiaccounts/settings/sync_protobuf_factories_test.go b/multiaccounts/settings/sync_protobuf_factories_test.go new file mode 100644 index 000000000..5c7f8a870 --- /dev/null +++ b/multiaccounts/settings/sync_protobuf_factories_test.go @@ -0,0 +1,58 @@ +package settings + +import ( + "encoding/json" + "testing" + + "github.com/golang/protobuf/proto" + "github.com/stretchr/testify/require" + + "github.com/status-im/status-go/protocol/protobuf" +) + +type testCriteria struct { + Name string + Input inputCriteria + Expected expectedCriteria +} + +type inputCriteria struct { + Value interface{} + Clock uint64 +} + +type expectedCriteria struct { + Value int64 + Clock uint64 + AMT protobuf.ApplicationMetadataMessage_Type +} + +func TestProfilePicturesVisibilityProtobufFactory(t *testing.T) { + var v interface{} + err := json.Unmarshal([]byte(`3`), &v) + require.NoError(t, err) + + expected := expectedCriteria{3, 123, protobuf.ApplicationMetadataMessage_SYNC_SETTING} + + cs := []testCriteria{ + {"json.Unmarshal int into interface{}", inputCriteria{Value: v, Clock: 123}, expected}, + {"ProfilePicturesVisibilityType", inputCriteria{Value: ProfilePicturesVisibilityNone, Clock: 123}, expected}, + {"int64", inputCriteria{Value: int64(3), Clock: 123}, expected}, + } + + for _, c := range cs { + a := require.New(t) + + rm, err := profilePicturesVisibilityProtobufFactory(c.Input.Value, c.Input.Clock, "0x123def") + a.NoError(err, c.Name) + + ppvp := new(protobuf.SyncSetting) + err = proto.Unmarshal(rm.Payload, ppvp) + a.NoError(err, c.Name) + + a.Equal(protobuf.SyncSetting_PROFILE_PICTURES_VISIBILITY, ppvp.Type, c.Name) + a.Equal(c.Expected.Value, ppvp.GetValueInt64(), c.Name) + a.Equal(c.Expected.Clock, ppvp.Clock, c.Name) + a.Equal(c.Expected.AMT, rm.MessageType, c.Name) + } +} diff --git a/multiaccounts/settings/value_handlers.go b/multiaccounts/settings/value_handlers.go new file mode 100644 index 000000000..5e6ed5149 --- /dev/null +++ b/multiaccounts/settings/value_handlers.go @@ -0,0 +1,65 @@ +package settings + +import ( + "encoding/json" + + "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/multiaccounts/errors" + "github.com/status-im/status-go/params" + "github.com/status-im/status-go/protocol/protobuf" + "github.com/status-im/status-go/sqlite" +) + +func StringFromSyncProtobuf(ss *protobuf.SyncSetting) interface{} { + return ss.GetValueString() +} + +func BoolFromSyncProtobuf(ss *protobuf.SyncSetting) interface{} { + return ss.GetValueBool() +} + +func BytesFromSyncProtobuf(ss *protobuf.SyncSetting) interface{} { + return ss.GetValueBytes() +} + +func Int64FromSyncProtobuf(ss *protobuf.SyncSetting) interface{} { + return ss.GetValueInt64() +} + +func BoolHandler(value interface{}) (interface{}, error) { + _, ok := value.(bool) + if !ok { + return value, errors.ErrInvalidConfig + } + + return value, nil +} + +func JSONBlobHandler(value interface{}) (interface{}, error) { + return &sqlite.JSONBlob{Data: value}, nil +} + +func AddressHandler(value interface{}) (interface{}, error) { + str, ok := value.(string) + if ok { + value = types.HexToAddress(str) + } else { + return value, errors.ErrInvalidConfig + } + return value, nil +} + +func NodeConfigHandler(value interface{}) (interface{}, error) { + jsonString, err := json.Marshal(value) + if err != nil { + return nil, err + } + + nodeConfig := new(params.NodeConfig) + err = json.Unmarshal(jsonString, nodeConfig) + if err != nil { + return nil, err + } + + return nodeConfig, nil +} diff --git a/node/status_node_rpc_client_test.go b/node/status_node_rpc_client_test.go index ae39b0de4..5718407f7 100644 --- a/node/status_node_rpc_client_test.go +++ b/node/status_node_rpc_client_test.go @@ -2,11 +2,16 @@ package node import ( "context" + "database/sql" + "io/ioutil" + "os" "strings" "testing" "github.com/stretchr/testify/require" + "github.com/status-im/status-go/appdatabase" + "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/params" ) @@ -16,12 +21,74 @@ func (api *TestServiceAPI) SomeMethod(_ context.Context) (string, error) { return "some method result", nil } +func setupTestDB() (*sql.DB, func() error, error) { + tmpfile, err := ioutil.TempFile("", "tests") + if err != nil { + return nil, nil, err + } + db, err := appdatabase.InitializeDB(tmpfile.Name(), "tests") + if err != nil { + return nil, nil, err + } + return db, func() error { + err := db.Close() + if err != nil { + return err + } + return os.Remove(tmpfile.Name()) + }, nil +} + +func setupTestMultiDB() (*multiaccounts.Database, func() error, error) { + tmpfile, err := ioutil.TempFile("", "tests") + if err != nil { + return nil, nil, err + } + db, err := multiaccounts.InitializeDB(tmpfile.Name()) + if err != nil { + return nil, nil, err + } + return db, func() error { + err := db.Close() + if err != nil { + return err + } + return os.Remove(tmpfile.Name()) + }, nil +} + func createAndStartStatusNode(config *params.NodeConfig) (*StatusNode, error) { statusNode := New(nil) - err := statusNode.Start(config, nil) + + db, stop, err := setupTestDB() + defer func() { + err := stop() + if err != nil { + statusNode.log.Error("stopping db", err) + } + }() if err != nil { return nil, err } + statusNode.appDB = db + + ma, stop2, err := setupTestMultiDB() + defer func() { + err := stop2() + if err != nil { + statusNode.log.Error("stopping multiaccount db", err) + } + }() + if err != nil { + return nil, err + } + statusNode.multiaccountsDB = ma + + err = statusNode.Start(config, nil) + if err != nil { + return nil, err + } + return statusNode, nil } @@ -80,4 +147,7 @@ func TestNodeRPCPrivateClientCallPrivateService(t *testing.T) { // the call is successful require.False(t, strings.Contains(result, "error")) + + _, err = statusNode.CallPrivateRPC(`{"jsonrpc": "2.0", "id": 1, "method": "settings_getSettings"}`) + require.NoError(t, err) } diff --git a/node/status_node_services.go b/node/status_node_services.go index 845cdca2c..e40e6abf9 100644 --- a/node/status_node_services.go +++ b/node/status_node_services.go @@ -60,6 +60,10 @@ var ( func (b *StatusNode) initServices(config *params.NodeConfig) error { accountsFeed := &event.Feed{} + accDB, err := accounts.NewDB(b.appDB) + if err != nil { + return err + } services := []common.StatusService{} services = appendIf(config.UpstreamConfig.Enabled, services, b.rpcFiltersService()) @@ -70,15 +74,15 @@ func (b *StatusNode) initServices(config *params.NodeConfig) error { services = append(services, b.personalService()) services = append(services, b.statusPublicService()) services = append(services, b.ensService()) - services = append(services, b.stickersService()) + services = append(services, b.stickersService(accDB)) services = appendIf(config.EnableNTPSync, services, b.timeSource()) - services = appendIf(b.appDB != nil && b.multiaccountsDB != nil, services, b.accountsService(accountsFeed)) + services = appendIf(b.appDB != nil && b.multiaccountsDB != nil, services, b.accountsService(accountsFeed, accDB)) services = appendIf(config.BrowsersConfig.Enabled, services, b.browsersService()) services = appendIf(config.PermissionsConfig.Enabled, services, b.permissionsService()) services = appendIf(config.MailserversConfig.Enabled, services, b.mailserversService()) - services = appendIf(config.Web3ProviderConfig.Enabled, services, b.providerService()) - services = append(services, b.gifService()) - services = append(services, b.ChatService()) + services = appendIf(config.Web3ProviderConfig.Enabled, services, b.providerService(accDB)) + services = append(services, b.gifService(accDB)) + services = append(services, b.ChatService(accDB)) if config.WakuConfig.Enabled { wakuService, err := b.wakuService(&config.WakuConfig, &config.ClusterConfig) @@ -125,7 +129,11 @@ func (b *StatusNode) initServices(config *params.NodeConfig) error { } // We ignore for now local notifications flag as users who are upgrading have no mean to enable it - services = append(services, b.localNotificationsService(config.NetworkID)) + lns, err := b.localNotificationsService(config.NetworkID) + if err != nil { + return err + } + services = append(services, lns) b.peerSrvc.SetDiscoverer(b) @@ -352,10 +360,10 @@ func (b *StatusNode) rpcStatsService() *rpcstats.Service { return b.rpcStatsSrvc } -func (b *StatusNode) accountsService(accountsFeed *event.Feed) *accountssvc.Service { +func (b *StatusNode) accountsService(accountsFeed *event.Feed, accDB *accounts.Database) *accountssvc.Service { if b.accountsSrvc == nil { b.accountsSrvc = accountssvc.NewService( - accounts.NewDB(b.appDB), + accDB, b.multiaccountsDB, b.gethAccountManager, b.config, @@ -380,23 +388,23 @@ func (b *StatusNode) ensService() *ens.Service { return b.ensSrvc } -func (b *StatusNode) stickersService() *stickers.Service { +func (b *StatusNode) stickersService(accountDB *accounts.Database) *stickers.Service { if b.stickersSrvc == nil { - b.stickersSrvc = stickers.NewService(b.appDB, b.rpcClient, b.gethAccountManager, b.rpcFiltersSrvc, b.config) + b.stickersSrvc = stickers.NewService(accountDB, b.rpcClient, b.gethAccountManager, b.rpcFiltersSrvc, b.config) } return b.stickersSrvc } -func (b *StatusNode) gifService() *gif.Service { +func (b *StatusNode) gifService(accountsDB *accounts.Database) *gif.Service { if b.gifSrvc == nil { - b.gifSrvc = gif.NewService(accounts.NewDB(b.appDB)) + b.gifSrvc = gif.NewService(accountsDB) } return b.gifSrvc } -func (b *StatusNode) ChatService() *chat.Service { +func (b *StatusNode) ChatService(accountsDB *accounts.Database) *chat.Service { if b.chatSrvc == nil { - b.chatSrvc = chat.NewService(b.appDB) + b.chatSrvc = chat.NewService(accountsDB) } return b.chatSrvc } @@ -416,9 +424,10 @@ func (b *StatusNode) mailserversService() *mailservers.Service { return b.mailserversSrvc } -func (b *StatusNode) providerService() *web3provider.Service { +func (b *StatusNode) providerService(accountsDB *accounts.Database) *web3provider.Service { + web3S := web3provider.NewService(b.appDB, accountsDB, b.rpcClient, b.config, b.gethAccountManager, b.rpcFiltersSrvc, b.transactor) if b.providerSrvc == nil { - b.providerSrvc = web3provider.NewService(b.appDB, b.rpcClient, b.config, b.gethAccountManager, b.rpcFiltersSrvc, b.transactor) + b.providerSrvc = web3S } return b.providerSrvc } @@ -437,11 +446,15 @@ func (b *StatusNode) walletService(accountsFeed *event.Feed, openseaAPIKey strin return b.walletSrvc } -func (b *StatusNode) localNotificationsService(network uint64) *localnotifications.Service { +func (b *StatusNode) localNotificationsService(network uint64) (*localnotifications.Service, error) { + var err error if b.localNotificationsSrvc == nil { - b.localNotificationsSrvc = localnotifications.NewService(b.appDB, network) + b.localNotificationsSrvc, err = localnotifications.NewService(b.appDB, network) + if err != nil { + return nil, err + } } - return b.localNotificationsSrvc + return b.localNotificationsSrvc, nil } func (b *StatusNode) peerService() *peer.Service { diff --git a/protocol/anonmetrics/migrations/migrations.go b/protocol/anonmetrics/migrations/migrations.go index d8e6e468b..168ec90b9 100644 --- a/protocol/anonmetrics/migrations/migrations.go +++ b/protocol/anonmetrics/migrations/migrations.go @@ -86,7 +86,7 @@ func _1619446565_postgres_make_anon_metrics_tableDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1619446565_postgres_make_anon_metrics_table.down.sql", size: 24, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1619446565_postgres_make_anon_metrics_table.down.sql", size: 24, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x75, 0xea, 0x1, 0x74, 0xe6, 0xa3, 0x11, 0xd0, 0x86, 0x87, 0x7e, 0x31, 0xb4, 0x1a, 0x27, 0x5d, 0xda, 0x77, 0xa3, 0xf5, 0x1d, 0x88, 0x79, 0xcf, 0xd5, 0x95, 0x75, 0xd, 0x47, 0xa1, 0x90, 0x5}} return a, nil } @@ -106,7 +106,7 @@ func _1619446565_postgres_make_anon_metrics_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1619446565_postgres_make_anon_metrics_table.up.sql", size: 443, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1619446565_postgres_make_anon_metrics_table.up.sql", size: 443, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd5, 0xdc, 0x72, 0x28, 0x3c, 0xf6, 0x94, 0xb0, 0x47, 0x3d, 0xca, 0x55, 0x3d, 0xf7, 0x83, 0xb8, 0x7d, 0x2f, 0x1e, 0x98, 0xb7, 0xde, 0xa, 0xff, 0xa0, 0x52, 0x60, 0x83, 0x56, 0xc5, 0xd1, 0xa2}} return a, nil } @@ -126,7 +126,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 380, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "doc.go", size: 380, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x49, 0x1, 0xd4, 0xd6, 0xc7, 0x44, 0xd4, 0xfd, 0x7b, 0x69, 0x1f, 0xe3, 0xe, 0x48, 0x14, 0x99, 0xf0, 0x8e, 0x43, 0xae, 0x54, 0x64, 0xa2, 0x8b, 0x82, 0x1c, 0x2b, 0xb, 0xec, 0xf5, 0xb3, 0xfc}} return a, nil } diff --git a/protocol/communities_messenger_test.go b/protocol/communities_messenger_test.go index bcc6fc887..820177ecd 100644 --- a/protocol/communities_messenger_test.go +++ b/protocol/communities_messenger_test.go @@ -18,7 +18,7 @@ import ( gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/communities" @@ -86,7 +86,7 @@ func (s *MessengerCommunitiesSuite) newMessengerWithOptions(shh types.Waku, priv } networks := json.RawMessage("{}") - settings := accounts.Settings{ + setting := settings.Settings{ Address: types.HexToAddress("0x1122334455667788990011223344556677889900"), AnonMetricsShouldSend: false, CurrentNetwork: "mainnet_rpc", @@ -108,7 +108,7 @@ func (s *MessengerCommunitiesSuite) newMessengerWithOptions(shh types.Waku, priv SendStatusUpdates: true, WalletRootAddress: types.HexToAddress("0x1122334455667788990011223344556677889900")} - _ = m.settings.CreateSettings(settings, config) + _ = m.settings.CreateSettings(setting, config) return m } diff --git a/protocol/contact.go b/protocol/contact.go index 29259e749..94a4a2770 100644 --- a/protocol/contact.go +++ b/protocol/contact.go @@ -6,7 +6,7 @@ import ( "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/images" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/identity/alias" "github.com/status-im/status-go/protocol/identity/identicon" ) @@ -33,8 +33,8 @@ func (c *Contact) CanonicalName() string { return c.Alias } -func (c *Contact) CanonicalImage(profilePicturesVisibility accounts.ProfilePicturesVisibilityType) string { - if profilePicturesVisibility == accounts.ProfilePicturesVisibilityNone || (profilePicturesVisibility == accounts.ProfilePicturesVisibilityContactsOnly && !c.Added) { +func (c *Contact) CanonicalImage(profilePicturesVisibility settings.ProfilePicturesVisibilityType) string { + if profilePicturesVisibility == settings.ProfilePicturesVisibilityNone || (profilePicturesVisibility == settings.ProfilePicturesVisibilityContactsOnly && !c.Added) { return c.Identicon } diff --git a/protocol/encryption/migrations/migrations.go b/protocol/encryption/migrations/migrations.go index d61f83e01..e6d44dad5 100644 --- a/protocol/encryption/migrations/migrations.go +++ b/protocol/encryption/migrations/migrations.go @@ -103,7 +103,7 @@ func _1536754952_initial_schemaDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1536754952_initial_schema.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1536754952_initial_schema.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x44, 0xcf, 0x76, 0x71, 0x1f, 0x5e, 0x9a, 0x43, 0xd8, 0xcd, 0xb8, 0xc3, 0x70, 0xc3, 0x7f, 0xfc, 0x90, 0xb4, 0x25, 0x1e, 0xf4, 0x66, 0x20, 0xb8, 0x33, 0x7e, 0xb0, 0x76, 0x1f, 0xc, 0xc0, 0x75}} return a, nil } @@ -123,7 +123,7 @@ func _1536754952_initial_schemaUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1536754952_initial_schema.up.sql", size: 962, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1536754952_initial_schema.up.sql", size: 962, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xea, 0x90, 0x5a, 0x59, 0x3e, 0x3, 0xe2, 0x3c, 0x81, 0x42, 0xcd, 0x4c, 0x9a, 0xe8, 0xda, 0x93, 0x2b, 0x70, 0xa4, 0xd5, 0x29, 0x3e, 0xd5, 0xc9, 0x27, 0xb6, 0xb7, 0x65, 0xff, 0x0, 0xcb, 0xde}} return a, nil } @@ -143,7 +143,7 @@ func _1539249977_update_ratchet_infoDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1539249977_update_ratchet_info.down.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1539249977_update_ratchet_info.down.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0xa4, 0xeb, 0xa0, 0xe6, 0xa0, 0xd4, 0x48, 0xbb, 0xad, 0x6f, 0x7d, 0x67, 0x8c, 0xbd, 0x25, 0xde, 0x1f, 0x73, 0x9a, 0xbb, 0xa8, 0xc9, 0x30, 0xb7, 0xa9, 0x7c, 0xaf, 0xb5, 0x1, 0x61, 0xdd}} return a, nil } @@ -163,7 +163,7 @@ func _1539249977_update_ratchet_infoUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1539249977_update_ratchet_info.up.sql", size: 368, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1539249977_update_ratchet_info.up.sql", size: 368, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc, 0x8e, 0xbf, 0x6f, 0xa, 0xc0, 0xe1, 0x3c, 0x42, 0x28, 0x88, 0x1d, 0xdb, 0xba, 0x1c, 0x83, 0xec, 0xba, 0xd3, 0x5f, 0x5c, 0x77, 0x5e, 0xa7, 0x46, 0x36, 0xec, 0x69, 0xa, 0x4b, 0x17, 0x79}} return a, nil } @@ -183,7 +183,7 @@ func _1540715431_add_versionDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1540715431_add_version.down.sql", size: 127, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1540715431_add_version.down.sql", size: 127, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x9, 0x4, 0xe3, 0x76, 0x2e, 0xb8, 0x9, 0x23, 0xf0, 0x70, 0x93, 0xc4, 0x50, 0xe, 0x9d, 0x84, 0x22, 0x8c, 0x94, 0xd3, 0x24, 0x9, 0x9a, 0xc1, 0xa1, 0x48, 0x45, 0xfd, 0x40, 0x6e, 0xe6}} return a, nil } @@ -203,7 +203,7 @@ func _1540715431_add_versionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1540715431_add_version.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1540715431_add_version.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc7, 0x4c, 0x36, 0x96, 0xdf, 0x16, 0x10, 0xa6, 0x27, 0x1a, 0x79, 0x8b, 0x42, 0x83, 0x23, 0xc, 0x7e, 0xb6, 0x3d, 0x2, 0xda, 0xa4, 0xb4, 0xd, 0x27, 0x55, 0xba, 0xdc, 0xb2, 0x88, 0x8f, 0xa6}} return a, nil } @@ -223,7 +223,7 @@ func _1541164797_add_installationsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1541164797_add_installations.down.sql", size: 26, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1541164797_add_installations.down.sql", size: 26, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0xfd, 0xe6, 0xd8, 0xca, 0x3b, 0x38, 0x18, 0xee, 0x0, 0x5f, 0x36, 0x9e, 0x1e, 0xd, 0x19, 0x3e, 0xb4, 0x73, 0x53, 0xe9, 0xa5, 0xac, 0xdd, 0xa1, 0x2f, 0xc7, 0x6c, 0xa8, 0xd9, 0xa, 0x88}} return a, nil } @@ -243,7 +243,7 @@ func _1541164797_add_installationsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1541164797_add_installations.up.sql", size: 216, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1541164797_add_installations.up.sql", size: 216, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2d, 0x18, 0x26, 0xb8, 0x88, 0x47, 0xdb, 0x83, 0xcc, 0xb6, 0x9d, 0x1c, 0x1, 0xae, 0x2f, 0xde, 0x97, 0x82, 0x3, 0x30, 0xa8, 0x63, 0xa1, 0x78, 0x4b, 0xa5, 0x9, 0x8, 0x75, 0xa2, 0x57, 0x81}} return a, nil } @@ -263,7 +263,7 @@ func _1558084410_add_secretDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558084410_add_secret.down.sql", size: 56, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1558084410_add_secret.down.sql", size: 56, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x49, 0xb, 0x65, 0xdf, 0x59, 0xbf, 0xe9, 0x5, 0x5b, 0x6f, 0xd5, 0x3a, 0xb7, 0x57, 0xe8, 0x78, 0x38, 0x73, 0x53, 0x57, 0xf7, 0x24, 0x4, 0xe4, 0xa2, 0x49, 0x22, 0xa2, 0xc6, 0xfd, 0x80, 0xa4}} return a, nil } @@ -283,7 +283,7 @@ func _1558084410_add_secretUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558084410_add_secret.up.sql", size: 301, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1558084410_add_secret.up.sql", size: 301, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x32, 0x36, 0x8e, 0x47, 0xb0, 0x8f, 0xc1, 0xc6, 0xf7, 0xc6, 0x9f, 0x2d, 0x44, 0x75, 0x2b, 0x26, 0xec, 0x6, 0xa0, 0x7b, 0xa5, 0xbd, 0xc8, 0x76, 0x8a, 0x82, 0x68, 0x2, 0x42, 0xb5, 0xf4}} return a, nil } @@ -303,7 +303,7 @@ func _1558588866_add_versionDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558588866_add_version.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1558588866_add_version.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x52, 0x34, 0x3c, 0x46, 0x4a, 0xf0, 0x72, 0x47, 0x6f, 0x49, 0x5c, 0xc7, 0xf9, 0x32, 0xce, 0xc4, 0x3d, 0xfd, 0x61, 0xa1, 0x8b, 0x8f, 0xf2, 0x31, 0x34, 0xde, 0x15, 0x49, 0xa6, 0xde, 0xb9}} return a, nil } @@ -323,7 +323,7 @@ func _1558588866_add_versionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558588866_add_version.up.sql", size: 57, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1558588866_add_version.up.sql", size: 57, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0xea, 0x64, 0x39, 0x61, 0x20, 0x83, 0x83, 0xb, 0x2e, 0x79, 0x64, 0xb, 0x53, 0xfa, 0xfe, 0xc6, 0xf7, 0x67, 0x42, 0xd3, 0x4f, 0xdc, 0x7e, 0x30, 0x32, 0xe8, 0x14, 0x41, 0xe9, 0xe7, 0x3b}} return a, nil } @@ -343,7 +343,7 @@ func _1559627659_add_contact_codeDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1559627659_add_contact_code.down.sql", size: 32, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1559627659_add_contact_code.down.sql", size: 32, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x64, 0x6d, 0xce, 0x24, 0x42, 0x20, 0x8d, 0x4f, 0x37, 0xaa, 0x9d, 0xc, 0x57, 0x98, 0xc1, 0xd1, 0x1a, 0x34, 0xcd, 0x9f, 0x8f, 0x34, 0x86, 0xb3, 0xd3, 0xdc, 0xf1, 0x7d, 0xe5, 0x1b, 0x6e}} return a, nil } @@ -363,7 +363,7 @@ func _1559627659_add_contact_codeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1559627659_add_contact_code.up.sql", size: 198, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1559627659_add_contact_code.up.sql", size: 198, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x16, 0xf6, 0xc2, 0x62, 0x9c, 0xd2, 0xc9, 0x1e, 0xd8, 0xea, 0xaa, 0xea, 0x95, 0x8f, 0x89, 0x6a, 0x85, 0x5d, 0x9d, 0x99, 0x78, 0x3c, 0x90, 0x66, 0x99, 0x3e, 0x4b, 0x19, 0x62, 0xfb, 0x31, 0x4d}} return a, nil } @@ -383,7 +383,7 @@ func _1561368210_add_installation_metadataDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561368210_add_installation_metadata.down.sql", size: 35, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1561368210_add_installation_metadata.down.sql", size: 35, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa8, 0xde, 0x3f, 0xd2, 0x4a, 0x50, 0x98, 0x56, 0xe3, 0xc0, 0xcd, 0x9d, 0xb0, 0x34, 0x3b, 0xe5, 0x62, 0x18, 0xb5, 0x20, 0xc9, 0x3e, 0xdc, 0x6a, 0x40, 0x36, 0x66, 0xea, 0x51, 0x8c, 0x71, 0xf5}} return a, nil } @@ -403,7 +403,7 @@ func _1561368210_add_installation_metadataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561368210_add_installation_metadata.up.sql", size: 267, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "1561368210_add_installation_metadata.up.sql", size: 267, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb4, 0x71, 0x8f, 0x29, 0xb1, 0xaa, 0xd6, 0xd1, 0x8c, 0x17, 0xef, 0x6c, 0xd5, 0x80, 0xb8, 0x2c, 0xc3, 0xfe, 0xec, 0x24, 0x4d, 0xc8, 0x25, 0xd3, 0xb4, 0xcd, 0xa9, 0xac, 0x63, 0x61, 0xb2, 0x9c}} return a, nil } @@ -423,7 +423,7 @@ func _1632236298_add_communitiesDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1632236298_add_communities.down.sql", size: 151, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1632236298_add_communities.down.sql", size: 151, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x26, 0xe5, 0x47, 0xd1, 0xe5, 0xec, 0x5b, 0x3e, 0xdc, 0x22, 0xf4, 0x27, 0xee, 0x70, 0xf3, 0x9, 0x4f, 0xd2, 0x9f, 0x92, 0xf, 0x5a, 0x18, 0x11, 0xb7, 0x40, 0xab, 0xf1, 0x98, 0x72, 0xd6, 0x60}} return a, nil } @@ -443,7 +443,7 @@ func _1632236298_add_communitiesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1632236298_add_communities.up.sql", size: 584, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1632236298_add_communities.up.sql", size: 584, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8f, 0xe0, 0x1, 0x6e, 0x84, 0xc, 0x35, 0xe4, 0x5a, 0xf, 0xbe, 0xcb, 0xf7, 0xd2, 0xa8, 0x25, 0xf5, 0xdb, 0x7, 0xcb, 0xa3, 0xe6, 0xf4, 0xc4, 0x1b, 0xa5, 0xec, 0x32, 0x1e, 0x1e, 0x48, 0x60}} return a, nil } @@ -463,7 +463,7 @@ func _1636536507_add_index_bundlesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1636536507_add_index_bundles.up.sql", size: 347, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1636536507_add_index_bundles.up.sql", size: 347, mode: os.FileMode(0644), modTime: time.Unix(1637232499, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf1, 0xb9, 0x3c, 0x16, 0xfc, 0xfb, 0xb2, 0xb4, 0x3b, 0xfe, 0xdc, 0xf5, 0x9c, 0x42, 0xa0, 0xa0, 0xd4, 0xd, 0x5b, 0x97, 0x10, 0x80, 0x95, 0xe, 0x13, 0xc1, 0x18, 0x8, 0xee, 0xf, 0x99, 0xee}} return a, nil } @@ -483,7 +483,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1603694100, 0)} + info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xef, 0xaf, 0xdf, 0xcf, 0x65, 0xae, 0x19, 0xfc, 0x9d, 0x29, 0xc1, 0x91, 0xaf, 0xb5, 0xd5, 0xb1, 0x56, 0xf3, 0xee, 0xa8, 0xba, 0x13, 0x65, 0xdb, 0xab, 0xcf, 0x4e, 0xac, 0x92, 0xe9, 0x60, 0xf1}} return a, nil } diff --git a/protocol/internal/sqlite/migrations.go b/protocol/internal/sqlite/migrations.go index f4832553b..13dc60b9c 100644 --- a/protocol/internal/sqlite/migrations.go +++ b/protocol/internal/sqlite/migrations.go @@ -183,8 +183,8 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ "000001_init.down.db.sql": _000001_initDownDbSql, - "000001_init.up.db.sql": _000001_initUpDbSql, - "doc.go": docGo, + "000001_init.up.db.sql": _000001_initUpDbSql, + "doc.go": docGo, } // AssetDir returns the file names below a certain @@ -226,10 +226,11 @@ type bintree struct { Func func() (*asset, error) Children map[string]*bintree } + var _bintree = &bintree{nil, map[string]*bintree{ "000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}}, - "000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, - "doc.go": &bintree{docGo, map[string]*bintree{}}, + "000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, + "doc.go": &bintree{docGo, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory diff --git a/protocol/local_notifications.go b/protocol/local_notifications.go index 88a8c5393..68ffdbaf4 100644 --- a/protocol/local_notifications.go +++ b/protocol/local_notifications.go @@ -5,7 +5,7 @@ import ( "encoding/json" gethcommon "github.com/ethereum/go-ethereum/common" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/communities" localnotifications "github.com/status-im/status-go/services/local-notifications" @@ -124,7 +124,7 @@ func (n NotificationBody) toMessageNotification(id string, contacts *contactMap, IsGroupConversation: true, Author: localnotifications.NotificationAuthor{ Name: n.Contact.CanonicalName(), - Icon: n.Contact.CanonicalImage(accounts.ProfilePicturesVisibilityType(profilePicturesVisibility)), + Icon: n.Contact.CanonicalImage(settings.ProfilePicturesVisibilityType(profilePicturesVisibility)), ID: n.Contact.ID, }, Timestamp: n.Message.WhisperTimestamp, @@ -144,7 +144,7 @@ func (n NotificationBody) toPrivateGroupInviteNotification(id string, profilePic Deeplink: n.Chat.DeepLink(), Author: localnotifications.NotificationAuthor{ Name: n.Contact.CanonicalName(), - Icon: n.Contact.CanonicalImage(accounts.ProfilePicturesVisibilityType(profilePicturesVisibility)), + Icon: n.Contact.CanonicalImage(settings.ProfilePicturesVisibilityType(profilePicturesVisibility)), ID: n.Contact.ID, }, Image: "", diff --git a/protocol/messenger.go b/protocol/messenger.go index f0f004b35..41582ef20 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -35,6 +35,7 @@ import ( userimage "github.com/status-im/status-go/images" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/anonmetrics" "github.com/status-im/status-go/protocol/audio" "github.com/status-im/status-go/protocol/common" @@ -382,7 +383,11 @@ func NewMessenger( if err != nil { return nil, err } - settings := accounts.NewDB(database) + + settings, err := accounts.NewDB(database) + if err != nil { + return nil, err + } mailservers := mailserversDB.NewDB(database) httpServer, err := server.NewServer(database, logger) @@ -634,6 +639,7 @@ func (m *Messenger) Start() (*MessengerResponse, error) { if err != nil { return nil, err } + m.startSyncSettingsLoop() if err := m.cleanTopics(); err != nil { return nil, err @@ -968,7 +974,7 @@ func (m *Messenger) attachIdentityImagesToChatIdentity(context chatContext, ci * return err } - if s.ProfilePicturesShowTo == accounts.ProfilePicturesShowToNone { + if s.ProfilePicturesShowTo == settings.ProfilePicturesShowToNone { m.logger.Info(fmt.Sprintf("settings.ProfilePicturesShowTo is set to '%d', skipping attaching IdentityImages", s.ProfilePicturesShowTo)) return nil } @@ -1014,7 +1020,7 @@ func (m *Messenger) attachIdentityImagesToChatIdentity(context chatContext, ci * return fmt.Errorf("unknown ChatIdentity context '%s'", context) } - if s.ProfilePicturesShowTo == accounts.ProfilePicturesShowToContactsOnly { + if s.ProfilePicturesShowTo == settings.ProfilePicturesShowToContactsOnly { err := EncryptIdentityImagesWithContactPubKeys(ci.Images, m) if err != nil { return err @@ -2607,6 +2613,11 @@ func (m *Messenger) SyncDevices(ctx context.Context, ensName, photoPath string) } } + err = m.syncSettings() + if err != nil { + return err + } + return err } @@ -3395,6 +3406,22 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte continue } + case protobuf.SyncSetting: + if !common.IsPubKeyEqual(messageState.CurrentMessageState.PublicKey, &m.identity.PublicKey) { + logger.Warn("not coming from us, ignoring") + continue + } + + ss := msg.ParsedMessage.Interface().(protobuf.SyncSetting) + logger.Debug("Handling SyncSetting", zap.Any("message", ss)) + + err := m.handleSyncSetting(messageState.Response, &ss) + if err != nil { + logger.Warn("failed to handle SyncSetting", zap.Error(err)) + allMessagesProcessed = false + continue + } + case protobuf.RequestAddressForTransaction: command := msg.ParsedMessage.Interface().(protobuf.RequestAddressForTransaction) logger.Debug("Handling RequestAddressForTransaction", zap.Any("message", command)) @@ -5280,8 +5307,11 @@ func (m *Messenger) BloomFilter() []byte { return m.transport.BloomFilter() } -func (m *Messenger) getSettings() (accounts.Settings, error) { - sDB := accounts.NewDB(m.database) +func (m *Messenger) getSettings() (settings.Settings, error) { + sDB, err := accounts.NewDB(m.database) + if err != nil { + return settings.Settings{}, err + } return sDB.GetSettings() } diff --git a/protocol/messenger_config.go b/protocol/messenger_config.go index 7bcf54a7b..a34d31378 100644 --- a/protocol/messenger_config.go +++ b/protocol/messenger_config.go @@ -11,6 +11,7 @@ import ( "github.com/status-im/status-go/appdatabase/migrations" "github.com/status-im/status-go/multiaccounts" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/anonmetrics" "github.com/status-im/status-go/protocol/common" @@ -125,7 +126,7 @@ func WithToplevelDatabaseMigrations() Option { } } -func WithAppSettings(s accounts.Settings, nc params.NodeConfig) Option { +func WithAppSettings(s settings.Settings, nc params.NodeConfig) Option { return func(c *config) error { c.afterDbCreatedHooks = append(c.afterDbCreatedHooks, func(c *config) error { if s.Networks == nil { @@ -137,7 +138,10 @@ func WithAppSettings(s accounts.Settings, nc params.NodeConfig) Option { s.Networks = networks } - sDB := accounts.NewDB(c.db) + sDB, err := accounts.NewDB(c.db) + if err != nil { + return err + } return sDB.CreateSettings(s, nc) }) return nil diff --git a/protocol/messenger_contact_update_test.go b/protocol/messenger_contact_update_test.go index ff1018416..3fec9f56d 100644 --- a/protocol/messenger_contact_update_test.go +++ b/protocol/messenger_contact_update_test.go @@ -11,6 +11,7 @@ import ( gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/tt" "github.com/status-im/status-go/waku" @@ -68,7 +69,7 @@ func (s *MessengerContactUpdateSuite) TestReceiveContactUpdate() { s.Require().NoError(err) // Set ENS name - err = theirMessenger.settings.SaveSetting("preferred-name", theirName) + err = theirMessenger.settings.SaveSettingField(settings.PreferredName, theirName) s.Require().NoError(err) theirContactID := types.EncodeHex(crypto.FromECDSAPub(&theirMessenger.identity.PublicKey)) diff --git a/protocol/messenger_display_name.go b/protocol/messenger_display_name.go index f12dc096f..12f1eec9d 100644 --- a/protocol/messenger_display_name.go +++ b/protocol/messenger_display_name.go @@ -5,6 +5,7 @@ import ( "regexp" "strings" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/identity/alias" ) @@ -57,7 +58,7 @@ func (m *Messenger) SetDisplayName(displayName string) error { return err } - err = m.settings.SaveSetting("display-name", displayName) + err = m.settings.SaveSettingField(settings.DisplayName, displayName) if err != nil { return err } diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 070ab9895..92b422581 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -12,7 +12,7 @@ import ( "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/images" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/communities" "github.com/status-im/status-go/protocol/encryption/multidevice" @@ -1453,8 +1453,8 @@ func (m *Messenger) HandleChatIdentity(state *ReceivedMessageState, ci protobuf. state.AllContacts.Store(contact.ID, contact) } - viewFromContacts := s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityContactsOnly - viewFromNoOne := s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityNone + viewFromContacts := s.ProfilePicturesVisibility == settings.ProfilePicturesVisibilityContactsOnly + viewFromNoOne := s.ProfilePicturesVisibility == settings.ProfilePicturesVisibilityNone m.logger.Debug("settings found", zap.Bool("viewFromContacts", viewFromContacts), diff --git a/protocol/messenger_identity_image_test.go b/protocol/messenger_identity_image_test.go index ca9984a58..8416ea382 100644 --- a/protocol/messenger_identity_image_test.go +++ b/protocol/messenger_identity_image_test.go @@ -16,7 +16,7 @@ import ( "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/images" "github.com/status-im/status-go/multiaccounts" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/protobuf" "github.com/status-im/status-go/protocol/requests" "github.com/status-im/status-go/protocol/tt" @@ -221,10 +221,10 @@ func (s *MessengerProfilePictureHandlerSuite) TestEncryptDecryptIdentityImagesWi func (s *MessengerProfilePictureHandlerSuite) TestPictureInPrivateChatOneSided() { s.setupTest() - err := s.bob.settings.SaveSetting("profile-pictures-visibility", accounts.ProfilePicturesShowToEveryone) + err := s.bob.settings.SaveSettingField(settings.ProfilePicturesVisibility, settings.ProfilePicturesShowToEveryone) s.Require().NoError(err) - err = s.alice.settings.SaveSetting("profile-pictures-visibility", accounts.ProfilePicturesShowToEveryone) + err = s.alice.settings.SaveSettingField(settings.ProfilePicturesVisibility, settings.ProfilePicturesShowToEveryone) s.Require().NoError(err) bChat := CreateOneToOneChat(s.generateKeyUID(&s.aliceKey.PublicKey), &s.aliceKey.PublicKey, s.alice.transport) @@ -265,16 +265,16 @@ func (s *MessengerProfilePictureHandlerSuite) TestPictureInPrivateChatOneSided() } func (s *MessengerProfilePictureHandlerSuite) TestE2eSendingReceivingProfilePicture() { - profilePicShowSettings := map[string]accounts.ProfilePicturesShowToType{ - "ShowToContactsOnly": accounts.ProfilePicturesShowToContactsOnly, - "ShowToEveryone": accounts.ProfilePicturesShowToEveryone, - "ShowToNone": accounts.ProfilePicturesShowToNone, + profilePicShowSettings := map[string]settings.ProfilePicturesShowToType{ + "ShowToContactsOnly": settings.ProfilePicturesShowToContactsOnly, + "ShowToEveryone": settings.ProfilePicturesShowToEveryone, + "ShowToNone": settings.ProfilePicturesShowToNone, } - profilePicViewSettings := map[string]accounts.ProfilePicturesVisibilityType{ - "ViewFromContactsOnly": accounts.ProfilePicturesVisibilityContactsOnly, - "ViewFromEveryone": accounts.ProfilePicturesVisibilityEveryone, - "ViewFromNone": accounts.ProfilePicturesVisibilityNone, + profilePicViewSettings := map[string]settings.ProfilePicturesVisibilityType{ + "ViewFromContactsOnly": settings.ProfilePicturesVisibilityContactsOnly, + "ViewFromEveryone": settings.ProfilePicturesVisibilityEveryone, + "ViewFromNone": settings.ProfilePicturesVisibilityNone, } isContactFor := map[string][]bool{ @@ -312,7 +312,7 @@ func (s *MessengerProfilePictureHandlerSuite) TestE2eSendingReceivingProfilePict s.logger.Debug("Setting up test criteria for Bob") s.logger.Debug("Save bob profile-pictures-visibility setting before") - err = s.bob.settings.SaveSetting("profile-pictures-visibility", vs) + err = s.bob.settings.SaveSettingField(settings.ProfilePicturesVisibility, vs) s.Require().NoError(err) s.logger.Debug("Save bob profile-pictures-visibility setting after") @@ -359,7 +359,7 @@ func (s *MessengerProfilePictureHandlerSuite) TestE2eSendingReceivingProfilePict s.logger.Debug("Setting up test criteria for Alice") s.logger.Debug("Save alice profile-pictures-show-to setting before") - err = s.alice.settings.SaveSetting("profile-pictures-show-to", ss) + err = s.alice.settings.SaveSettingField(settings.ProfilePicturesShowTo, ss) s.Require().NoError(err) s.logger.Debug("Save alice profile-pictures-show-to setting after") @@ -535,29 +535,29 @@ func (s *MessengerProfilePictureHandlerSuite) TestE2eSendingReceivingProfilePict s.setupTest() } -func resultExpected(ss accounts.ProfilePicturesShowToType, vs accounts.ProfilePicturesVisibilityType, ac, bc bool) (bool, error) { +func resultExpected(ss settings.ProfilePicturesShowToType, vs settings.ProfilePicturesVisibilityType, ac, bc bool) (bool, error) { switch ss { - case accounts.ProfilePicturesShowToContactsOnly: + case settings.ProfilePicturesShowToContactsOnly: if ac { return resultExpectedVS(vs, bc) } return false, nil - case accounts.ProfilePicturesShowToEveryone: + case settings.ProfilePicturesShowToEveryone: return resultExpectedVS(vs, bc) - case accounts.ProfilePicturesShowToNone: + case settings.ProfilePicturesShowToNone: return false, nil default: return false, errors.New("unknown ProfilePicturesShowToType") } } -func resultExpectedVS(vs accounts.ProfilePicturesVisibilityType, bc bool) (bool, error) { +func resultExpectedVS(vs settings.ProfilePicturesVisibilityType, bc bool) (bool, error) { switch vs { - case accounts.ProfilePicturesVisibilityContactsOnly: + case settings.ProfilePicturesVisibilityContactsOnly: return true, nil - case accounts.ProfilePicturesVisibilityEveryone: + case settings.ProfilePicturesVisibilityEveryone: return true, nil - case accounts.ProfilePicturesVisibilityNone: + case settings.ProfilePicturesVisibilityNone: // If we are contacts, we save the image regardless return bc, nil default: diff --git a/protocol/messenger_response.go b/protocol/messenger_response.go index 5abfcdb59..3be562ca7 100644 --- a/protocol/messenger_response.go +++ b/protocol/messenger_response.go @@ -6,6 +6,7 @@ import ( "github.com/status-im/status-go/services/browsers" "github.com/status-im/status-go/appmetrics" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/communities" "github.com/status-im/status-go/protocol/encryption/multidevice" @@ -33,6 +34,7 @@ type MessengerResponse struct { AnonymousMetrics []*appmetrics.AppMetric Mailservers []mailservers.Mailserver Bookmarks []*browsers.Bookmark + Settings []*settings.SyncSettingField // notifications a list of notifications derived from messenger events // that are useful to notify the user about @@ -74,6 +76,7 @@ func (r *MessengerResponse) MarshalJSON() ([]byte, error) { ActivityCenterNotifications []*ActivityCenterNotification `json:"activityCenterNotifications,omitempty"` CurrentStatus *UserStatus `json:"currentStatus,omitempty"` StatusUpdates []UserStatus `json:"statusUpdates,omitempty"` + Settings []*settings.SyncSettingField `json:"settings,omitempty"` }{ Contacts: r.Contacts, Installations: r.Installations, @@ -84,19 +87,20 @@ func (r *MessengerResponse) MarshalJSON() ([]byte, error) { Mailservers: r.Mailservers, Bookmarks: r.Bookmarks, CurrentStatus: r.currentStatus, - } + Settings: r.Settings, - responseItem.Messages = r.Messages() - responseItem.Notifications = r.Notifications() - responseItem.Chats = r.Chats() - responseItem.Communities = r.Communities() - responseItem.CommunitiesSettings = r.CommunitiesSettings() - responseItem.RemovedChats = r.RemovedChats() - responseItem.RemovedMessages = r.RemovedMessages() - responseItem.ClearedHistories = r.ClearedHistories() - responseItem.ActivityCenterNotifications = r.ActivityCenterNotifications() - responseItem.PinMessages = r.PinMessages() - responseItem.StatusUpdates = r.StatusUpdates() + Messages: r.Messages(), + Notifications: r.Notifications(), + Chats: r.Chats(), + Communities: r.Communities(), + CommunitiesSettings: r.CommunitiesSettings(), + RemovedChats: r.RemovedChats(), + RemovedMessages: r.RemovedMessages(), + ClearedHistories: r.ClearedHistories(), + ActivityCenterNotifications: r.ActivityCenterNotifications(), + PinMessages: r.PinMessages(), + StatusUpdates: r.StatusUpdates(), + } return json.Marshal(responseItem) } @@ -181,6 +185,7 @@ func (r *MessengerResponse) IsEmpty() bool { len(r.Contacts)+ len(r.Bookmarks)+ len(r.clearedHistories)+ + len(r.Settings)+ len(r.Installations)+ len(r.Invitations)+ len(r.EmojiReactions)+ diff --git a/protocol/messenger_status_updates.go b/protocol/messenger_status_updates.go index e334c5d59..3ecc10387 100644 --- a/protocol/messenger_status_updates.go +++ b/protocol/messenger_status_updates.go @@ -8,6 +8,7 @@ import ( "github.com/golang/protobuf/proto" "go.uber.org/zap" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/communities" "github.com/status-im/status-go/protocol/protobuf" @@ -44,7 +45,7 @@ func (m *Messenger) sendUserStatus(ctx context.Context, status UserStatus) error status.Clock = uint64(time.Now().Unix()) - err = m.settings.SaveSetting("current-user-status", status) + err = m.settings.SaveSettingField(settings.CurrentUserStatus, status) if err != nil { return err } @@ -140,7 +141,7 @@ func (m *Messenger) sendCurrentUserStatusToCommunity(ctx context.Context, commun status.Clock = uint64(time.Now().Unix()) - err = m.settings.SaveSetting("current-user-status", status) + err = m.settings.SaveSettingField(settings.CurrentUserStatus, status) if err != nil { logger.Debug("m.settings.SaveSetting error", zap.Any("current-user-status", status), @@ -244,7 +245,7 @@ func (m *Messenger) HandleStatusUpdate(state *ReceivedMessageState, statusMessag return nil // older status message, or status does not change ignoring it } newStatus := ToUserStatus(statusMessage) - err = m.settings.SaveSetting("current-user-status", newStatus) + err = m.settings.SaveSettingField(settings.CurrentUserStatus, newStatus) if err != nil { return err } diff --git a/protocol/messenger_sync_settings.go b/protocol/messenger_sync_settings.go new file mode 100644 index 000000000..c94199820 --- /dev/null +++ b/protocol/messenger_sync_settings.go @@ -0,0 +1,134 @@ +package protocol + +import ( + "context" + + "go.uber.org/zap" + + "github.com/status-im/status-go/multiaccounts/errors" + "github.com/status-im/status-go/multiaccounts/settings" + "github.com/status-im/status-go/protocol/protobuf" +) + +// syncSettings syncs all settings that are syncable +func (m *Messenger) syncSettings() error { + logger := m.logger.Named("syncSettings") + + s, err := m.settings.GetSettings() + if err != nil { + return err + } + + // Do not use the network clock, use the db value + _, chat := m.getLastClockWithRelatedChat() + + var errs []error + for _, sf := range settings.SettingFieldRegister { + if sf.CanSync(settings.FromStruct) { + // Pull clock from the db + clock, err := m.settings.GetSettingLastSynced(sf) + if err != nil { + logger.Error("m.settings.GetSettingLastSynced", zap.Error(err), zap.Any("SettingField", sf)) + return err + } + + // Build protobuf + rm, err := sf.SyncProtobufFactory().FromStruct()(s, clock, chat.ID) + if err != nil { + // Collect errors to give other sync messages a chance to send + logger.Error("SyncProtobufFactory.Struct", zap.Error(err)) + errs = append(errs, err) + } + + _, err = m.dispatchMessage(context.Background(), *rm) + if err != nil { + logger.Error("dispatchMessage", zap.Error(err)) + return err + } + logger.Debug("dispatchMessage success", zap.Any("rm", rm)) + } + } + + if len(errs) != 0 { + // return just the first error, the others have been logged + return errs[0] + } + return nil +} + +// handleSyncSetting parses incoming *protobuf.SyncSetting and stores the setting data if needed +func (m *Messenger) handleSyncSetting(response *MessengerResponse, syncSetting *protobuf.SyncSetting) error { + sf, err := settings.GetFieldFromProtobufType(syncSetting.Type) + if err != nil { + m.logger.Error( + "handleSyncSetting - settings.GetFieldFromProtobufType", + zap.Error(err), + zap.Any("syncSetting", syncSetting), + ) + return err + } + + spf := sf.SyncProtobufFactory() + if spf == nil { + m.logger.Warn("handleSyncSetting - received protobuf for setting with no SyncProtobufFactory", zap.Any("SettingField", sf)) + return nil + } + if spf.Inactive() { + m.logger.Warn("handleSyncSetting - received protobuf for inactive sync setting", zap.Any("SettingField", sf)) + return nil + } + + value := spf.ExtractValueFromProtobuf()(syncSetting) + + err = m.settings.SaveSyncSetting(sf, value, syncSetting.Clock) + if err == errors.ErrNewClockOlderThanCurrent { + m.logger.Info("handleSyncSetting - SaveSyncSetting :", zap.Error(err)) + return nil + } + if err != nil { + return err + } + + response.Settings = append(response.Settings, &settings.SyncSettingField{SettingField: sf, Value: value}) + return nil +} + +// startSyncSettingsLoop watches the m.settings.SyncQueue and sends a sync message in response to a settings update +func (m *Messenger) startSyncSettingsLoop() { + go func() { + logger := m.logger.Named("SyncSettingsLoop") + + for { + select { + case s := <-m.settings.SyncQueue: + if s.CanSync(settings.FromInterface) { + logger.Debug("setting for sync received from settings.SyncQueue") + + clock, chat := m.getLastClockWithRelatedChat() + + // Only the messenger has access to the clock, so set the settings sync clock here. + err := m.settings.SetSettingLastSynced(s.SettingField, clock) + if err != nil { + logger.Error("m.settings.SetSettingLastSynced", zap.Error(err)) + break + } + rm, err := s.SyncProtobufFactory().FromInterface()(s.Value, clock, chat.ID) + if err != nil { + logger.Error("SyncProtobufFactory().FromInterface", zap.Error(err), zap.Any("SyncSettingField", s)) + break + } + + _, err = m.dispatchMessage(context.Background(), *rm) + if err != nil { + logger.Error("dispatchMessage", zap.Error(err)) + break + } + + logger.Debug("message dispatched") + } + case <-m.quit: + return + } + } + }() +} diff --git a/protocol/messenger_sync_settings_test.go b/protocol/messenger_sync_settings_test.go new file mode 100644 index 000000000..270b9264e --- /dev/null +++ b/protocol/messenger_sync_settings_test.go @@ -0,0 +1,404 @@ +package protocol + +import ( + "context" + "crypto/ecdsa" + "encoding/json" + "errors" + "io/ioutil" + "testing" + + "github.com/google/uuid" + "github.com/stretchr/testify/suite" + "go.uber.org/zap" + + gethbridge "github.com/status-im/status-go/eth-node/bridge/geth" + "github.com/status-im/status-go/eth-node/crypto" + "github.com/status-im/status-go/eth-node/types" + "github.com/status-im/status-go/multiaccounts/settings" + "github.com/status-im/status-go/params" + "github.com/status-im/status-go/protocol/encryption/multidevice" + "github.com/status-im/status-go/protocol/tt" + "github.com/status-im/status-go/services/stickers" + "github.com/status-im/status-go/waku" +) + +var ( + pf = "A Preferred Name" + pf2 = "AnotherPreferredName.eth" + rawSticker = []byte(`{ + "1":{ + "author":"cryptoworld1373", + "id":1, + "name":"Status Cat", + "preview":"e3010170122050efc0a3e661339f31e1e44b3d15a1bf4e501c965a0523f57b701667fa90ccca", + "price":0, + "stickers":[ + {"hash":"e30101701220eab9a8ef4eac6c3e5836a3768d8e04935c10c67d9a700436a0e53199e9b64d29"}, + {"hash":"e30101701220c8f28aebe4dbbcee896d1cdff89ceeaceaf9f837df55c79125388f954ee5f1fe"}, + {"hash":"e301017012204861f93e29dd8e7cf6699135c7b13af1bce8ceeaa1d9959ab8592aa20f05d15f"}, + {"hash":"e301017012203ffa57a51cceaf2ce040852de3b300d395d5ba4d70e08ba993f93a25a387e3a9"}, + {"hash":"e301017012204f2674db0bc7f7cfc0382d1d7f79b4ff73c41f5c487ef4c3bb3f3a4cf3f87d70"}, + {"hash":"e30101701220e8d4d8b9fb5f805add2f63c1cb5c891e60f9929fc404e3bb725aa81628b97b5f"}, + {"hash":"e301017012206fdad56fe7a2facb02dabe8294f3ac051443fcc52d67c2fbd8615eb72f9d74bd"}, + {"hash":"e30101701220a691193cf0559905c10a3c5affb9855d730eae05509d503d71327e6c820aaf98"}, + {"hash":"e30101701220d8004af925f8e85b4e24813eaa5ef943fa6a0c76035491b64fbd2e632a5cc2fd"}, + {"hash":"e3010170122049f7bc650615568f14ee1cfa9ceaf89bfbc4745035479a7d8edee9b4465e64de"}, + {"hash":"e301017012201915dc0faad8e6783aca084a854c03553450efdabf977d57b4f22f73d5c53b50"}, + {"hash":"e301017012200b9fb71a129048c2a569433efc8e4d9155c54d598538be7f65ea26f665be1e84"}, + {"hash":"e30101701220d37944e3fb05213d45416fa634cf9e10ec1f43d3bf72c4eb3062ae6cc4ed9b08"}, + {"hash":"e3010170122059390dca66ba8713a9c323925bf768612f7dd16298c13a07a6b47cb5af4236e6"}, + {"hash":"e30101701220daaf88ace8a3356559be5d6912d5d442916e3cc92664954526c9815d693dc32b"}, + {"hash":"e301017012203ae30594fdf56d7bfd686cef1a45c201024e9c10a792722ef07ba968c83c064d"}, + {"hash":"e3010170122016e5eba0bbd32fc1ff17d80d1247fc67432705cd85731458b52febb84fdd6408"}, + {"hash":"e3010170122014fe2c2186cbf9d15ff61e04054fd6b0a5dbd7f365a1807f6f3d3d3e93e50875"}, + {"hash":"e30101701220f23a7dad3ea7ad3f3553a98fb305148d285e4ebf66b427d85a2340f66d51da94"}, + {"hash":"e3010170122047a637c6af02904a8ae702ec74b3df5fd8914df6fb11c99446a36d890beeb7ee"}, + {"hash":"e30101701220776f1ff89f6196ae68414545f6c6a5314c35eee7406cb8591d607a2b0533cc86"} + ], + "thumbnail":"e30101701220e9876531554a7cb4f20d7ebbf9daef2253e6734ad9c96ba288586a9b88bef491" + } +}`) +) + +func TestMessengerSyncSettings(t *testing.T) { + suite.Run(t, new(MessengerSyncSettingsSuite)) +} + +type MessengerSyncSettingsSuite struct { + suite.Suite + alice *Messenger + alice2 *Messenger + // If one wants to send messages between different instances of Messenger, + // a single Waku service should be shared. + shh types.Waku + logger *zap.Logger + + ignoreTests bool +} + +func (s *MessengerSyncSettingsSuite) SetupSuite() { + s.ignoreTests = true +} + +func (s *MessengerSyncSettingsSuite) SetupTest() { + s.logger = tt.MustCreateTestLogger() + + config := waku.DefaultConfig + config.MinimumAcceptedPoW = 0 + shh := waku.New(&config, s.logger) + s.shh = gethbridge.NewGethWakuWrapper(shh) + s.Require().NoError(shh.Start()) + + s.alice = s.newMessenger() + _, err := s.alice.Start() + s.Require().NoError(err) + + s.alice2, err = newMessengerWithKey(s.shh, s.alice.identity, s.logger, nil) + s.Require().NoError(err) + + s.prepAliceMessengersForPairing() +} + +func (s *MessengerSyncSettingsSuite) TearDownTest() { + s.Require().NoError(s.alice.Shutdown()) + _ = s.logger.Sync() +} + +func (s *MessengerSyncSettingsSuite) newMessengerWithOptions(shh types.Waku, privateKey *ecdsa.PrivateKey, options []Option) *Messenger { + m, err := NewMessenger( + "Test", + privateKey, + &testNode{shh: shh}, + uuid.New().String(), + nil, + options..., + ) + s.Require().NoError(err) + + err = m.Init() + s.Require().NoError(err) + + config := params.NodeConfig{ + NetworkID: 10, + DataDir: "test", + } + + networks := json.RawMessage("{}") + setting := settings.Settings{ + Address: types.HexToAddress("0x1122334455667788990011223344556677889900"), + AnonMetricsShouldSend: false, + CurrentNetwork: "mainnet_rpc", + DappsAddress: types.HexToAddress("0x1122334455667788990011223344556677889900"), + InstallationID: "d3efcff6-cffa-560e-a547-21d3858cbc51", + KeyUID: "0x1122334455667788990011223344556677889900", + LatestDerivedPath: 0, + Name: "Test", + Networks: &networks, + PhotoPath: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAAjklEQVR4nOzXwQmFMBAAUZXUYh32ZB32ZB02sxYQQSZGsod55/91WFgSS0RM+SyjA56ZRZhFmEWYRRT6h+M6G16zrxv6fdJpmUWYRbxsYr13dKfanpN0WmYRZhGzXz6AWYRZRIfbaX26fT9Jk07LLMIsosPt9I/dTDotswizCG+nhFmEWYRZhFnEHQAA///z1CFkYamgfQAAAABJRU5ErkJggg==", + PreviewPrivacy: false, + PublicKey: "0x04112233445566778899001122334455667788990011223344556677889900112233445566778899001122334455667788990011223344556677889900", + SigningPhrase: "yurt joey vibe", + SendPushNotifications: true, + ProfilePicturesVisibility: 1, + DefaultSyncPeriod: 86400, + UseMailservers: true, + LinkPreviewRequestEnabled: true, + SendStatusUpdates: true, + WalletRootAddress: types.HexToAddress("0x1122334455667788990011223344556677889900")} + + err = m.settings.CreateSettings(setting, config) + s.Require().NoError(err) + + err = m.settings.SaveSettingField(settings.PreferredName, &pf) + s.Require().NoError(err) + + err = m.settings.SaveSettingField(settings.Currency, "eth") + s.Require().NoError(err) + + return m +} + +func (s *MessengerSyncSettingsSuite) newMessengerWithKey(shh types.Waku, privateKey *ecdsa.PrivateKey) *Messenger { + tmpFile, err := ioutil.TempFile("", "") + s.Require().NoError(err) + + options := []Option{ + WithCustomLogger(s.logger), + WithDatabaseConfig(tmpFile.Name(), ""), + WithDatasync(), + } + return s.newMessengerWithOptions(shh, privateKey, options) +} + +func (s *MessengerSyncSettingsSuite) newMessenger() *Messenger { + privateKey, err := crypto.GenerateKey() + s.Require().NoError(err) + + return s.newMessengerWithKey(s.shh, privateKey) +} + +func (s *MessengerSyncSettingsSuite) pairTwoDevices(device1, device2 *Messenger) { + // Send pairing data + response, err := device1.SendPairInstallation(context.Background()) + s.Require().NoError(err) + s.Require().NotNil(response) + s.Len(response.Chats(), 1) + s.False(response.Chats()[0].Active) + + i, ok := device1.allInstallations.Load(device1.installationID) + s.Require().True(ok) + + // Wait for the message to reach its destination + response, err = WaitOnMessengerResponse( + device2, + func(r *MessengerResponse) bool { + for _, installation := range r.Installations { + if installation.ID == device1.installationID { + return installation.InstallationMetadata != nil && + i.InstallationMetadata.Name == installation.InstallationMetadata.Name && + i.InstallationMetadata.DeviceType == installation.InstallationMetadata.DeviceType + } + } + return false + + }, + "installation not received", + ) + s.Require().NoError(err) + s.Require().NotNil(response) + + // Ensure installation is enabled + err = device2.EnableInstallation(device1.installationID) + s.Require().NoError(err) +} + +func (s *MessengerSyncSettingsSuite) prepAliceMessengersForPairing() { + // Set Alice's installation metadata + aim := &multidevice.InstallationMetadata{ + Name: "alice's-device", + DeviceType: "alice's-device-type", + } + err := s.alice.SetInstallationMetadata(s.alice.installationID, aim) + s.Require().NoError(err) + + // Set Alice 2's installation metadata + a2im := &multidevice.InstallationMetadata{ + Name: "alice's-other-device", + DeviceType: "alice's-other-device-type", + } + err = s.alice2.SetInstallationMetadata(s.alice2.installationID, a2im) + s.Require().NoError(err) +} + +func (s *MessengerSyncSettingsSuite) TestSyncSettings() { + // Pair alice's two devices + s.pairTwoDevices(s.alice2, s.alice) + s.pairTwoDevices(s.alice, s.alice2) + + // Check alice 1 settings values + as, err := s.alice.settings.GetSettings() + s.Require().NoError(err) + s.Require().Exactly(settings.ProfilePicturesShowToContactsOnly, as.ProfilePicturesShowTo) + s.Require().Exactly(settings.ProfilePicturesVisibilityContactsOnly, as.ProfilePicturesVisibility) + + // Check alice 2 settings values + aos, err := s.alice2.settings.GetSettings() + s.Require().NoError(err) + s.Require().Exactly(settings.ProfilePicturesShowToContactsOnly, aos.ProfilePicturesShowTo) + s.Require().Exactly(settings.ProfilePicturesVisibilityContactsOnly, aos.ProfilePicturesVisibility) + + // Update alice ProfilePicturesVisibility setting + err = s.alice.settings.SaveSettingField(settings.ProfilePicturesVisibility, settings.ProfilePicturesVisibilityEveryone) + s.Require().NoError(err) + + // Wait for the message to reach its destination + err = tt.RetryWithBackOff(func() error { + mr, err := s.alice2.RetrieveAll() + if err != nil { + return err + } + + if len(mr.Settings) == 0 { + return errors.New("sync settings not in MessengerResponse") + } + + return nil + }) + s.Require().NoError(err) + + // Check alice 2 settings values + aos, err = s.alice2.settings.GetSettings() + s.Require().NoError(err) + s.Require().Equal(settings.ProfilePicturesVisibilityEveryone, aos.ProfilePicturesVisibility) + + // Alice 2 updated a setting which triggers the sync functionality + err = s.alice2.settings.SaveSettingField(settings.ProfilePicturesShowTo, settings.ProfilePicturesShowToEveryone) + s.Require().NoError(err) + + // Wait for the message to reach its destination + err = tt.RetryWithBackOff(func() error { + mr, err := s.alice.RetrieveAll() + if err != nil { + return err + } + + if len(mr.Settings) == 0 { + return errors.New("sync settings not in MessengerResponse") + } + + return nil + }) + s.Require().NoError(err) + + // Check alice 1 settings values + as, err = s.alice.settings.GetSettings() + s.Require().NoError(err) + s.Require().Exactly(settings.ProfilePicturesShowToEveryone, as.ProfilePicturesShowTo) +} + +func (s *MessengerSyncSettingsSuite) TestSyncSettings_StickerPacks() { + if s.ignoreTests { + s.T().Skip("Currently sticker pack syncing has been deactivated, testing to resume after sticker packs works correctly") + return + } + + // Check alice 1 settings values + as, err := s.alice.settings.GetSettings() + s.Require().NoError(err) + s.Require().Nil(as.StickerPacksInstalled) + s.Require().Nil(as.StickerPacksPending) + s.Require().Nil(as.StickersRecentStickers) + + // Check alice 2 settings values + aos, err := s.alice2.settings.GetSettings() + s.Require().NoError(err) + s.Require().Nil(aos.StickerPacksInstalled) + s.Require().Nil(aos.StickerPacksPending) + s.Require().Nil(aos.StickersRecentStickers) + + // Pair devices. Allows alice to send to alicesOtherDevice + s.pairTwoDevices(s.alice2, s.alice) + + // Add sticker pack to alice device + stickerPacks := make(stickers.StickerPackCollection) + err = json.Unmarshal(rawSticker, &stickerPacks) + s.Require().NoError(err) + + err = s.alice.settings.SaveSettingField(settings.StickersPacksInstalled, stickerPacks) + s.Require().NoError(err) + + as, err = s.alice.settings.GetSettings() + s.Require().NoError(err) + spi, err := as.StickerPacksInstalled.MarshalJSON() + s.Require().NoError(err) + s.Require().Equal(2169, len(spi)) + + // Wait for the message to reach its destination + err = tt.RetryWithBackOff(func() error { + mr, err := s.alice2.RetrieveAll() + if err != nil { + return err + } + + if len(mr.Settings) == 0 { + return errors.New("sync settings not in MessengerResponse") + } + + return nil + }) + s.Require().NoError(err) + + aos, err = s.alice2.settings.GetSettings() + s.Require().NoError(err) + ospi, err := aos.StickerPacksInstalled.MarshalJSON() + s.Require().NoError(err) + s.Require().Exactly(spi, ospi) +} + +func (s *MessengerSyncSettingsSuite) TestSyncSettings_PreferredName() { + if s.ignoreTests { + s.T().Skip("Currently preferred syncing has been deactivated, testing to resume after ens names also sync") + return + } + + // Check alice 1 settings values + as, err := s.alice.settings.GetSettings() + s.Require().NoError(err) + s.Require().Equal(pf, *as.PreferredName) + + // Check alice 2 settings values + aos, err := s.alice2.settings.GetSettings() + s.Require().NoError(err) + s.Require().Nil(aos.PreferredName) + + // Pair devices. Allows alice to send to alicesOtherDevice + s.pairTwoDevices(s.alice2, s.alice) + + // Update Alice's PreferredName + err = s.alice.settings.SaveSettingField(settings.PreferredName, pf2) + s.Require().NoError(err) + + apn, err := s.alice.settings.GetPreferredUsername() + s.Require().NoError(err) + s.Require().Equal(pf2, apn) + + // Wait for the sync message to reach its destination + err = tt.RetryWithBackOff(func() error { + mr, err := s.alice2.RetrieveAll() + if err != nil { + return err + } + + if len(mr.Settings) == 0 { + return errors.New("sync settings not in MessengerResponse") + } + + return nil + }) + s.Require().NoError(err) + + opn, err := s.alice2.settings.GetPreferredUsername() + s.Require().NoError(err) + s.Require().Equal(pf2, opn) +} diff --git a/protocol/messenger_test.go b/protocol/messenger_test.go index dd1de7201..29c42881d 100644 --- a/protocol/messenger_test.go +++ b/protocol/messenger_test.go @@ -24,7 +24,7 @@ import ( "github.com/status-im/status-go/eth-node/types" enstypes "github.com/status-im/status-go/eth-node/types/ens" "github.com/status-im/status-go/multiaccounts" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/protobuf" @@ -130,7 +130,7 @@ func newMessengerWithKey(shh types.Waku, privateKey *ecdsa.PrivateKey, logger *z WithAccount(iai.ToMultiAccount()), WithDatasync(), WithToplevelDatabaseMigrations(), - WithAppSettings(accounts.Settings{}, params.NodeConfig{}), + WithAppSettings(settings.Settings{}, params.NodeConfig{}), WithBrowserDatabase(nil), } diff --git a/protocol/migrations/migrations.go b/protocol/migrations/migrations.go index a6b3c6acc..68223bd14 100644 --- a/protocol/migrations/migrations.go +++ b/protocol/migrations/migrations.go @@ -135,7 +135,7 @@ func _000001_initDownDbSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1610007618, 0)} + info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5e, 0xbb, 0x3f, 0x1, 0x75, 0x19, 0x70, 0x86, 0xa7, 0x34, 0x40, 0x17, 0x34, 0x3e, 0x18, 0x51, 0x79, 0xd4, 0x22, 0xad, 0x8f, 0x80, 0xcc, 0xa6, 0xcc, 0x6, 0x2b, 0x62, 0x2, 0x47, 0xba, 0xf9}} return a, nil } @@ -155,7 +155,7 @@ func _000001_initUpDbSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2719, mode: os.FileMode(0644), modTime: time.Unix(1610007618, 0)} + info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2719, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x60, 0xdc, 0xeb, 0xe, 0xc2, 0x4f, 0x75, 0xa, 0xf6, 0x3e, 0xc7, 0xc4, 0x4, 0xe2, 0xe1, 0xa4, 0x73, 0x2f, 0x4a, 0xad, 0x1a, 0x0, 0xc3, 0x93, 0x9d, 0x77, 0x3e, 0x31, 0x91, 0x77, 0x2e, 0xc8}} return a, nil } @@ -175,7 +175,7 @@ func _000002_add_last_ens_clock_valueUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000002_add_last_ens_clock_value.up.sql", size: 77, mode: os.FileMode(0644), modTime: time.Unix(1610007618, 0)} + info := bindataFileInfo{name: "000002_add_last_ens_clock_value.up.sql", size: 77, mode: os.FileMode(0644), modTime: time.Unix(1589413297, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4d, 0x3, 0x8f, 0xd5, 0x85, 0x83, 0x47, 0xbe, 0xf9, 0x82, 0x7e, 0x81, 0xa4, 0xbd, 0xaa, 0xd5, 0x98, 0x18, 0x5, 0x2d, 0x82, 0x42, 0x3b, 0x3, 0x50, 0xc3, 0x1e, 0x84, 0x35, 0xf, 0xb6, 0x2b}} return a, nil } @@ -195,7 +195,7 @@ func _1586358095_add_replaceUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1586358095_add_replace.up.sql", size: 224, mode: os.FileMode(0644), modTime: time.Unix(1611588719, 0)} + info := bindataFileInfo{name: "1586358095_add_replace.up.sql", size: 224, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd2, 0xb3, 0xa9, 0xc7, 0x7f, 0x9d, 0x8f, 0x43, 0x8c, 0x9e, 0x58, 0x8d, 0x44, 0xbc, 0xfa, 0x6b, 0x5f, 0x3f, 0x5a, 0xbe, 0xe8, 0xb1, 0x16, 0xf, 0x91, 0x2a, 0xa0, 0x71, 0xbb, 0x8d, 0x6b, 0xcb}} return a, nil } @@ -215,7 +215,7 @@ func _1588665364_add_image_dataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1588665364_add_image_data.up.sql", size: 186, mode: os.FileMode(0644), modTime: time.Unix(1611588719, 0)} + info := bindataFileInfo{name: "1588665364_add_image_data.up.sql", size: 186, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd6, 0xc6, 0x35, 0xb4, 0x4c, 0x39, 0x96, 0x29, 0x30, 0xda, 0xf4, 0x8f, 0xcb, 0xf1, 0x9f, 0x84, 0xdc, 0x88, 0xd4, 0xd5, 0xbc, 0xb6, 0x5b, 0x46, 0x78, 0x67, 0x76, 0x1a, 0x5, 0x36, 0xdc, 0xe5}} return a, nil } @@ -235,7 +235,7 @@ func _1589365189_add_pow_targetUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1589365189_add_pow_target.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1611588719, 0)} + info := bindataFileInfo{name: "1589365189_add_pow_target.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4e, 0x3a, 0xe2, 0x2e, 0x7d, 0xaf, 0xbb, 0xcc, 0x21, 0xa1, 0x7a, 0x41, 0x9a, 0xd0, 0xbb, 0xa9, 0xc8, 0x35, 0xf9, 0x32, 0x34, 0x46, 0x44, 0x9a, 0x86, 0x40, 0x7c, 0xb9, 0x23, 0xc7, 0x3, 0x3f}} return a, nil } @@ -255,7 +255,7 @@ func _1591277220_add_index_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1591277220_add_index_messages.up.sql", size: 240, mode: os.FileMode(0644), modTime: time.Unix(1614609069, 0)} + info := bindataFileInfo{name: "1591277220_add_index_messages.up.sql", size: 240, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9c, 0xfe, 0xbe, 0xd5, 0xb8, 0x8f, 0xdd, 0xef, 0xbb, 0xa8, 0xad, 0x7f, 0xed, 0x5b, 0x5b, 0x2f, 0xe6, 0x82, 0x27, 0x78, 0x1f, 0xb9, 0x57, 0xdc, 0x8, 0xc2, 0xb2, 0xa9, 0x9a, 0x4, 0xe1, 0x7a}} return a, nil } @@ -275,7 +275,7 @@ func _1593087212_add_mute_chat_and_raw_message_fieldsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1593087212_add_mute_chat_and_raw_message_fields.up.sql", size: 215, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1593087212_add_mute_chat_and_raw_message_fields.up.sql", size: 215, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x73, 0x99, 0x61, 0xd1, 0xaa, 0xb4, 0xbf, 0xaf, 0xd7, 0x20, 0x17, 0x40, 0xf9, 0x2, 0xfb, 0xcc, 0x40, 0x2a, 0xd, 0x86, 0x36, 0x30, 0x88, 0x89, 0x25, 0x80, 0x42, 0xb0, 0x5b, 0xe9, 0x73, 0x78}} return a, nil } @@ -295,7 +295,7 @@ func _1595862781_add_audio_dataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1595862781_add_audio_data.up.sql", size: 246, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1595862781_add_audio_data.up.sql", size: 246, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xae, 0xd2, 0xee, 0x55, 0xfb, 0x36, 0xa4, 0x92, 0x66, 0xe, 0x81, 0x62, 0x1e, 0x7a, 0x69, 0xa, 0xd5, 0x4b, 0xa5, 0x6a, 0x8d, 0x1d, 0xce, 0xf3, 0x3e, 0xc0, 0x5f, 0x9c, 0x66, 0x1b, 0xb4, 0xed}} return a, nil } @@ -315,7 +315,7 @@ func _1595865249_create_emoji_reactions_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1595865249_create_emoji_reactions_table.up.sql", size: 300, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1595865249_create_emoji_reactions_table.up.sql", size: 300, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x3e, 0xc5, 0x43, 0x5c, 0x3d, 0x53, 0x43, 0x2c, 0x1a, 0xa5, 0xb6, 0xbf, 0x7, 0x4, 0x5a, 0x3e, 0x40, 0x8b, 0xa4, 0x57, 0x12, 0x58, 0xbc, 0x42, 0xe2, 0xc3, 0xde, 0x76, 0x98, 0x80, 0xe2, 0xbe}} return a, nil } @@ -335,7 +335,7 @@ func _1596805115_create_group_chat_invitations_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1596805115_create_group_chat_invitations_table.up.sql", size: 231, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1596805115_create_group_chat_invitations_table.up.sql", size: 231, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6d, 0xb1, 0x14, 0x6d, 0x54, 0x28, 0x67, 0xc3, 0x23, 0x6a, 0xfc, 0x80, 0xdf, 0x9e, 0x4c, 0x35, 0x36, 0xf, 0xf8, 0xf3, 0x5f, 0xae, 0xad, 0xb, 0xc1, 0x51, 0x8e, 0x17, 0x7, 0xe5, 0x7f, 0x91}} return a, nil } @@ -355,7 +355,7 @@ func _1597322655_add_invitation_admin_chat_fieldUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1597322655_add_invitation_admin_chat_field.up.sql", size: 54, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1597322655_add_invitation_admin_chat_field.up.sql", size: 54, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x7a, 0xa0, 0xf2, 0xdb, 0x13, 0x91, 0x91, 0xa8, 0x34, 0x1a, 0xa1, 0x49, 0x68, 0xd5, 0xae, 0x2c, 0xd8, 0xd5, 0xea, 0x8f, 0x8c, 0xc7, 0x2, 0x4e, 0x58, 0x2c, 0x3a, 0x14, 0xd4, 0x4f, 0x2c}} return a, nil } @@ -375,7 +375,7 @@ func _1597757544_add_nicknameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1597757544_add_nickname.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1597757544_add_nickname.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf4, 0xa2, 0x64, 0x50, 0xc5, 0x4, 0xb9, 0x8b, 0xd1, 0x18, 0x9b, 0xc3, 0x91, 0x36, 0x2a, 0x1f, 0xc3, 0x6c, 0x2d, 0x92, 0xf8, 0x5e, 0xff, 0xb1, 0x59, 0x61, 0x2, 0x1c, 0xe1, 0x85, 0x90, 0xa4}} return a, nil } @@ -395,7 +395,7 @@ func _1598955122_add_mentionsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1598955122_add_mentions.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1598955122_add_mentions.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8d, 0x22, 0x17, 0x92, 0xd2, 0x11, 0x4e, 0x7, 0x93, 0x9a, 0x55, 0xfd, 0xb, 0x97, 0xc4, 0x63, 0x6a, 0x81, 0x97, 0xcd, 0xb2, 0xf8, 0x4b, 0x5f, 0x3c, 0xfa, 0x3a, 0x38, 0x53, 0x10, 0xed, 0x9d}} return a, nil } @@ -415,7 +415,7 @@ func _1599641390_add_emoji_reactions_indexUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1599641390_add_emoji_reactions_index.up.sql", size: 126, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1599641390_add_emoji_reactions_index.up.sql", size: 126, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf9, 0xd8, 0xdc, 0xa7, 0xb, 0x92, 0x7a, 0x61, 0x37, 0x24, 0x1c, 0x77, 0x5e, 0xe, 0x7e, 0xfc, 0x9f, 0x98, 0x7b, 0x65, 0xe7, 0xf9, 0x71, 0x57, 0x89, 0x2d, 0x90, 0x1b, 0xf6, 0x5e, 0x37, 0xe8}} return a, nil } @@ -435,7 +435,7 @@ func _1599720851_add_seen_index_remove_long_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1599720851_add_seen_index_remove_long_messages.up.sql", size: 150, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1599720851_add_seen_index_remove_long_messages.up.sql", size: 150, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x24, 0x1c, 0xc4, 0x78, 0x91, 0xc7, 0xeb, 0xfe, 0xc8, 0xa0, 0xd8, 0x13, 0x27, 0x97, 0xc8, 0x96, 0x56, 0x97, 0x33, 0x2c, 0x1e, 0x16, 0x8a, 0xd3, 0x49, 0x99, 0x3, 0xe9, 0xbb, 0xc4, 0x5, 0x3c}} return a, nil } @@ -455,7 +455,7 @@ func _1603198582_add_profile_chat_fieldUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1603198582_add_profile_chat_field.up.sql", size: 45, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1603198582_add_profile_chat_field.up.sql", size: 45, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xaa, 0xca, 0xe, 0x46, 0xa0, 0x9, 0x9d, 0x47, 0x57, 0xe9, 0xfb, 0x17, 0xeb, 0x9c, 0xf6, 0xb8, 0x1d, 0xe9, 0xd, 0x0, 0xd5, 0xe5, 0xd8, 0x9e, 0x60, 0xa, 0xbf, 0x32, 0x2c, 0x52, 0x7f, 0x6a}} return a, nil } @@ -475,7 +475,7 @@ func _1603816533_add_linksUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1603816533_add_links.up.sql", size: 48, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1603816533_add_links.up.sql", size: 48, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc9, 0x24, 0xd6, 0x1d, 0xa, 0x83, 0x1e, 0x4d, 0xf, 0xae, 0x4d, 0x8c, 0x51, 0x32, 0xa8, 0x37, 0xb0, 0x14, 0xfb, 0x32, 0x34, 0xc8, 0xc, 0x4e, 0x5b, 0xc5, 0x15, 0x65, 0x73, 0x0, 0x0, 0x1d}} return a, nil } @@ -495,7 +495,7 @@ func _1603888149_create_chat_identity_last_published_tableUpSql() (*asset, error return nil, err } - info := bindataFileInfo{name: "1603888149_create_chat_identity_last_published_table.up.sql", size: 407, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1603888149_create_chat_identity_last_published_table.up.sql", size: 407, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7f, 0x9, 0xf, 0xfb, 0xdb, 0x3c, 0x86, 0x70, 0x82, 0xda, 0x10, 0x25, 0xe2, 0x4e, 0x40, 0x45, 0xab, 0x8b, 0x1c, 0x91, 0x7c, 0xf1, 0x70, 0x2e, 0x81, 0xf3, 0x71, 0x45, 0xda, 0xe2, 0xa4, 0x57}} return a, nil } @@ -515,7 +515,7 @@ func _1605075346_add_communitiesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1605075346_add_communities.up.sql", size: 6971, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1605075346_add_communities.up.sql", size: 6971, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1f, 0x64, 0xea, 0xb4, 0xae, 0x9e, 0xdb, 0x9, 0x58, 0xb6, 0x5c, 0x7a, 0x50, 0xc5, 0xfe, 0x93, 0x5d, 0x36, 0x85, 0x5d, 0x6a, 0xba, 0xc9, 0x7e, 0x84, 0xd7, 0xbf, 0x2a, 0x53, 0xf3, 0x97, 0xf1}} return a, nil } @@ -535,7 +535,7 @@ func _1610117927_add_message_cacheUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1610117927_add_message_cache.up.sql", size: 142, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "1610117927_add_message_cache.up.sql", size: 142, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x34, 0xf1, 0xf0, 0x82, 0x79, 0x28, 0x19, 0xc2, 0x39, 0x6a, 0xa5, 0x96, 0x59, 0x23, 0xa0, 0xed, 0x60, 0x58, 0x86, 0x9, 0xb9, 0xad, 0xfb, 0xa, 0xe3, 0x47, 0x6e, 0xa1, 0x18, 0xe8, 0x39, 0x2c}} return a, nil } @@ -555,7 +555,7 @@ func _1610959908_add_dont_wrap_to_raw_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1610959908_add_dont_wrap_to_raw_messages.up.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1636975146, 0)} + info := bindataFileInfo{name: "1610959908_add_dont_wrap_to_raw_messages.up.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x71, 0x2, 0x9a, 0xca, 0xd4, 0x38, 0x44, 0x30, 0x2b, 0xa8, 0x27, 0x32, 0x63, 0x53, 0x22, 0x60, 0x59, 0x84, 0x23, 0x96, 0x77, 0xf0, 0x56, 0xd7, 0x94, 0xe0, 0x95, 0x28, 0x6, 0x1d, 0x4e, 0xb1}} return a, nil } @@ -575,7 +575,7 @@ func _1610960912_add_send_on_personal_topicUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1610960912_add_send_on_personal_topic.up.sql", size: 82, mode: os.FileMode(0644), modTime: time.Unix(1636975146, 0)} + info := bindataFileInfo{name: "1610960912_add_send_on_personal_topic.up.sql", size: 82, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x77, 0xac, 0x2f, 0xc4, 0xd, 0xa7, 0x1b, 0x37, 0x30, 0xc2, 0x68, 0xee, 0xde, 0x54, 0x5e, 0xbf, 0x3f, 0xa0, 0xd6, 0xc6, 0x9f, 0xd4, 0x34, 0x12, 0x76, 0x1e, 0x66, 0x4a, 0xfc, 0xf, 0xee, 0xc9}} return a, nil } @@ -595,7 +595,7 @@ func _1612870480_add_datasync_idUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1612870480_add_datasync_id.up.sql", size: 111, mode: os.FileMode(0644), modTime: time.Unix(1636975146, 0)} + info := bindataFileInfo{name: "1612870480_add_datasync_id.up.sql", size: 111, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x34, 0x9a, 0xbc, 0xfa, 0xaa, 0x8c, 0x9c, 0x37, 0x67, 0x15, 0x9c, 0x7e, 0x78, 0x75, 0x66, 0x82, 0x18, 0x72, 0x10, 0xbc, 0xd4, 0xab, 0x44, 0xfe, 0x57, 0x85, 0x6d, 0x19, 0xf5, 0x96, 0x8a, 0xbe}} return a, nil } @@ -615,7 +615,7 @@ func _1614152139_add_communities_request_to_joinUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1614152139_add_communities_request_to_join.up.sql", size: 831, mode: os.FileMode(0644), modTime: time.Unix(1636975146, 0)} + info := bindataFileInfo{name: "1614152139_add_communities_request_to_join.up.sql", size: 831, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x11, 0x3, 0x26, 0xf9, 0x29, 0x50, 0x4f, 0xcd, 0x46, 0xe5, 0xb1, 0x6b, 0xb9, 0x2, 0x40, 0xb1, 0xdf, 0x4a, 0x4c, 0x7a, 0xda, 0x3, 0x35, 0xcd, 0x2d, 0xcc, 0x80, 0x7d, 0x57, 0x5f, 0x3, 0x5c}} return a, nil } @@ -635,7 +635,7 @@ func _1615374373_add_confirmationsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1615374373_add_confirmations.up.sql", size: 227, mode: os.FileMode(0644), modTime: time.Unix(1637083886, 0)} + info := bindataFileInfo{name: "1615374373_add_confirmations.up.sql", size: 227, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xdd, 0xa6, 0x65, 0xc5, 0x1d, 0xb2, 0x77, 0x36, 0xe3, 0x79, 0xda, 0xe8, 0x7a, 0xa4, 0xdf, 0x45, 0xae, 0xd8, 0xb4, 0xba, 0x90, 0xfd, 0x74, 0x71, 0x14, 0x75, 0x73, 0x72, 0xb9, 0x9e, 0x1, 0x81}} return a, nil } @@ -655,7 +655,7 @@ func _1617694931_add_notification_centerUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1617694931_add_notification_center.up.sql", size: 572, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1617694931_add_notification_center.up.sql", size: 572, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x10, 0x45, 0xc6, 0xc9, 0x73, 0xbb, 0x1f, 0xda, 0xa3, 0x4d, 0x19, 0x98, 0x85, 0x2d, 0xca, 0xda, 0xcc, 0x3b, 0x32, 0xff, 0xc7, 0x7b, 0xe3, 0x9f, 0x9b, 0x2a, 0x93, 0xf5, 0xdf, 0x65, 0x38, 0x91}} return a, nil } @@ -675,7 +675,7 @@ func _1618923660_create_pin_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1618923660_create_pin_messages.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1618923660_create_pin_messages.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1623074824, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x61, 0x44, 0x3a, 0xbe, 0x30, 0xd2, 0x7e, 0xc0, 0xe2, 0x8e, 0x65, 0x53, 0x54, 0xbb, 0x7a, 0x1c, 0xb3, 0x5d, 0xd2, 0xa6, 0xa9, 0x28, 0xb7, 0xa4, 0x5f, 0x8b, 0x9, 0x5f, 0x17, 0xc1, 0x85, 0x21}} return a, nil } @@ -695,7 +695,7 @@ func _1619094007_add_joined_chat_fieldUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1619094007_add_joined_chat_field.up.sql", size: 101, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1619094007_add_joined_chat_field.up.sql", size: 101, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfa, 0x30, 0x81, 0x3a, 0x2f, 0x9f, 0xb3, 0x0, 0x55, 0x8e, 0x1d, 0xa8, 0xb0, 0x68, 0xf0, 0x40, 0x1a, 0x6c, 0xaa, 0xfc, 0x33, 0xd1, 0xd1, 0x55, 0x3f, 0xf2, 0xbd, 0x54, 0xa1, 0x2b, 0x40, 0x95}} return a, nil } @@ -715,7 +715,7 @@ func _1619099821_add_last_synced_fieldUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1619099821_add_last_synced_field.up.sql", size: 226, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1619099821_add_last_synced_field.up.sql", size: 226, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf, 0x52, 0x22, 0xe, 0x2f, 0xd7, 0x93, 0x5f, 0x42, 0xc2, 0x93, 0x4, 0x35, 0x6f, 0xc9, 0x19, 0xed, 0x6b, 0x52, 0x6f, 0xae, 0x99, 0xe2, 0x68, 0x3d, 0x4f, 0x40, 0xe, 0xe1, 0xa, 0x47, 0x21}} return a, nil } @@ -735,7 +735,7 @@ func _1621933219_add_mentionedUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1621933219_add_mentioned.up.sql", size: 70, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1621933219_add_mentioned.up.sql", size: 70, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x36, 0x76, 0x8a, 0xc9, 0x7, 0x8f, 0xa5, 0xcb, 0x12, 0x21, 0x4e, 0xfe, 0x96, 0x77, 0xcf, 0x7f, 0x76, 0x75, 0x36, 0x2c, 0xf8, 0x1d, 0x13, 0xcb, 0xcd, 0x6e, 0x70, 0xbf, 0xf5, 0x93, 0x67, 0xd1}} return a, nil } @@ -755,7 +755,7 @@ func _1622010048_add_unviewed_mentions_countUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1622010048_add_unviewed_mentions_count.up.sql", size: 114, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1622010048_add_unviewed_mentions_count.up.sql", size: 114, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7c, 0x16, 0x85, 0xa6, 0x5b, 0xe1, 0x66, 0xb9, 0x84, 0xbe, 0x7f, 0xa, 0x77, 0x23, 0xb9, 0xef, 0x8e, 0x2, 0x8, 0xfc, 0x61, 0xb2, 0x43, 0xa9, 0x63, 0xae, 0xb4, 0xdf, 0x30, 0xb1, 0x61, 0x4b}} return a, nil } @@ -775,7 +775,7 @@ func _1622061278_add_message_activity_center_notification_fieldUpSql() (*asset, return nil, err } - info := bindataFileInfo{name: "1622061278_add_message_activity_center_notification_field.up.sql", size: 80, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1622061278_add_message_activity_center_notification_field.up.sql", size: 80, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8, 0xc, 0xa6, 0x1f, 0xa5, 0xc6, 0x7c, 0x6f, 0xab, 0x2c, 0x2d, 0xb5, 0xa4, 0xdd, 0xc1, 0xd6, 0x44, 0x83, 0xf9, 0xb1, 0xa5, 0xce, 0x34, 0x3d, 0x2, 0xa9, 0x35, 0xcf, 0xc6, 0xb2, 0x43, 0x37}} return a, nil } @@ -795,7 +795,7 @@ func _1622464518_set_synced_to_fromUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1622464518_set_synced_to_from.up.sql", size: 105, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1622464518_set_synced_to_from.up.sql", size: 105, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x33, 0x3e, 0x2b, 0xa, 0x1e, 0xc7, 0x6d, 0x6f, 0xd1, 0x1d, 0xe8, 0x4b, 0xdd, 0x92, 0x76, 0xea, 0xf2, 0x3e, 0x15, 0x85, 0xc4, 0xc3, 0x31, 0xf1, 0xc0, 0xa2, 0xd7, 0x47, 0xde, 0x4e, 0xfd, 0xc6}} return a, nil } @@ -815,7 +815,7 @@ func _1622464519_add_chat_descriptionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1622464519_add_chat_description.up.sql", size: 93, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1622464519_add_chat_description.up.sql", size: 93, mode: os.FileMode(0644), modTime: time.Unix(1623331301, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x36, 0x2e, 0x89, 0x31, 0xec, 0xef, 0xeb, 0x43, 0xf5, 0x96, 0x6d, 0xce, 0x91, 0x8a, 0x37, 0x2a, 0x11, 0x7a, 0x3f, 0xd9, 0x10, 0xbb, 0xa1, 0xbc, 0x7, 0xe0, 0x3b, 0xa5, 0xf4, 0xa6, 0xf4, 0xa1}} return a, nil } @@ -835,7 +835,7 @@ func _1622622253_add_pinned_by_to_pin_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1622622253_add_pinned_by_to_pin_messages.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1622622253_add_pinned_by_to_pin_messages.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1628512368, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9b, 0x94, 0xa3, 0x45, 0x91, 0x1e, 0x66, 0xd1, 0x96, 0x5a, 0xaf, 0xfa, 0x29, 0x39, 0xa8, 0x3a, 0x97, 0x4c, 0x65, 0x6, 0x96, 0x90, 0x4c, 0xfe, 0xce, 0x7d, 0x5d, 0xd4, 0xb3, 0x8, 0x6d, 0x5f}} return a, nil } @@ -855,7 +855,7 @@ func _1623938329_add_author_activity_center_notification_fieldUpSql() (*asset, e return nil, err } - info := bindataFileInfo{name: "1623938329_add_author_activity_center_notification_field.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1623938329_add_author_activity_center_notification_field.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x36, 0xe6, 0xa7, 0xd5, 0x26, 0xff, 0xab, 0x92, 0x88, 0xf0, 0xd3, 0x34, 0xd9, 0x2f, 0xe7, 0x18, 0x1a, 0x40, 0xf9, 0xbe, 0x8e, 0xfc, 0xd0, 0x4f, 0x1f, 0x4a, 0xb9, 0x83, 0x3f, 0xa9, 0xde, 0xb}} return a, nil } @@ -875,7 +875,7 @@ func _1623938330_add_edit_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1623938330_add_edit_messages.up.sql", size: 369, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1623938330_add_edit_messages.up.sql", size: 369, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7e, 0xd2, 0xce, 0xe, 0x5c, 0x19, 0xbe, 0x5e, 0x29, 0xbe, 0x9b, 0x31, 0x53, 0x76, 0xb2, 0xc8, 0x56, 0xf0, 0x82, 0xfe, 0x7d, 0x6c, 0xe8, 0x5c, 0xe9, 0x7a, 0x5d, 0x5, 0xc4, 0x92, 0x38, 0xe3}} return a, nil } @@ -895,7 +895,7 @@ func _1624978434_add_muted_communityUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1624978434_add_muted_community.up.sql", size: 82, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1624978434_add_muted_community.up.sql", size: 82, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6, 0xdc, 0x6e, 0x6f, 0x97, 0xc7, 0x3d, 0x50, 0xab, 0x80, 0x87, 0x44, 0x43, 0x38, 0xe6, 0xc5, 0xc1, 0x91, 0x26, 0xf, 0x16, 0xe, 0xd9, 0x32, 0x37, 0x25, 0x96, 0x25, 0x6, 0xc8, 0xb5, 0x4a}} return a, nil } @@ -915,7 +915,7 @@ func _1625018910_add_repply_message_activity_center_notification_fieldUpSql() (* return nil, err } - info := bindataFileInfo{name: "1625018910_add_repply_message_activity_center_notification_field.up.sql", size: 86, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1625018910_add_repply_message_activity_center_notification_field.up.sql", size: 86, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf2, 0x52, 0x12, 0x40, 0xd8, 0x6f, 0x71, 0x97, 0x46, 0x39, 0xaa, 0x74, 0x41, 0xcd, 0x45, 0x4c, 0xe8, 0xd9, 0xe2, 0x56, 0x8e, 0x78, 0x18, 0x62, 0xf6, 0xa8, 0x36, 0xe9, 0x9a, 0x1f, 0xc, 0xb1}} return a, nil } @@ -935,7 +935,7 @@ func _1625762506_add_deleted_messagesUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1625762506_add_deleted_messages.up.sql", size: 357, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1625762506_add_deleted_messages.up.sql", size: 357, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd5, 0x61, 0x42, 0xb6, 0x8c, 0x7f, 0x2d, 0xec, 0xa9, 0x6d, 0x3d, 0x0, 0xa3, 0x32, 0xd8, 0x4a, 0x38, 0x5c, 0x97, 0xfc, 0x68, 0xde, 0xa9, 0xb7, 0xd8, 0xde, 0xb, 0x29, 0x93, 0xdc, 0x81, 0xf8}} return a, nil } @@ -955,7 +955,7 @@ func _1627388946_add_communities_synced_atUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1627388946_add_communities_synced_at.up.sql", size: 87, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1627388946_add_communities_synced_at.up.sql", size: 87, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc1, 0xbd, 0x9b, 0x6a, 0xc9, 0x1a, 0x7a, 0x34, 0xcf, 0x5f, 0x80, 0x9e, 0x8c, 0x1c, 0xc0, 0xec, 0x4e, 0x78, 0xb0, 0x2d, 0x15, 0x77, 0x38, 0x4a, 0x6a, 0x5, 0x84, 0xf5, 0x8d, 0x8b, 0xbe, 0x9}} return a, nil } @@ -975,7 +975,7 @@ func _1628280060_createUsermessagesIndexSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1628280060_create-usermessages-index.sql", size: 80, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1628280060_create-usermessages-index.sql", size: 80, mode: os.FileMode(0644), modTime: time.Unix(1633078507, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x10, 0x6f, 0x70, 0x47, 0x40, 0xab, 0xa8, 0x60, 0xe0, 0xf9, 0x8, 0x7e, 0x19, 0x9d, 0xba, 0x33, 0x16, 0xfc, 0x3c, 0xdc, 0xa8, 0xa6, 0x53, 0x61, 0x39, 0x82, 0x91, 0xcf, 0x69, 0xd8, 0xf2, 0xcf}} return a, nil } @@ -995,7 +995,7 @@ func _1632303896_modify_contacts_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1632303896_modify_contacts_table.up.sql", size: 1574, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1632303896_modify_contacts_table.up.sql", size: 1574, mode: os.FileMode(0644), modTime: time.Unix(1635152717, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x81, 0x1e, 0x6c, 0x3c, 0xd, 0xd7, 0x7d, 0xbb, 0x19, 0xbc, 0xe4, 0x7, 0xfd, 0xf8, 0x66, 0x6d, 0x78, 0xf6, 0x4, 0xe6, 0x51, 0xe4, 0xe6, 0xdc, 0xe, 0x5a, 0x2e, 0xac, 0xe6, 0xe7, 0x24, 0x69}} return a, nil } @@ -1015,7 +1015,7 @@ func _1633349838_add_emoji_column_in_chatsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1633349838_add_emoji_column_in_chats.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1633349838_add_emoji_column_in_chats.up.sql", size: 52, mode: os.FileMode(0644), modTime: time.Unix(1635152717, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xcb, 0x33, 0xcb, 0x3b, 0xa9, 0x99, 0x77, 0x6a, 0xea, 0xc4, 0x39, 0xd7, 0xa1, 0x49, 0xa7, 0xdf, 0xff, 0x72, 0xda, 0x34, 0x21, 0x67, 0x66, 0xca, 0x65, 0x46, 0x1, 0xa6, 0x4e, 0xf9, 0x38, 0x86}} return a, nil } @@ -1035,7 +1035,7 @@ func _1634831235_add_highlight_column_in_chatsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1634831235_add_highlight_column_in_chats.up.sql", size: 62, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1634831235_add_highlight_column_in_chats.up.sql", size: 62, mode: os.FileMode(0644), modTime: time.Unix(1635152717, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xaa, 0x63, 0x5c, 0x73, 0x19, 0x83, 0xbd, 0x35, 0x80, 0x9f, 0x66, 0xec, 0x4c, 0xbc, 0x9d, 0x2d, 0x52, 0x91, 0x6d, 0xb3, 0x2b, 0x87, 0xde, 0x24, 0x46, 0x5c, 0xd, 0xfd, 0x78, 0xf5, 0xe3, 0xe9}} return a, nil } @@ -1055,7 +1055,7 @@ func _1634896007_add_last_updated_locally_and_removedUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1634896007_add_last_updated_locally_and_removed.up.sql", size: 131, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1634896007_add_last_updated_locally_and_removed.up.sql", size: 131, mode: os.FileMode(0644), modTime: time.Unix(1637232499, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2e, 0xa8, 0x34, 0xe2, 0xc0, 0x62, 0xc8, 0xd6, 0x5a, 0x87, 0xe3, 0x70, 0xe1, 0xc4, 0x16, 0x9c, 0x60, 0x2e, 0x98, 0xf0, 0x91, 0x84, 0xbe, 0xe0, 0xdf, 0x3e, 0x4d, 0x24, 0xc4, 0x6c, 0x40, 0x17}} return a, nil } @@ -1075,7 +1075,7 @@ func _1635840039_add_clock_read_at_column_in_chatsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1635840039_add_clock_read_at_column_in_chats.up.sql", size: 245, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1635840039_add_clock_read_at_column_in_chats.up.sql", size: 245, mode: os.FileMode(0644), modTime: time.Unix(1635982167, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6c, 0xba, 0x3f, 0xba, 0x1a, 0x71, 0xa8, 0x9, 0x19, 0xbe, 0x1e, 0x38, 0x50, 0x30, 0x3a, 0x52, 0x15, 0x29, 0xee, 0x49, 0x19, 0x6f, 0x53, 0xc2, 0xc6, 0x6c, 0xd9, 0x80, 0x7e, 0xb9, 0x58, 0x7a}} return a, nil } @@ -1095,7 +1095,7 @@ func _1637852321_add_received_invitation_admin_column_in_chatsUpSql() (*asset, e return nil, err } - info := bindataFileInfo{name: "1637852321_add_received_invitation_admin_column_in_chats.up.sql", size: 72, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1637852321_add_received_invitation_admin_column_in_chats.up.sql", size: 72, mode: os.FileMode(0644), modTime: time.Unix(1642505279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x70, 0x8b, 0x92, 0x56, 0x83, 0x70, 0x7f, 0x6, 0xb2, 0xd, 0x1c, 0x2f, 0xcc, 0x93, 0xc3, 0x85, 0x8c, 0xc2, 0x38, 0x94, 0x7e, 0x88, 0x3f, 0x39, 0x34, 0xf8, 0x90, 0xcf, 0x83, 0x68, 0x3d, 0xe5}} return a, nil } @@ -1115,7 +1115,7 @@ func _1645034601_display_nameUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1645034601_display_name.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "1645034601_display_name.up.sql", size: 110, mode: os.FileMode(0644), modTime: time.Unix(1647948124, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x15, 0xfc, 0xda, 0x70, 0x53, 0x19, 0x90, 0x20, 0x4, 0x1c, 0x99, 0x42, 0x53, 0x1a, 0xd6, 0xb8, 0xbb, 0x8a, 0xe8, 0xbe, 0xcc, 0xb7, 0xc, 0x7f, 0x73, 0x50, 0x18, 0xf1, 0x8b, 0x18, 0x54, 0x64}} return a, nil } @@ -1135,7 +1135,7 @@ func readmeMd() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "README.md", size: 554, mode: os.FileMode(0644), modTime: time.Unix(1617280156, 0)} + info := bindataFileInfo{name: "README.md", size: 554, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1c, 0x6e, 0xfb, 0xcc, 0x81, 0x94, 0x4d, 0x8c, 0xa0, 0x3b, 0x5, 0xb0, 0x18, 0xd6, 0xbb, 0xb3, 0x79, 0xc8, 0x8f, 0xff, 0xc1, 0x10, 0xf9, 0xf, 0x20, 0x1b, 0x4a, 0x74, 0x96, 0x42, 0xd7, 0xa8}} return a, nil } @@ -1155,7 +1155,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 850, mode: os.FileMode(0644), modTime: time.Unix(1611588719, 0)} + info := bindataFileInfo{name: "doc.go", size: 850, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa0, 0xcc, 0x41, 0xe1, 0x61, 0x12, 0x97, 0xe, 0x36, 0x8c, 0xa7, 0x9e, 0xe0, 0x6e, 0x59, 0x9e, 0xee, 0xd5, 0x4a, 0xcf, 0x1e, 0x60, 0xd6, 0xc3, 0x3a, 0xc9, 0x6c, 0xf2, 0x86, 0x5a, 0xb4, 0x1e}} return a, nil } diff --git a/protocol/protobuf/application_metadata_message.pb.go b/protocol/protobuf/application_metadata_message.pb.go index 727da32bc..ea6e71878 100644 --- a/protocol/protobuf/application_metadata_message.pb.go +++ b/protocol/protobuf/application_metadata_message.pb.go @@ -65,6 +65,7 @@ const ( ApplicationMetadataMessage_SYNC_ACTIVITY_CENTER_DISMISSED ApplicationMetadataMessage_Type = 39 ApplicationMetadataMessage_SYNC_BOOKMARK ApplicationMetadataMessage_Type = 40 ApplicationMetadataMessage_SYNC_CLEAR_HISTORY ApplicationMetadataMessage_Type = 41 + ApplicationMetadataMessage_SYNC_SETTING ApplicationMetadataMessage_Type = 42 ) var ApplicationMetadataMessage_Type_name = map[int32]string{ @@ -110,6 +111,7 @@ var ApplicationMetadataMessage_Type_name = map[int32]string{ 39: "SYNC_ACTIVITY_CENTER_DISMISSED", 40: "SYNC_BOOKMARK", 41: "SYNC_CLEAR_HISTORY", + 42: "SYNC_SETTING", } var ApplicationMetadataMessage_Type_value = map[string]int32{ @@ -155,6 +157,7 @@ var ApplicationMetadataMessage_Type_value = map[string]int32{ "SYNC_ACTIVITY_CENTER_DISMISSED": 39, "SYNC_BOOKMARK": 40, "SYNC_CLEAR_HISTORY": 41, + "SYNC_SETTING": 42, } func (x ApplicationMetadataMessage_Type) String() string { @@ -233,49 +236,50 @@ func init() { } var fileDescriptor_ad09a6406fcf24c7 = []byte{ - // 704 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xdb, 0x52, 0x23, 0x37, - 0x10, 0x8d, 0x77, 0x09, 0x2c, 0x6d, 0x60, 0x85, 0x96, 0x8b, 0x31, 0x0b, 0x78, 0xbd, 0x1b, 0x2e, - 0x49, 0x95, 0x53, 0x95, 0x3c, 0xa6, 0xf2, 0x20, 0x4b, 0x0d, 0x16, 0xf6, 0x48, 0x83, 0xa4, 0x71, - 0xca, 0x79, 0x51, 0x0d, 0xc1, 0xa1, 0xa8, 0x02, 0xec, 0x02, 0xf3, 0xc0, 0x8f, 0xe4, 0x2b, 0xf2, - 0x91, 0x29, 0xcd, 0xf8, 0x06, 0x98, 0xf0, 0x64, 0xab, 0xcf, 0x51, 0xb7, 0xfa, 0xf4, 0xe9, 0x81, - 0x6a, 0xda, 0xef, 0x5f, 0x5f, 0xfd, 0x95, 0x0e, 0xae, 0x7a, 0xb7, 0xfe, 0xa6, 0x3b, 0x48, 0x2f, - 0xd2, 0x41, 0xea, 0x6f, 0xba, 0xf7, 0xf7, 0xe9, 0x65, 0xb7, 0xd6, 0xbf, 0xeb, 0x0d, 0x7a, 0xf4, - 0x43, 0xf6, 0x73, 0xfe, 0xf0, 0x77, 0xf5, 0x5f, 0x80, 0x32, 0x9b, 0x5c, 0x88, 0x86, 0xfc, 0x28, - 0xa7, 0xd3, 0xcf, 0xb0, 0x78, 0x7f, 0x75, 0x79, 0x9b, 0x0e, 0x1e, 0xee, 0xba, 0xa5, 0x42, 0xa5, - 0x70, 0xb8, 0x64, 0x26, 0x01, 0x5a, 0x82, 0x85, 0x7e, 0xfa, 0x78, 0xdd, 0x4b, 0x2f, 0x4a, 0xef, - 0x32, 0x6c, 0x74, 0xa4, 0xbf, 0xc3, 0xdc, 0xe0, 0xb1, 0xdf, 0x2d, 0xbd, 0xaf, 0x14, 0x0e, 0x57, - 0x7e, 0x39, 0xaa, 0x8d, 0xea, 0xd5, 0x5e, 0xaf, 0x55, 0x73, 0x8f, 0xfd, 0xae, 0xc9, 0xae, 0x55, - 0xff, 0x59, 0x84, 0xb9, 0x70, 0xa4, 0x45, 0x58, 0x48, 0x54, 0x53, 0xe9, 0x3f, 0x14, 0xf9, 0x8e, - 0x12, 0x58, 0xe2, 0x0d, 0xe6, 0x7c, 0x84, 0xd6, 0xb2, 0x13, 0x24, 0x05, 0x4a, 0x61, 0x85, 0x6b, - 0xe5, 0x18, 0x77, 0x3e, 0x89, 0x05, 0x73, 0x48, 0xde, 0xd1, 0x1d, 0xd8, 0x8a, 0x30, 0xaa, 0xa3, - 0xb1, 0x0d, 0x19, 0x0f, 0xc3, 0xe3, 0x2b, 0xef, 0xe9, 0x3a, 0xac, 0xc6, 0x4c, 0x1a, 0x2f, 0x95, - 0x75, 0xac, 0xd5, 0x62, 0x4e, 0x6a, 0x45, 0xe6, 0x42, 0xd8, 0x76, 0x14, 0x7f, 0x1a, 0xfe, 0x9e, - 0x7e, 0x85, 0x3d, 0x83, 0x67, 0x09, 0x5a, 0xe7, 0x99, 0x10, 0x06, 0xad, 0xf5, 0xc7, 0xda, 0x78, - 0x67, 0x98, 0xb2, 0x8c, 0x67, 0xa4, 0x79, 0xfa, 0x23, 0xec, 0x33, 0xce, 0x31, 0x76, 0xfe, 0x2d, - 0xee, 0x02, 0xfd, 0x09, 0x0e, 0x04, 0xf2, 0x96, 0x54, 0xf8, 0x26, 0xf9, 0x03, 0xdd, 0x84, 0x4f, - 0x23, 0xd2, 0x34, 0xb0, 0x48, 0xd7, 0x80, 0x58, 0x54, 0xe2, 0x49, 0x14, 0xe8, 0x1e, 0x6c, 0x3f, - 0xcf, 0x3d, 0x4d, 0x28, 0x06, 0x69, 0x5e, 0x34, 0xe9, 0x87, 0x02, 0x92, 0xa5, 0xd9, 0x30, 0xe3, - 0x5c, 0x27, 0xca, 0x91, 0x65, 0xfa, 0x05, 0x76, 0x5e, 0xc2, 0x71, 0x52, 0x6f, 0x49, 0xee, 0xc3, - 0x5c, 0xc8, 0x0a, 0xdd, 0x85, 0xf2, 0x68, 0x1e, 0x5c, 0x0b, 0xf4, 0x4c, 0xb4, 0xd1, 0x38, 0x69, - 0x31, 0x42, 0xe5, 0xc8, 0x47, 0x5a, 0x85, 0xdd, 0x38, 0xb1, 0x0d, 0xaf, 0xb4, 0x93, 0xc7, 0x92, - 0xe7, 0x29, 0x0c, 0x9e, 0x48, 0xeb, 0x4c, 0x2e, 0x39, 0x09, 0x0a, 0xfd, 0x3f, 0xc7, 0x1b, 0xb4, - 0xb1, 0x56, 0x16, 0xc9, 0x2a, 0xdd, 0x86, 0xcd, 0x97, 0xe4, 0xb3, 0x04, 0x4d, 0x87, 0x50, 0xfa, - 0x0d, 0x2a, 0xaf, 0x80, 0x93, 0x14, 0x9f, 0x42, 0xd7, 0xb3, 0xea, 0x65, 0xfa, 0x91, 0xb5, 0xd0, - 0xd2, 0x2c, 0x78, 0x78, 0x7d, 0x3d, 0x58, 0x10, 0x23, 0x7d, 0x2a, 0xbd, 0xc1, 0xa1, 0xce, 0x1b, - 0x74, 0x0b, 0xd6, 0x4f, 0x8c, 0x4e, 0xe2, 0x4c, 0x16, 0x2f, 0x55, 0x5b, 0xba, 0xbc, 0xbb, 0x4d, - 0xba, 0x0a, 0xcb, 0x79, 0x50, 0xa0, 0x72, 0xd2, 0x75, 0x48, 0x29, 0xb0, 0xb9, 0x8e, 0xa2, 0x44, - 0x49, 0xd7, 0xf1, 0x02, 0x2d, 0x37, 0x32, 0xce, 0xd8, 0x5b, 0xb4, 0x04, 0x6b, 0x13, 0x68, 0x2a, - 0x4f, 0x39, 0xbc, 0x7a, 0x82, 0x8c, 0xa7, 0xad, 0xfd, 0xa9, 0x96, 0x8a, 0x6c, 0xd3, 0x8f, 0x50, - 0x8c, 0xa5, 0x1a, 0xdb, 0xfe, 0x73, 0xd8, 0x1d, 0x14, 0x72, 0xb2, 0x3b, 0x3b, 0xe1, 0x25, 0xd6, - 0x31, 0x97, 0xd8, 0xd1, 0xea, 0xec, 0x86, 0x5e, 0x04, 0xb6, 0x70, 0x6a, 0x5f, 0xf6, 0x82, 0xa9, - 0x66, 0x79, 0x66, 0x58, 0x9a, 0x54, 0x68, 0x19, 0x36, 0x98, 0xd2, 0xaa, 0x13, 0xe9, 0xc4, 0xfa, - 0x08, 0x9d, 0x91, 0xdc, 0xd7, 0x99, 0xe3, 0x0d, 0xf2, 0x65, 0xbc, 0x55, 0x59, 0xcb, 0x06, 0x23, - 0xdd, 0x46, 0x41, 0xaa, 0x61, 0x6a, 0x93, 0xf0, 0xb0, 0x94, 0x0d, 0x02, 0x0a, 0xf2, 0x95, 0x02, - 0xcc, 0xd7, 0x19, 0x6f, 0x26, 0x31, 0xf9, 0x36, 0x76, 0x64, 0x50, 0xb6, 0x1d, 0x3a, 0xe5, 0xa8, - 0x1c, 0x9a, 0x9c, 0xfa, 0xc3, 0xd8, 0x91, 0xcf, 0xe1, 0x7c, 0x1b, 0x51, 0x90, 0xfd, 0xe0, 0xb8, - 0x99, 0x14, 0x21, 0x6d, 0x24, 0xad, 0x45, 0x41, 0x0e, 0x32, 0x25, 0x02, 0xa7, 0xae, 0x75, 0x33, - 0x62, 0xa6, 0x49, 0x0e, 0xe9, 0x06, 0xd0, 0xfc, 0x85, 0x2d, 0x64, 0xc6, 0x37, 0xa4, 0x75, 0xda, - 0x74, 0xc8, 0x51, 0x7d, 0xf9, 0xcf, 0x62, 0xed, 0xe7, 0xdf, 0x46, 0x5f, 0xb3, 0xf3, 0xf9, 0xec, - 0xdf, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x84, 0x31, 0xd9, 0x7d, 0x74, 0x05, 0x00, 0x00, + // 715 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x5d, 0x53, 0x5b, 0x37, + 0x10, 0xad, 0x13, 0x0a, 0x61, 0x0d, 0x44, 0x28, 0x7c, 0x18, 0x13, 0xc0, 0x71, 0xd2, 0x84, 0xa4, + 0x33, 0xee, 0x4c, 0xfb, 0xd8, 0xe9, 0x83, 0x2c, 0x2d, 0xb6, 0xb0, 0xaf, 0x74, 0x91, 0x74, 0xdd, + 0x71, 0x5f, 0x34, 0x97, 0xe2, 0x32, 0xcc, 0x00, 0xf6, 0x80, 0x79, 0xe0, 0x1f, 0xf5, 0x57, 0xf4, + 0xb7, 0x75, 0x74, 0xaf, 0xbf, 0x00, 0x13, 0x9e, 0x6c, 0x9d, 0x73, 0xb4, 0xab, 0x3d, 0xbb, 0x7b, + 0xa1, 0x9a, 0x0e, 0x06, 0x97, 0x17, 0x7f, 0xa7, 0xc3, 0x8b, 0xfe, 0xb5, 0xbf, 0xea, 0x0d, 0xd3, + 0xb3, 0x74, 0x98, 0xfa, 0xab, 0xde, 0xed, 0x6d, 0x7a, 0xde, 0xab, 0x0d, 0x6e, 0xfa, 0xc3, 0x3e, + 0x7d, 0x93, 0xfd, 0x9c, 0xde, 0xfd, 0x53, 0xfd, 0x0f, 0xa0, 0xcc, 0xa6, 0x17, 0xa2, 0x91, 0x3e, + 0xca, 0xe5, 0xf4, 0x3d, 0x2c, 0xdf, 0x5e, 0x9c, 0x5f, 0xa7, 0xc3, 0xbb, 0x9b, 0x5e, 0xa9, 0x50, + 0x29, 0x1c, 0xae, 0x98, 0x29, 0x40, 0x4b, 0xb0, 0x34, 0x48, 0xef, 0x2f, 0xfb, 0xe9, 0x59, 0xe9, + 0x55, 0xc6, 0x8d, 0x8f, 0xf4, 0x0f, 0x58, 0x18, 0xde, 0x0f, 0x7a, 0xa5, 0xd7, 0x95, 0xc2, 0xe1, + 0xda, 0xaf, 0x5f, 0x6b, 0xe3, 0x7c, 0xb5, 0xe7, 0x73, 0xd5, 0xdc, 0xfd, 0xa0, 0x67, 0xb2, 0x6b, + 0xd5, 0x7f, 0x97, 0x61, 0x21, 0x1c, 0x69, 0x11, 0x96, 0x12, 0xd5, 0x52, 0xfa, 0x4f, 0x45, 0x7e, + 0xa0, 0x04, 0x56, 0x78, 0x93, 0x39, 0x1f, 0xa1, 0xb5, 0xac, 0x81, 0xa4, 0x40, 0x29, 0xac, 0x71, + 0xad, 0x1c, 0xe3, 0xce, 0x27, 0xb1, 0x60, 0x0e, 0xc9, 0x2b, 0xba, 0x07, 0x3b, 0x11, 0x46, 0x75, + 0x34, 0xb6, 0x29, 0xe3, 0x11, 0x3c, 0xb9, 0xf2, 0x9a, 0x6e, 0xc2, 0x7a, 0xcc, 0xa4, 0xf1, 0x52, + 0x59, 0xc7, 0xda, 0x6d, 0xe6, 0xa4, 0x56, 0x64, 0x21, 0xc0, 0xb6, 0xab, 0xf8, 0x43, 0xf8, 0x47, + 0xfa, 0x11, 0x0e, 0x0c, 0x9e, 0x24, 0x68, 0x9d, 0x67, 0x42, 0x18, 0xb4, 0xd6, 0x1f, 0x69, 0xe3, + 0x9d, 0x61, 0xca, 0x32, 0x9e, 0x89, 0x16, 0xe9, 0x37, 0xf8, 0xcc, 0x38, 0xc7, 0xd8, 0xf9, 0x97, + 0xb4, 0x4b, 0xf4, 0x67, 0xf8, 0x22, 0x90, 0xb7, 0xa5, 0xc2, 0x17, 0xc5, 0x6f, 0xe8, 0x36, 0xbc, + 0x1b, 0x8b, 0x66, 0x89, 0x65, 0xba, 0x01, 0xc4, 0xa2, 0x12, 0x0f, 0x50, 0xa0, 0x07, 0xb0, 0xfb, + 0x38, 0xf6, 0xac, 0xa0, 0x18, 0xac, 0x79, 0x52, 0xa4, 0x1f, 0x19, 0x48, 0x56, 0xe6, 0xd3, 0x8c, + 0x73, 0x9d, 0x28, 0x47, 0x56, 0xe9, 0x07, 0xd8, 0x7b, 0x4a, 0xc7, 0x49, 0xbd, 0x2d, 0xb9, 0x0f, + 0x7d, 0x21, 0x6b, 0x74, 0x1f, 0xca, 0xe3, 0x7e, 0x70, 0x2d, 0xd0, 0x33, 0xd1, 0x41, 0xe3, 0xa4, + 0xc5, 0x08, 0x95, 0x23, 0x6f, 0x69, 0x15, 0xf6, 0xe3, 0xc4, 0x36, 0xbd, 0xd2, 0x4e, 0x1e, 0x49, + 0x9e, 0x87, 0x30, 0xd8, 0x90, 0xd6, 0x99, 0xdc, 0x72, 0x12, 0x1c, 0xfa, 0xbe, 0xc6, 0x1b, 0xb4, + 0xb1, 0x56, 0x16, 0xc9, 0x3a, 0xdd, 0x85, 0xed, 0xa7, 0xe2, 0x93, 0x04, 0x4d, 0x97, 0x50, 0xfa, + 0x09, 0x2a, 0xcf, 0x90, 0xd3, 0x10, 0xef, 0x42, 0xd5, 0xf3, 0xf2, 0x65, 0xfe, 0x91, 0x8d, 0x50, + 0xd2, 0x3c, 0x7a, 0x74, 0x7d, 0x33, 0x8c, 0x20, 0x46, 0xfa, 0x58, 0x7a, 0x83, 0x23, 0x9f, 0xb7, + 0xe8, 0x0e, 0x6c, 0x36, 0x8c, 0x4e, 0xe2, 0xcc, 0x16, 0x2f, 0x55, 0x47, 0xba, 0xbc, 0xba, 0x6d, + 0xba, 0x0e, 0xab, 0x39, 0x28, 0x50, 0x39, 0xe9, 0xba, 0xa4, 0x14, 0xd4, 0x5c, 0x47, 0x51, 0xa2, + 0xa4, 0xeb, 0x7a, 0x81, 0x96, 0x1b, 0x19, 0x67, 0xea, 0x1d, 0x5a, 0x82, 0x8d, 0x29, 0x35, 0x13, + 0xa7, 0x1c, 0x5e, 0x3d, 0x65, 0x26, 0xdd, 0xd6, 0xfe, 0x58, 0x4b, 0x45, 0x76, 0xe9, 0x5b, 0x28, + 0xc6, 0x52, 0x4d, 0xc6, 0xfe, 0x7d, 0xd8, 0x1d, 0x14, 0x72, 0xba, 0x3b, 0x7b, 0xe1, 0x25, 0xd6, + 0x31, 0x97, 0xd8, 0xf1, 0xea, 0xec, 0x87, 0x5a, 0x04, 0xb6, 0x71, 0x66, 0x5f, 0x0e, 0xc2, 0x50, + 0xcd, 0x9b, 0x99, 0x51, 0x6a, 0x52, 0xa1, 0x65, 0xd8, 0x62, 0x4a, 0xab, 0x6e, 0xa4, 0x13, 0xeb, + 0x23, 0x74, 0x46, 0x72, 0x5f, 0x67, 0x8e, 0x37, 0xc9, 0x87, 0xc9, 0x56, 0x65, 0x25, 0x1b, 0x8c, + 0x74, 0x07, 0x05, 0xa9, 0x86, 0xae, 0x4d, 0xe1, 0x51, 0x2a, 0x1b, 0x0c, 0x14, 0xe4, 0x23, 0x05, + 0x58, 0xac, 0x33, 0xde, 0x4a, 0x62, 0xf2, 0x69, 0x32, 0x91, 0xc1, 0xd9, 0x4e, 0xa8, 0x94, 0xa3, + 0x72, 0x68, 0x72, 0xe9, 0x4f, 0x93, 0x89, 0x7c, 0x4c, 0xe7, 0xdb, 0x88, 0x82, 0x7c, 0x0e, 0x13, + 0x37, 0x57, 0x22, 0xa4, 0x8d, 0xa4, 0xb5, 0x28, 0xc8, 0x97, 0xcc, 0x89, 0xa0, 0xa9, 0x6b, 0xdd, + 0x8a, 0x98, 0x69, 0x91, 0x43, 0xba, 0x05, 0x34, 0x7f, 0x61, 0x1b, 0x99, 0xf1, 0x4d, 0x69, 0x9d, + 0x36, 0x5d, 0xf2, 0x35, 0xd8, 0x98, 0xe1, 0x16, 0x9d, 0x93, 0xaa, 0x41, 0xbe, 0xd5, 0x57, 0xff, + 0x2a, 0xd6, 0x7e, 0xf9, 0x7d, 0xfc, 0x7d, 0x3b, 0x5d, 0xcc, 0xfe, 0xfd, 0xf6, 0x7f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xab, 0x54, 0x29, 0x45, 0x86, 0x05, 0x00, 0x00, } diff --git a/protocol/protobuf/application_metadata_message.proto b/protocol/protobuf/application_metadata_message.proto index efaa2dfe9..9e1b60582 100644 --- a/protocol/protobuf/application_metadata_message.proto +++ b/protocol/protobuf/application_metadata_message.proto @@ -55,5 +55,6 @@ message ApplicationMetadataMessage { SYNC_ACTIVITY_CENTER_DISMISSED = 39; SYNC_BOOKMARK = 40; SYNC_CLEAR_HISTORY = 41; + SYNC_SETTING = 42; } } diff --git a/protocol/protobuf/service.go b/protocol/protobuf/service.go index a72907fbe..79960c9a8 100644 --- a/protocol/protobuf/service.go +++ b/protocol/protobuf/service.go @@ -4,7 +4,7 @@ import ( "github.com/golang/protobuf/proto" ) -//go:generate protoc --go_out=. ./chat_message.proto ./application_metadata_message.proto ./membership_update_message.proto ./command.proto ./contact.proto ./pairing.proto ./push_notifications.proto ./emoji_reaction.proto ./enums.proto ./group_chat_invitation.proto ./chat_identity.proto ./communities.proto ./pin_message.proto ./anon_metrics.proto ./status_update.proto +//go:generate protoc --go_out=. ./chat_message.proto ./application_metadata_message.proto ./membership_update_message.proto ./command.proto ./contact.proto ./pairing.proto ./push_notifications.proto ./emoji_reaction.proto ./enums.proto ./group_chat_invitation.proto ./chat_identity.proto ./communities.proto ./pin_message.proto ./anon_metrics.proto ./status_update.proto ./sync_settings.proto func Unmarshal(payload []byte) (*ApplicationMetadataMessage, error) { var message ApplicationMetadataMessage diff --git a/protocol/protobuf/sync_settings.pb.go b/protocol/protobuf/sync_settings.pb.go new file mode 100644 index 000000000..b05dd8835 --- /dev/null +++ b/protocol/protobuf/sync_settings.pb.go @@ -0,0 +1,246 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: sync_settings.proto + +package protobuf + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type SyncSetting_Type int32 + +const ( + SyncSetting_UNKNOWN SyncSetting_Type = 0 + SyncSetting_CURRENCY SyncSetting_Type = 1 + SyncSetting_GIF_RECENTS SyncSetting_Type = 2 + SyncSetting_GIF_FAVOURITES SyncSetting_Type = 3 + SyncSetting_MESSAGES_FROM_CONTACTS_ONLY SyncSetting_Type = 4 + SyncSetting_PREFERRED_NAME SyncSetting_Type = 5 + SyncSetting_PREVIEW_PRIVACY SyncSetting_Type = 6 + SyncSetting_PROFILE_PICTURES_SHOW_TO SyncSetting_Type = 7 + SyncSetting_PROFILE_PICTURES_VISIBILITY SyncSetting_Type = 8 + SyncSetting_SEND_STATUS_UPDATES SyncSetting_Type = 9 + SyncSetting_STICKERS_PACKS_INSTALLED SyncSetting_Type = 10 + SyncSetting_STICKERS_PACKS_PENDING SyncSetting_Type = 11 + SyncSetting_STICKERS_RECENT_STICKERS SyncSetting_Type = 12 +) + +var SyncSetting_Type_name = map[int32]string{ + 0: "UNKNOWN", + 1: "CURRENCY", + 2: "GIF_RECENTS", + 3: "GIF_FAVOURITES", + 4: "MESSAGES_FROM_CONTACTS_ONLY", + 5: "PREFERRED_NAME", + 6: "PREVIEW_PRIVACY", + 7: "PROFILE_PICTURES_SHOW_TO", + 8: "PROFILE_PICTURES_VISIBILITY", + 9: "SEND_STATUS_UPDATES", + 10: "STICKERS_PACKS_INSTALLED", + 11: "STICKERS_PACKS_PENDING", + 12: "STICKERS_RECENT_STICKERS", +} + +var SyncSetting_Type_value = map[string]int32{ + "UNKNOWN": 0, + "CURRENCY": 1, + "GIF_RECENTS": 2, + "GIF_FAVOURITES": 3, + "MESSAGES_FROM_CONTACTS_ONLY": 4, + "PREFERRED_NAME": 5, + "PREVIEW_PRIVACY": 6, + "PROFILE_PICTURES_SHOW_TO": 7, + "PROFILE_PICTURES_VISIBILITY": 8, + "SEND_STATUS_UPDATES": 9, + "STICKERS_PACKS_INSTALLED": 10, + "STICKERS_PACKS_PENDING": 11, + "STICKERS_RECENT_STICKERS": 12, +} + +func (x SyncSetting_Type) String() string { + return proto.EnumName(SyncSetting_Type_name, int32(x)) +} + +func (SyncSetting_Type) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_e2f7a0bce2873c78, []int{0, 0} +} + +type SyncSetting struct { + Type SyncSetting_Type `protobuf:"varint,1,opt,name=type,proto3,enum=protobuf.SyncSetting_Type" json:"type,omitempty"` + Clock uint64 `protobuf:"varint,2,opt,name=clock,proto3" json:"clock,omitempty"` + // Types that are valid to be assigned to Value: + // *SyncSetting_ValueString + // *SyncSetting_ValueBytes + // *SyncSetting_ValueBool + // *SyncSetting_ValueInt64 + Value isSyncSetting_Value `protobuf_oneof:"value"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SyncSetting) Reset() { *m = SyncSetting{} } +func (m *SyncSetting) String() string { return proto.CompactTextString(m) } +func (*SyncSetting) ProtoMessage() {} +func (*SyncSetting) Descriptor() ([]byte, []int) { + return fileDescriptor_e2f7a0bce2873c78, []int{0} +} + +func (m *SyncSetting) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SyncSetting.Unmarshal(m, b) +} +func (m *SyncSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SyncSetting.Marshal(b, m, deterministic) +} +func (m *SyncSetting) XXX_Merge(src proto.Message) { + xxx_messageInfo_SyncSetting.Merge(m, src) +} +func (m *SyncSetting) XXX_Size() int { + return xxx_messageInfo_SyncSetting.Size(m) +} +func (m *SyncSetting) XXX_DiscardUnknown() { + xxx_messageInfo_SyncSetting.DiscardUnknown(m) +} + +var xxx_messageInfo_SyncSetting proto.InternalMessageInfo + +func (m *SyncSetting) GetType() SyncSetting_Type { + if m != nil { + return m.Type + } + return SyncSetting_UNKNOWN +} + +func (m *SyncSetting) GetClock() uint64 { + if m != nil { + return m.Clock + } + return 0 +} + +type isSyncSetting_Value interface { + isSyncSetting_Value() +} + +type SyncSetting_ValueString struct { + ValueString string `protobuf:"bytes,3,opt,name=value_string,json=valueString,proto3,oneof"` +} + +type SyncSetting_ValueBytes struct { + ValueBytes []byte `protobuf:"bytes,4,opt,name=value_bytes,json=valueBytes,proto3,oneof"` +} + +type SyncSetting_ValueBool struct { + ValueBool bool `protobuf:"varint,5,opt,name=value_bool,json=valueBool,proto3,oneof"` +} + +type SyncSetting_ValueInt64 struct { + ValueInt64 int64 `protobuf:"varint,6,opt,name=value_int64,json=valueInt64,proto3,oneof"` +} + +func (*SyncSetting_ValueString) isSyncSetting_Value() {} + +func (*SyncSetting_ValueBytes) isSyncSetting_Value() {} + +func (*SyncSetting_ValueBool) isSyncSetting_Value() {} + +func (*SyncSetting_ValueInt64) isSyncSetting_Value() {} + +func (m *SyncSetting) GetValue() isSyncSetting_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *SyncSetting) GetValueString() string { + if x, ok := m.GetValue().(*SyncSetting_ValueString); ok { + return x.ValueString + } + return "" +} + +func (m *SyncSetting) GetValueBytes() []byte { + if x, ok := m.GetValue().(*SyncSetting_ValueBytes); ok { + return x.ValueBytes + } + return nil +} + +func (m *SyncSetting) GetValueBool() bool { + if x, ok := m.GetValue().(*SyncSetting_ValueBool); ok { + return x.ValueBool + } + return false +} + +func (m *SyncSetting) GetValueInt64() int64 { + if x, ok := m.GetValue().(*SyncSetting_ValueInt64); ok { + return x.ValueInt64 + } + return 0 +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SyncSetting) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*SyncSetting_ValueString)(nil), + (*SyncSetting_ValueBytes)(nil), + (*SyncSetting_ValueBool)(nil), + (*SyncSetting_ValueInt64)(nil), + } +} + +func init() { + proto.RegisterEnum("protobuf.SyncSetting_Type", SyncSetting_Type_name, SyncSetting_Type_value) + proto.RegisterType((*SyncSetting)(nil), "protobuf.SyncSetting") +} + +func init() { + proto.RegisterFile("sync_settings.proto", fileDescriptor_e2f7a0bce2873c78) +} + +var fileDescriptor_e2f7a0bce2873c78 = []byte{ + // 447 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0xcd, 0x8e, 0xd3, 0x30, + 0x10, 0x80, 0x9b, 0x36, 0xfd, 0x9b, 0x94, 0x5d, 0xcb, 0x45, 0x10, 0x2d, 0x48, 0x1b, 0x96, 0x4b, + 0x4e, 0x41, 0x02, 0xc4, 0x85, 0x53, 0x9a, 0x38, 0xad, 0xd5, 0xd4, 0x89, 0x6c, 0xa7, 0x55, 0xb9, + 0x58, 0xb4, 0x0a, 0xab, 0x8a, 0x2a, 0xa9, 0x36, 0x29, 0x52, 0x9e, 0x89, 0x97, 0xe0, 0xd1, 0x50, + 0x12, 0xca, 0xdf, 0x9e, 0xec, 0xf9, 0xe6, 0x9b, 0xf1, 0x68, 0x64, 0x98, 0x16, 0x55, 0xb6, 0x57, + 0x45, 0x5a, 0x96, 0x87, 0xec, 0xbe, 0x70, 0x4e, 0x0f, 0x79, 0x99, 0xe3, 0x51, 0x73, 0xec, 0xce, + 0x5f, 0xee, 0xbe, 0xeb, 0x60, 0x88, 0x2a, 0xdb, 0x8b, 0x56, 0xc0, 0x0e, 0xe8, 0x65, 0x75, 0x4a, + 0x4d, 0xcd, 0xd2, 0xec, 0xab, 0xb7, 0x37, 0xce, 0x45, 0x74, 0xfe, 0x92, 0x1c, 0x59, 0x9d, 0x52, + 0xde, 0x78, 0xf8, 0x29, 0xf4, 0xf7, 0xc7, 0x7c, 0xff, 0xd5, 0xec, 0x5a, 0x9a, 0xad, 0xf3, 0x36, + 0xc0, 0xaf, 0x61, 0xf2, 0xed, 0xf3, 0xf1, 0x9c, 0xaa, 0xa2, 0x7c, 0x38, 0x64, 0xf7, 0x66, 0xcf, + 0xd2, 0xec, 0xf1, 0xa2, 0xc3, 0x8d, 0x86, 0x8a, 0x06, 0xe2, 0x57, 0xd0, 0x86, 0x6a, 0x57, 0x95, + 0x69, 0x61, 0xea, 0x96, 0x66, 0x4f, 0x16, 0x1d, 0x0e, 0x0d, 0x9c, 0xd5, 0x0c, 0xdf, 0x02, 0xfc, + 0x52, 0xf2, 0xfc, 0x68, 0xf6, 0x2d, 0xcd, 0x1e, 0x2d, 0x3a, 0x7c, 0xdc, 0x1a, 0x79, 0x7e, 0xfc, + 0xd3, 0xe3, 0x90, 0x95, 0x1f, 0xde, 0x9b, 0x03, 0x4b, 0xb3, 0x7b, 0xbf, 0x7b, 0xd0, 0x9a, 0xdd, + 0xfd, 0xe8, 0x82, 0x5e, 0x0f, 0x8c, 0x0d, 0x18, 0x26, 0x6c, 0xc9, 0xa2, 0x0d, 0x43, 0x1d, 0x3c, + 0x81, 0x91, 0x97, 0x70, 0x4e, 0x98, 0xb7, 0x45, 0x1a, 0xbe, 0x06, 0x63, 0x4e, 0x03, 0xc5, 0x89, + 0x47, 0x98, 0x14, 0xa8, 0x8b, 0x31, 0x5c, 0xd5, 0x20, 0x70, 0xd7, 0x51, 0xc2, 0xa9, 0x24, 0x02, + 0xf5, 0xf0, 0x2d, 0xbc, 0x58, 0x11, 0x21, 0xdc, 0x39, 0x11, 0x2a, 0xe0, 0xd1, 0x4a, 0x79, 0x11, + 0x93, 0xae, 0x27, 0x85, 0x8a, 0x58, 0xb8, 0x45, 0x7a, 0x5d, 0x14, 0x73, 0x12, 0x10, 0xce, 0x89, + 0xaf, 0x98, 0xbb, 0x22, 0xa8, 0x8f, 0xa7, 0x70, 0x1d, 0x73, 0xb2, 0xa6, 0x64, 0xa3, 0x62, 0x4e, + 0xd7, 0xae, 0xb7, 0x45, 0x03, 0xfc, 0x12, 0xcc, 0x98, 0x47, 0x01, 0x0d, 0x89, 0x8a, 0xa9, 0x27, + 0x13, 0x4e, 0x84, 0x12, 0x8b, 0x68, 0xa3, 0x64, 0x84, 0x86, 0xf5, 0x3b, 0x8f, 0xb2, 0x6b, 0x2a, + 0xe8, 0x8c, 0x86, 0x54, 0x6e, 0xd1, 0x08, 0x3f, 0x87, 0xa9, 0x20, 0xcc, 0x57, 0x42, 0xba, 0x32, + 0x11, 0x2a, 0x89, 0x7d, 0xb7, 0x9e, 0x70, 0x5c, 0xf7, 0x15, 0x92, 0x7a, 0x4b, 0xc2, 0x85, 0x8a, + 0x5d, 0x6f, 0x29, 0x14, 0x65, 0x42, 0xba, 0x61, 0x48, 0x7c, 0x04, 0xf8, 0x06, 0x9e, 0xfd, 0x97, + 0x8d, 0x09, 0xf3, 0x29, 0x9b, 0x23, 0xe3, 0x9f, 0xca, 0x76, 0x0b, 0xea, 0x12, 0xa3, 0xc9, 0x6c, + 0x08, 0xfd, 0x76, 0xe5, 0x4f, 0x3e, 0x19, 0xce, 0x9b, 0x8f, 0x97, 0x3f, 0xb1, 0x1b, 0x34, 0xb7, + 0x77, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x91, 0x74, 0x80, 0x25, 0x64, 0x02, 0x00, 0x00, +} diff --git a/protocol/protobuf/sync_settings.proto b/protocol/protobuf/sync_settings.proto new file mode 100644 index 000000000..cfe3d1754 --- /dev/null +++ b/protocol/protobuf/sync_settings.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +option go_package = "./;protobuf"; +package protobuf; + +message SyncSetting { + Type type = 1; + uint64 clock = 2; + + oneof value { + string value_string = 3; + bytes value_bytes = 4; + bool value_bool = 5; + int64 value_int64 = 6; + } + + enum Type { + UNKNOWN = 0; + CURRENCY = 1; + GIF_RECENTS = 2; + GIF_FAVOURITES = 3; + MESSAGES_FROM_CONTACTS_ONLY = 4; + PREFERRED_NAME = 5; + PREVIEW_PRIVACY = 6; + PROFILE_PICTURES_SHOW_TO = 7; + PROFILE_PICTURES_VISIBILITY = 8; + SEND_STATUS_UPDATES = 9; + STICKERS_PACKS_INSTALLED = 10; + STICKERS_PACKS_PENDING = 11; + STICKERS_RECENT_STICKERS = 12; + } +} + +/* TODOs +LastBackup uint64 +BackupEnabled bool + */ diff --git a/protocol/pushnotificationclient/migrations/migrations.go b/protocol/pushnotificationclient/migrations/migrations.go index 9bd002b56..45a724926 100644 --- a/protocol/pushnotificationclient/migrations/migrations.go +++ b/protocol/pushnotificationclient/migrations/migrations.go @@ -90,7 +90,7 @@ func _1593601729_initial_schemaDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1593601729_initial_schema.down.sql", size: 144, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1593601729_initial_schema.down.sql", size: 144, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa, 0x95, 0x55, 0x64, 0x38, 0x40, 0x16, 0xbf, 0x8b, 0x1c, 0x18, 0xb4, 0xc5, 0x7f, 0xd0, 0xb8, 0xf0, 0x3c, 0xa2, 0x82, 0xf8, 0x8d, 0x5a, 0xd3, 0xb6, 0x6e, 0xa3, 0xb4, 0xc, 0x9, 0x33, 0x0}} return a, nil } @@ -110,7 +110,7 @@ func _1593601729_initial_schemaUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1593601729_initial_schema.up.sql", size: 1773, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1593601729_initial_schema.up.sql", size: 1773, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4e, 0x1e, 0x5, 0x35, 0x9, 0xb2, 0x2d, 0x6f, 0x33, 0x63, 0xa2, 0x7a, 0x5b, 0xd2, 0x2d, 0xcb, 0x79, 0x7e, 0x6, 0xb4, 0x9d, 0x35, 0xd8, 0x9b, 0x55, 0xe5, 0xf8, 0x44, 0xca, 0xa6, 0xf3, 0xd3}} return a, nil } @@ -130,7 +130,7 @@ func _1597909626_add_server_typeDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1597909626_add_server_type.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1597909626_add_server_type.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -150,7 +150,7 @@ func _1597909626_add_server_typeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1597909626_add_server_type.up.sql", size: 145, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1597909626_add_server_type.up.sql", size: 145, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc8, 0x3f, 0xe0, 0xe7, 0x57, 0x0, 0x5d, 0x60, 0xf3, 0x55, 0x64, 0x71, 0x80, 0x3c, 0xca, 0x8, 0x61, 0xb5, 0x3c, 0xe, 0xa1, 0xe4, 0x61, 0xd1, 0x4e, 0xd8, 0xb2, 0x55, 0xdd, 0x87, 0x62, 0x9b}} return a, nil } @@ -170,7 +170,7 @@ func _1599053776_add_chat_id_and_typeDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1599053776_add_chat_id_and_type.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1599053776_add_chat_id_and_type.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} return a, nil } @@ -190,7 +190,7 @@ func _1599053776_add_chat_id_and_typeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1599053776_add_chat_id_and_type.up.sql", size: 264, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1599053776_add_chat_id_and_type.up.sql", size: 264, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xea, 0x7a, 0xf9, 0xc4, 0xa2, 0x96, 0x2e, 0xf9, 0x8f, 0x7, 0xf1, 0x1e, 0x73, 0x8a, 0xa6, 0x3a, 0x13, 0x4, 0x73, 0x82, 0x83, 0xb, 0xe3, 0xb5, 0x3b, 0x7e, 0xd, 0x23, 0xce, 0x98, 0xd4, 0xdc}} return a, nil } @@ -210,7 +210,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 382, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "doc.go", size: 382, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc0, 0x2f, 0x1e, 0x64, 0x9, 0x93, 0xe4, 0x8b, 0xf2, 0x98, 0x5a, 0x45, 0xe2, 0x80, 0x88, 0x67, 0x7a, 0x2d, 0xd7, 0x4b, 0xd1, 0x73, 0xb6, 0x6d, 0x15, 0xc2, 0x0, 0x34, 0xcd, 0xa0, 0xdb, 0x20}} return a, nil } diff --git a/protocol/pushnotificationserver/migrations/migrations.go b/protocol/pushnotificationserver/migrations/migrations.go index feb73a6aa..174d36052 100644 --- a/protocol/pushnotificationserver/migrations/migrations.go +++ b/protocol/pushnotificationserver/migrations/migrations.go @@ -88,7 +88,7 @@ func _1593601728_initial_schemaDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1593601728_initial_schema.down.sql", size: 200, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1593601728_initial_schema.down.sql", size: 200, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x88, 0x8a, 0x61, 0x81, 0x57, 0x45, 0x9b, 0x97, 0x9b, 0x1f, 0xf6, 0x94, 0x8a, 0x20, 0xb3, 0x2b, 0xff, 0x69, 0x49, 0xf4, 0x58, 0xcc, 0xd0, 0x55, 0xcc, 0x9a, 0x8b, 0xb6, 0x7f, 0x29, 0x53, 0xc1}} return a, nil } @@ -108,7 +108,7 @@ func _1593601728_initial_schemaUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1593601728_initial_schema.up.sql", size: 675, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1593601728_initial_schema.up.sql", size: 675, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfd, 0x61, 0x90, 0x79, 0xd9, 0x14, 0x65, 0xe9, 0x96, 0x53, 0x17, 0x33, 0x54, 0xeb, 0x8b, 0x5d, 0x95, 0x99, 0x10, 0x36, 0x58, 0xdd, 0xb2, 0xbf, 0x45, 0xd9, 0xbb, 0xc4, 0x92, 0xe, 0xce, 0x2}} return a, nil } @@ -128,7 +128,7 @@ func _1598419937_add_push_notifications_tableDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1598419937_add_push_notifications_table.down.sql", size: 51, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1598419937_add_push_notifications_table.down.sql", size: 51, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc, 0x98, 0xc8, 0x30, 0x45, 0x5b, 0xc5, 0x7d, 0x13, 0x5d, 0xe7, 0xc8, 0x23, 0x43, 0xf7, 0xdc, 0x9c, 0xe2, 0xdd, 0x63, 0xf0, 0xb7, 0x16, 0x40, 0xc, 0xda, 0xb9, 0x16, 0x70, 0x2b, 0x5a, 0x7e}} return a, nil } @@ -148,7 +148,7 @@ func _1598419937_add_push_notifications_tableUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1598419937_add_push_notifications_table.up.sql", size: 104, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "1598419937_add_push_notifications_table.up.sql", size: 104, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2, 0x3e, 0xef, 0xf, 0xc2, 0xdf, 0xbc, 0x99, 0x7a, 0xc2, 0xd3, 0x64, 0x4f, 0x4c, 0x7e, 0xfc, 0x2e, 0x8c, 0xa7, 0x54, 0xd3, 0x4d, 0x25, 0x98, 0x41, 0xbc, 0xea, 0xd7, 0x2, 0xc1, 0xd0, 0x52}} return a, nil } @@ -168,7 +168,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 382, mode: os.FileMode(0644), modTime: time.Unix(1611588835, 0)} + info := bindataFileInfo{name: "doc.go", size: 382, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc0, 0x2f, 0x1e, 0x64, 0x9, 0x93, 0xe4, 0x8b, 0xf2, 0x98, 0x5a, 0x45, 0xe2, 0x80, 0x88, 0x67, 0x7a, 0x2d, 0xd7, 0x4b, 0xd1, 0x73, 0xb6, 0x6d, 0x15, 0xc2, 0x0, 0x34, 0xcd, 0xa0, 0xdb, 0x20}} return a, nil } diff --git a/protocol/transport/migrations/migrations.go b/protocol/transport/migrations/migrations.go index 5ebbb09e8..baa50830d 100644 --- a/protocol/transport/migrations/migrations.go +++ b/protocol/transport/migrations/migrations.go @@ -89,7 +89,7 @@ func _1561059284_add_waku_keysDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059284_add_waku_keys.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1561059284_add_waku_keys.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe5, 0x2a, 0x7e, 0x9, 0xa3, 0xdd, 0xc6, 0x3, 0xfa, 0xaa, 0x98, 0xa0, 0x26, 0x5e, 0x67, 0x43, 0xe6, 0x20, 0xfd, 0x10, 0xfd, 0x60, 0x89, 0x17, 0x13, 0x87, 0x1b, 0x44, 0x36, 0x79, 0xb6, 0x60}} return a, nil } @@ -109,7 +109,7 @@ func _1561059284_add_waku_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059284_add_waku_keys.up.sql", size: 109, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1561059284_add_waku_keys.up.sql", size: 109, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x5c, 0x8, 0x32, 0xef, 0x12, 0x88, 0x21, 0xd, 0x7a, 0x42, 0x4d, 0xe7, 0x2d, 0x6c, 0x99, 0xb6, 0x1, 0xf1, 0xba, 0x2c, 0x40, 0x8d, 0xa9, 0x4b, 0xe6, 0xc4, 0x21, 0xec, 0x47, 0x6b, 0xf7}} return a, nil } @@ -129,7 +129,7 @@ func _1616691080_add_wakuv2_keysDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1616691080_add_wakuV2_keys.down.sql", size: 24, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1616691080_add_wakuV2_keys.down.sql", size: 24, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x42, 0xb6, 0x23, 0x70, 0xb8, 0x63, 0x18, 0x61, 0xea, 0x35, 0x6e, 0xae, 0xe9, 0x71, 0x89, 0xa, 0xa5, 0x72, 0xa2, 0x64, 0xaa, 0x45, 0x1, 0xf, 0xfc, 0xee, 0x1b, 0xd9, 0xd2, 0x27, 0xf4, 0xe2}} return a, nil } @@ -149,7 +149,7 @@ func _1616691080_add_wakuv2_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1616691080_add_wakuV2_keys.up.sql", size: 111, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "1616691080_add_wakuV2_keys.up.sql", size: 111, mode: os.FileMode(0644), modTime: time.Unix(1628714143, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x10, 0xf0, 0x97, 0x25, 0xfe, 0x96, 0x2c, 0xa8, 0x62, 0x4a, 0x71, 0x75, 0xff, 0x5f, 0x43, 0x1e, 0x71, 0x53, 0xf1, 0xde, 0xf, 0xcf, 0xcd, 0x87, 0x15, 0x61, 0x9d, 0x25, 0x2e, 0xaf, 0x18, 0x99}} return a, nil } @@ -169,7 +169,7 @@ func _1634723014_add_wakuv2_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1634723014_add_wakuV2_keys.up.sql", size: 125, mode: os.FileMode(0644), modTime: time.Unix(1643037480, 0)} + info := bindataFileInfo{name: "1634723014_add_wakuV2_keys.up.sql", size: 125, mode: os.FileMode(0644), modTime: time.Unix(1635152717, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7e, 0xe1, 0x7a, 0x1e, 0x6, 0xad, 0x1b, 0x37, 0xdb, 0xea, 0x94, 0xaf, 0xe0, 0x7d, 0xc9, 0xd6, 0xda, 0x52, 0x71, 0x8a, 0x44, 0xb3, 0xa6, 0x7b, 0x1e, 0x90, 0xdb, 0x1e, 0x5a, 0xa, 0x40, 0x26}} return a, nil } @@ -189,7 +189,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1621263711, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x23, 0x6a, 0xc1, 0xce, 0x94, 0xf6, 0xef, 0xf1, 0x97, 0x95, 0xb, 0x35, 0xaf, 0x5f, 0xe7, 0x5f, 0xac, 0x6e, 0xb8, 0xab, 0xba, 0xb5, 0x35, 0x97, 0x22, 0x36, 0x11, 0xce, 0x44, 0xfc, 0xfa, 0xac}} return a, nil } diff --git a/protocol/v1/status_message.go b/protocol/v1/status_message.go index 2b3cd0962..d22e92680 100644 --- a/protocol/v1/status_message.go +++ b/protocol/v1/status_message.go @@ -267,6 +267,8 @@ func (m *StatusMessage) HandleApplication() error { return m.unmarshalProtobufData(new(protobuf.SyncBookmark)) case protobuf.ApplicationMetadataMessage_SYNC_CLEAR_HISTORY: return m.unmarshalProtobufData(new(protobuf.SyncClearHistory)) + case protobuf.ApplicationMetadataMessage_SYNC_SETTING: + return m.unmarshalProtobufData(new(protobuf.SyncSetting)) } return nil } diff --git a/services/accounts/accounts.go b/services/accounts/accounts.go index 644881654..dc29b8883 100644 --- a/services/accounts/accounts.go +++ b/services/accounts/accounts.go @@ -12,6 +12,7 @@ import ( "github.com/status-im/status-go/account" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" ) @@ -178,7 +179,7 @@ func (api *API) GenerateAccount( return err } - account := accounts.Account{ + acc := accounts.Account{ Address: types.Address(common.HexToAddress(infos[path].Address)), PublicKey: types.HexBytes(infos[path].PublicKey), Type: "generated", @@ -188,12 +189,12 @@ func (api *API) GenerateAccount( Path: path, } - err = api.db.SaveSetting("latest-derived-path", newDerivedPath) + err = api.db.SaveSettingField(settings.LatestDerivedPath, newDerivedPath) if err != nil { return err } - return api.SaveAccounts(ctx, []accounts.Account{account}) + return api.SaveAccounts(ctx, []accounts.Account{acc}) } func (api *API) verifyPassword(password string) error { diff --git a/services/accounts/settings.go b/services/accounts/settings.go index 84cdd8f13..8ff2c463a 100644 --- a/services/accounts/settings.go +++ b/services/accounts/settings.go @@ -4,6 +4,7 @@ import ( "context" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/nodecfg" "github.com/status-im/status-go/params" ) @@ -26,7 +27,7 @@ func (api *SettingsAPI) SaveSetting(ctx context.Context, typ string, val interfa return api.db.SaveSetting(typ, val) } -func (api *SettingsAPI) GetSettings(ctx context.Context) (accounts.Settings, error) { +func (api *SettingsAPI) GetSettings(ctx context.Context) (settings.Settings, error) { return api.db.GetSettings() } diff --git a/services/chat/service.go b/services/chat/service.go index d4678ac21..4e33b4360 100644 --- a/services/chat/service.go +++ b/services/chat/service.go @@ -1,8 +1,6 @@ package chat import ( - "database/sql" - "github.com/ethereum/go-ethereum/p2p" gethrpc "github.com/ethereum/go-ethereum/rpc" @@ -10,9 +8,9 @@ import ( "github.com/status-im/status-go/protocol" ) -func NewService(appDB *sql.DB) *Service { +func NewService(accountsDB *accounts.Database) *Service { return &Service{ - accountsDB: accounts.NewDB(appDB), + accountsDB: accountsDB, } } diff --git a/services/ext/api.go b/services/ext/api.go index 535246271..ac332f66b 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -17,7 +17,7 @@ import ( "github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/mailserver" - "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/protocol" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/communities" @@ -705,7 +705,7 @@ func (api *PublicAPI) SignMessageWithChatKey(ctx context.Context, message string // PushNotifications server endpoints func (api *PublicAPI) StartPushNotificationsServer() error { - err := api.service.accountsDB.SaveSetting("push-notifications-server-enabled?", true) + err := api.service.accountsDB.SaveSettingField(settings.PushNotificationsServerEnabled, true) if err != nil { return err } @@ -714,7 +714,7 @@ func (api *PublicAPI) StartPushNotificationsServer() error { } func (api *PublicAPI) StopPushNotificationsServer() error { - err := api.service.accountsDB.SaveSetting("push-notifications-server-enabled?", false) + err := api.service.accountsDB.SaveSettingField(settings.PushNotificationsServerEnabled, false) if err != nil { return err } @@ -733,7 +733,7 @@ func (api *PublicAPI) UnregisterFromPushNotifications(ctx context.Context) error } func (api *PublicAPI) DisableSendingNotifications(ctx context.Context) error { - err := api.service.accountsDB.SaveSetting("send-push-notifications?", false) + err := api.service.accountsDB.SaveSettingField(settings.SendPushNotifications, false) if err != nil { return err } @@ -742,7 +742,7 @@ func (api *PublicAPI) DisableSendingNotifications(ctx context.Context) error { } func (api *PublicAPI) EnableSendingNotifications(ctx context.Context) error { - err := api.service.accountsDB.SaveSetting("send-push-notifications?", true) + err := api.service.accountsDB.SaveSettingField(settings.SendPushNotifications, true) if err != nil { return err } @@ -750,7 +750,7 @@ func (api *PublicAPI) EnableSendingNotifications(ctx context.Context) error { } func (api *PublicAPI) EnablePushNotificationsFromContactsOnly(ctx context.Context) error { - err := api.service.accountsDB.SaveSetting("push-notifications-from-contacts-only?", true) + err := api.service.accountsDB.SaveSettingField(settings.PushNotificationsFromContactsOnly, true) if err != nil { return err } @@ -758,7 +758,7 @@ func (api *PublicAPI) EnablePushNotificationsFromContactsOnly(ctx context.Contex } func (api *PublicAPI) DisablePushNotificationsFromContactsOnly(ctx context.Context) error { - err := api.service.accountsDB.SaveSetting("push-notifications-from-contacts-only?", false) + err := api.service.accountsDB.SaveSettingField(settings.PushNotificationsFromContactsOnly, false) if err != nil { return err } @@ -766,7 +766,7 @@ func (api *PublicAPI) DisablePushNotificationsFromContactsOnly(ctx context.Conte } func (api *PublicAPI) EnablePushNotificationsBlockMentions(ctx context.Context) error { - err := api.service.accountsDB.SaveSetting("push-notifications-block-mentions?", true) + err := api.service.accountsDB.SaveSettingField(settings.PushNotificationsBlockMentions, true) if err != nil { return err } @@ -774,7 +774,7 @@ func (api *PublicAPI) EnablePushNotificationsBlockMentions(ctx context.Context) } func (api *PublicAPI) DisablePushNotificationsBlockMentions(ctx context.Context) error { - err := api.service.accountsDB.SaveSetting("push-notifications-block-mentions?", false) + err := api.service.accountsDB.SaveSettingField(settings.PushNotificationsBlockMentions, false) if err != nil { return err } @@ -952,8 +952,8 @@ func (api *PublicAPI) Peers() map[string][]string { return api.service.messenger.Peers() } -func (api *PublicAPI) ChangeIdentityImageShowTo(showTo accounts.ProfilePicturesShowToType) error { - err := api.service.accountsDB.SaveSetting("profile-pictures-show-to", showTo) +func (api *PublicAPI) ChangeIdentityImageShowTo(showTo settings.ProfilePicturesShowToType) error { + err := api.service.accountsDB.SaveSettingField(settings.ProfilePicturesShowTo, showTo) if err != nil { return err } diff --git a/services/ext/service.go b/services/ext/service.go index 657042934..e05126bbe 100644 --- a/services/ext/service.go +++ b/services/ext/service.go @@ -105,6 +105,7 @@ func (s *Service) GetPeer(rawURL string) (*enode.Node, error) { } func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, db *sql.DB, multiAccountDb *multiaccounts.Database, acc *multiaccounts.Account, logger *zap.Logger) error { + var err error if !s.config.ShhextConfig.PFSEnabled { return nil } @@ -135,7 +136,10 @@ func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, db * EnvelopeEventsHandler: EnvelopeSignalHandler{}, Logger: logger, } - s.accountsDB = accounts.NewDB(db) + s.accountsDB, err = accounts.NewDB(db) + if err != nil { + return err + } s.multiAccountsDB = multiAccountDb s.account = acc diff --git a/services/gif/gif.go b/services/gif/gif.go index 3aac8cfde..7fde3d99a 100644 --- a/services/gif/gif.go +++ b/services/gif/gif.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" ) type Gif struct { @@ -41,7 +42,7 @@ type API struct { func (api *API) SetTenorAPIKey(key string) (err error) { log.Info("[GifAPI::SetTenorAPIKey]") - err = api.db.SaveSetting("gifs/api-key", key) + err = api.db.SaveSettingField(settings.GifAPIKey, key) if err != nil { return err } @@ -103,7 +104,7 @@ func (api *API) UpdateRecentGifs(updatedGifs json.RawMessage) (err error) { if err != nil { return err } - err = api.db.SaveSetting("gifs/recent-gifs", recentGifsContainer.Items) + err = api.db.SaveSettingField(settings.GifRecents, recentGifsContainer.Items) if err != nil { return err } @@ -117,7 +118,7 @@ func (api *API) UpdateFavoriteGifs(updatedGifs json.RawMessage) (err error) { if err != nil { return err } - err = api.db.SaveSetting("gifs/favorite-gifs", favsGifsContainer.Items) + err = api.db.SaveSettingField(settings.GifFavourites, favsGifsContainer.Items) if err != nil { return err } diff --git a/services/gif/gif_test.go b/services/gif/gif_test.go index edc038991..e360eb1c2 100644 --- a/services/gif/gif_test.go +++ b/services/gif/gif_test.go @@ -24,7 +24,9 @@ func setupSQLTestDb(t *testing.T) (*sql.DB, func()) { } func setupTestDB(t *testing.T, db *sql.DB) (*accounts.Database, func()) { - return accounts.NewDB(db), func() { + acc, err := accounts.NewDB(db) + require.NoError(t, err) + return acc, func() { require.NoError(t, db.Close()) } } diff --git a/services/local-notifications/core.go b/services/local-notifications/core.go index c4d722250..56fef59e1 100644 --- a/services/local-notifications/core.go +++ b/services/local-notifications/core.go @@ -95,10 +95,13 @@ type Service struct { accountsDB *accounts.Database } -func NewService(appDB *sql.DB, chainID uint64) *Service { +func NewService(appDB *sql.DB, chainID uint64) (*Service, error) { db := NewDB(appDB, chainID) walletDB := transfer.NewDB(appDB) - accountsDB := accounts.NewDB(appDB) + accountsDB, err := accounts.NewDB(appDB) + if err != nil { + return nil, err + } trans := &transmitter{} walletTrans := &transmitter{} @@ -109,7 +112,7 @@ func NewService(appDB *sql.DB, chainID uint64) *Service { accountsDB: accountsDB, transmitter: trans, walletTransmitter: walletTrans, - } + }, nil } func (n *Notification) MarshalJSON() ([]byte, error) { diff --git a/services/local-notifications/core_test.go b/services/local-notifications/core_test.go index 8a4e8cb38..2040d40a5 100644 --- a/services/local-notifications/core_test.go +++ b/services/local-notifications/core_test.go @@ -29,7 +29,8 @@ func TestServiceStartStop(t *testing.T) { db, stop := setupAppTestDb(t) defer stop() - s := NewService(db, 1777) + s, err := NewService(db, 1777) + require.NoError(t, err) require.NoError(t, s.Start()) require.Equal(t, true, s.IsStarted()) @@ -42,7 +43,8 @@ func TestWalletSubscription(t *testing.T) { defer stop() feed := &event.Feed{} - s := NewService(db, 1777) + s, err := NewService(db, 1777) + require.NoError(t, err) require.NoError(t, s.Start()) require.Equal(t, true, s.IsStarted()) @@ -66,7 +68,8 @@ func TestTransactionNotification(t *testing.T) { walletDb, stop := createWalletDb(t, db) defer stop() - s := NewService(db, 1777) + s, err := NewService(db, 1777) + require.NoError(t, err) require.NoError(t, s.Start()) require.Equal(t, true, s.IsStarted()) diff --git a/services/stickers/api.go b/services/stickers/api.go index 6be2b6662..07a1c77e4 100644 --- a/services/stickers/api.go +++ b/services/stickers/api.go @@ -2,7 +2,6 @@ package stickers import ( "context" - "database/sql" "errors" "io/ioutil" "math/big" @@ -54,7 +53,7 @@ type API struct { } type Sticker struct { - PackID *bigint.BigInt `json:"packID"` + PackID *bigint.BigInt `json:"packID,omitempty"` URL string `json:"url,omitempty"` Hash string `json:"hash,omitempty"` } @@ -63,15 +62,17 @@ type StickerPack struct { ID *bigint.BigInt `json:"id"` Name string `json:"name"` Author string `json:"author"` - Owner common.Address `json:"owner"` + Owner common.Address `json:"owner,omitempty"` Price *bigint.BigInt `json:"price"` Preview string `json:"preview"` Thumbnail string `json:"thumbnail"` Stickers []Sticker `json:"stickers"` - Status stickerStatus `json:"status"` + Status stickerStatus `json:"status,omitempty"` } +type StickerPackCollection map[uint]StickerPack + type ednSticker struct { Hash string } @@ -87,13 +88,13 @@ type ednStickerPackInfo struct { Meta ednStickerPack } -func NewAPI(ctx context.Context, appDB *sql.DB, rpcClient *rpc.Client, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, config *params.NodeConfig) *API { +func NewAPI(ctx context.Context, acc *accounts.Database, rpcClient *rpc.Client, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, config *params.NodeConfig) *API { return &API{ contractMaker: &contracts.ContractMaker{ RPCClient: rpcClient, }, accountsManager: accountsManager, - accountsDB: accounts.NewDB(appDB), + accountsDB: acc, rpcFiltersSrvc: rpcFiltersSrvc, config: config, ctx: ctx, @@ -105,7 +106,7 @@ func NewAPI(ctx context.Context, appDB *sql.DB, rpcClient *rpc.Client, accountsM func (api *API) Market(chainID uint64) ([]StickerPack, error) { // TODO: eventually this should be changed to include pagination - accounts, err := api.accountsDB.GetAccounts() + accs, err := api.accountsDB.GetAccounts() if err != nil { return nil, err } @@ -120,7 +121,7 @@ func (api *API) Market(chainID uint64) ([]StickerPack, error) { purchasedPackChan := make(chan *big.Int) errChan := make(chan error) doneChan := make(chan struct{}, 1) - go api.getAccountsPurchasedPack(chainID, accounts, purchasedPackChan, errChan, doneChan) + go api.getAccountsPurchasedPack(chainID, accs, purchasedPackChan, errChan, doneChan) for { select { diff --git a/services/stickers/install.go b/services/stickers/install.go index 02609fd67..be613ba65 100644 --- a/services/stickers/install.go +++ b/services/stickers/install.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/services/wallet/bigint" ) @@ -31,7 +32,7 @@ func (api *API) Install(chainID uint64, packID *bigint.BigInt) error { installedPacks[uint(packID.Uint64())] = *stickerPack - err = api.accountsDB.SaveSetting("stickers/packs-installed", installedPacks) + err = api.accountsDB.SaveSettingField(settings.StickersPacksInstalled, installedPacks) if err != nil { return err } @@ -39,8 +40,8 @@ func (api *API) Install(chainID uint64, packID *bigint.BigInt) error { return nil } -func (api *API) installedStickerPacks() (map[uint]StickerPack, error) { - stickerPacks := make(map[uint]StickerPack) +func (api *API) installedStickerPacks() (StickerPackCollection, error) { + stickerPacks := make(StickerPackCollection) installedStickersJSON, err := api.accountsDB.GetInstalledStickerPacks() if err != nil { @@ -59,7 +60,7 @@ func (api *API) installedStickerPacks() (map[uint]StickerPack, error) { return stickerPacks, nil } -func (api *API) Installed() (map[uint]StickerPack, error) { +func (api *API) Installed() (StickerPackCollection, error) { stickerPacks, err := api.installedStickerPacks() if err != nil { return nil, err @@ -104,7 +105,7 @@ func (api *API) Uninstall(packID *bigint.BigInt) error { delete(installedPacks, uint(packID.Uint64())) - err = api.accountsDB.SaveSetting("stickers/packs-installed", installedPacks) + err = api.accountsDB.SaveSettingField(settings.StickersPacksInstalled, installedPacks) if err != nil { return err } @@ -130,7 +131,7 @@ func (api *API) Uninstall(packID *bigint.BigInt) error { if idx != len(recentStickers)-1 { newRecentStickers = append(newRecentStickers, recentStickers[idx+1:]...) } - return api.accountsDB.SaveSetting("stickers/recent-stickers", newRecentStickers) + return api.accountsDB.SaveSettingField(settings.StickersRecentStickers, newRecentStickers) } return nil diff --git a/services/stickers/pending.go b/services/stickers/pending.go index 731381397..25f00fb76 100644 --- a/services/stickers/pending.go +++ b/services/stickers/pending.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/services/wallet/bigint" ) @@ -29,11 +30,11 @@ func (api *API) AddPending(chainID uint64, packID *bigint.BigInt) error { pendingPacks[uint(packID.Uint64())] = *stickerPack - return api.accountsDB.SaveSetting("stickers/packs-pending", pendingPacks) + return api.accountsDB.SaveSettingField(settings.StickersPacksPending, pendingPacks) } -func (api *API) pendingStickerPacks() (map[uint]StickerPack, error) { - stickerPacks := make(map[uint]StickerPack) +func (api *API) pendingStickerPacks() (StickerPackCollection, error) { + stickerPacks := make(StickerPackCollection) pendingStickersJSON, err := api.accountsDB.GetPendingStickerPacks() if err != nil { @@ -52,7 +53,7 @@ func (api *API) pendingStickerPacks() (map[uint]StickerPack, error) { return stickerPacks, nil } -func (api *API) Pending() (map[uint]StickerPack, error) { +func (api *API) Pending() (StickerPackCollection, error) { stickerPacks, err := api.pendingStickerPacks() if err != nil { return nil, err @@ -97,5 +98,5 @@ func (api *API) RemovePending(packID *bigint.BigInt) error { delete(pendingPacks, uint(packID.Uint64())) - return api.accountsDB.SaveSetting("stickers/packs-pending", pendingPacks) + return api.accountsDB.SaveSettingField(settings.StickersPacksPending, pendingPacks) } diff --git a/services/stickers/recent.go b/services/stickers/recent.go index 26b53d1b5..91fae2347 100644 --- a/services/stickers/recent.go +++ b/services/stickers/recent.go @@ -2,6 +2,8 @@ package stickers import ( "encoding/json" + + "github.com/status-im/status-go/multiaccounts/settings" ) const maxNumberRecentStickers = 24 @@ -27,8 +29,8 @@ func (api *API) recentStickers() ([]Sticker, error) { } func (api *API) ClearRecent() error { - recentStickersList := []Sticker{} - return api.accountsDB.SaveSetting("stickers/recent-stickers", recentStickersList) + var recentStickersList []Sticker + return api.accountsDB.SaveSettingField(settings.StickersRecentStickers, recentStickersList) } func (api *API) Recent() ([]Sticker, error) { @@ -73,5 +75,5 @@ func (api *API) AddRecent(sticker Sticker) error { recentStickersList = append([]Sticker{sticker}, recentStickersList...) } - return api.accountsDB.SaveSetting("stickers/recent-stickers", recentStickersList) + return api.accountsDB.SaveSettingField(settings.StickersRecentStickers, recentStickersList) } diff --git a/services/stickers/service.go b/services/stickers/service.go index b24a5ab88..53a32395a 100644 --- a/services/stickers/service.go +++ b/services/stickers/service.go @@ -2,22 +2,22 @@ package stickers import ( "context" - "database/sql" "github.com/ethereum/go-ethereum/p2p" ethRpc "github.com/ethereum/go-ethereum/rpc" "github.com/status-im/status-go/account" + "github.com/status-im/status-go/multiaccounts/accounts" "github.com/status-im/status-go/params" "github.com/status-im/status-go/rpc" "github.com/status-im/status-go/services/rpcfilters" ) // NewService initializes service instance. -func NewService(appDB *sql.DB, rpcClient *rpc.Client, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, config *params.NodeConfig) *Service { +func NewService(acc *accounts.Database, rpcClient *rpc.Client, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, config *params.NodeConfig) *Service { ctx, cancel := context.WithCancel(context.Background()) return &Service{ - appDB: appDB, + accountsDB: acc, rpcClient: rpcClient, accountsManager: accountsManager, rpcFiltersSrvc: rpcFiltersSrvc, @@ -30,7 +30,7 @@ func NewService(appDB *sql.DB, rpcClient *rpc.Client, accountsManager *account.G // Service is a browsers service. type Service struct { - appDB *sql.DB + accountsDB *accounts.Database rpcClient *rpc.Client accountsManager *account.GethManager rpcFiltersSrvc *rpcfilters.Service @@ -57,7 +57,7 @@ func (s *Service) APIs() []ethRpc.API { { Namespace: "stickers", Version: "0.1.0", - Service: NewAPI(s.ctx, s.appDB, s.rpcClient, s.accountsManager, s.rpcFiltersSrvc, s.config), + Service: NewAPI(s.ctx, s.accountsDB, s.rpcClient, s.accountsManager, s.rpcFiltersSrvc, s.config), }, } } diff --git a/services/wallet/transfer/block.go b/services/wallet/transfer/block.go index ff5d923aa..058594949 100644 --- a/services/wallet/transfer/block.go +++ b/services/wallet/transfer/block.go @@ -64,7 +64,10 @@ func (b *Block) mergeBlocksRanges(chainIDs []uint64, accounts []common.Address) } func (b *Block) setInitialBlocksRange(chainClient *chain.Client) error { - accountsDB := accounts.NewDB(b.db) + accountsDB, err := accounts.NewDB(b.db) + if err != nil { + return err + } watchAddress, err := accountsDB.GetWalletAddress() if err != nil { return err diff --git a/services/web3provider/api_test.go b/services/web3provider/api_test.go index 36818fc43..ae11fde3c 100644 --- a/services/web3provider/api_test.go +++ b/services/web3provider/api_test.go @@ -14,6 +14,7 @@ import ( "github.com/status-im/status-go/appdatabase" "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/multiaccounts/accounts" + "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/services/permissions" "github.com/status-im/status-go/t/utils" @@ -64,10 +65,13 @@ func setupTestAPI(t *testing.T) (*API, func()) { NetworkID: 1, } - service := NewService(db, rpcClient, nodeConfig, accManager, nil, nil) + accDB, err := accounts.NewDB(db) + require.NoError(t, err) + + service := NewService(db, accDB, rpcClient, nodeConfig, accManager, nil, nil) networks := json.RawMessage("{}") - settings := accounts.Settings{ + settings := settings.Settings{ DappsAddress: types.HexToAddress(utils.TestConfig.Account1.WalletAddress), Networks: &networks, } diff --git a/services/web3provider/service.go b/services/web3provider/service.go index fb53cbaac..990cb9532 100644 --- a/services/web3provider/service.go +++ b/services/web3provider/service.go @@ -17,10 +17,10 @@ import ( "github.com/status-im/status-go/services/rpcfilters" ) -func NewService(appDB *sql.DB, rpcClient *rpc.Client, config *params.NodeConfig, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, transactor *transactions.Transactor) *Service { +func NewService(appDB *sql.DB, accountsDB *accounts.Database, rpcClient *rpc.Client, config *params.NodeConfig, accountsManager *account.GethManager, rpcFiltersSrvc *rpcfilters.Service, transactor *transactions.Transactor) *Service { return &Service{ permissionsDB: permissions.NewDB(appDB), - accountsDB: accounts.NewDB(appDB), + accountsDB: accountsDB, rpcClient: rpcClient, rpcFiltersSrvc: rpcFiltersSrvc, config: config, diff --git a/sqlite/fields.go b/sqlite/fields.go index b0fe54faa..59413b903 100644 --- a/sqlite/fields.go +++ b/sqlite/fields.go @@ -32,8 +32,16 @@ func (blob *JSONBlob) Scan(value interface{}) error { // Value implements interface. func (blob *JSONBlob) Value() (driver.Value, error) { dataVal := reflect.ValueOf(blob.Data) - if blob.Data == nil || dataVal.Kind() == reflect.Ptr && dataVal.IsNil() { + if (blob.Data == nil) || (dataVal.Kind() == reflect.Ptr && dataVal.IsNil()) { return nil, nil } + + switch dataVal.Kind() { + case reflect.Slice, reflect.Array, reflect.Map: + if dataVal.Len() == 0 { + return nil, nil + } + } + return json.Marshal(blob.Data) } diff --git a/static/bindata.go b/static/bindata.go index ff4e513fe..3f0a76512 100644 --- a/static/bindata.go +++ b/static/bindata.go @@ -104,7 +104,7 @@ func emojisTxt() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "emojis.txt", size: 28134, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "emojis.txt", size: 28134, mode: os.FileMode(0644), modTime: time.Unix(1647533729, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x28, 0xc, 0x22, 0x34, 0xa1, 0xeb, 0x8, 0x8d, 0xef, 0x38, 0x1b, 0xd8, 0xc2, 0x1a, 0x6d, 0xa2, 0x62, 0xad, 0x43, 0xfc, 0x1c, 0x38, 0xda, 0x8c, 0x3f, 0x34, 0xa, 0x8c, 0x6f, 0x5d, 0xd8}} return a, nil } @@ -124,7 +124,7 @@ func ConfigReadmeMd() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/README.md", size: 3031, mode: os.FileMode(0644), modTime: time.Unix(1646392728, 0)} + info := bindataFileInfo{name: "../config/README.md", size: 3031, mode: os.FileMode(0644), modTime: time.Unix(1643299628, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x15, 0x44, 0x2b, 0x13, 0x14, 0x34, 0xa, 0x66, 0x62, 0x1b, 0xc6, 0x4a, 0x2c, 0x7d, 0x4d, 0x89, 0xfb, 0xc9, 0x69, 0xe4, 0x18, 0x5f, 0x3, 0x98, 0x6d, 0x3c, 0x9e, 0xa8, 0xcd, 0x53, 0x5d, 0x75}} return a, nil } @@ -144,7 +144,7 @@ func ConfigCliAnonMetricNodeClientJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/anon-metric-node-client.json", size: 857, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "../config/cli/anon-metric-node-client.json", size: 857, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x90, 0xdf, 0xcd, 0xc8, 0x92, 0x1d, 0x63, 0x5e, 0xe1, 0xf9, 0x7f, 0xed, 0xf2, 0x68, 0x6b, 0x20, 0xff, 0x1d, 0x3b, 0xc9, 0x7b, 0xb9, 0x6a, 0xba, 0xd3, 0xbd, 0xf7, 0x48, 0x7b, 0x5a, 0x52, 0x79}} return a, nil } @@ -164,7 +164,7 @@ func ConfigCliAnonMetricNodeServerJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/anon-metric-node-server.json", size: 696, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "../config/cli/anon-metric-node-server.json", size: 696, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf0, 0x2f, 0x97, 0xab, 0x77, 0x61, 0x93, 0x9d, 0x1f, 0x33, 0x18, 0x72, 0xad, 0xce, 0xa3, 0x35, 0xa9, 0x44, 0xbf, 0x29, 0xa8, 0xea, 0x21, 0xb7, 0x22, 0x7f, 0x7d, 0x3a, 0x6b, 0x55, 0x3c, 0x66}} return a, nil } @@ -184,7 +184,7 @@ func ConfigCliFleetEthProdJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-eth.prod.json", size: 4470, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-eth.prod.json", size: 4470, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x34, 0x7b, 0x71, 0xe3, 0x8a, 0xb0, 0x7f, 0xc3, 0xe, 0xd2, 0x67, 0x38, 0x50, 0xf4, 0x27, 0xaa, 0xec, 0x47, 0xa1, 0x1, 0xf7, 0x5d, 0xe9, 0x8f, 0x3c, 0x35, 0x9f, 0xdb, 0x9b, 0x30, 0x88, 0x26}} return a, nil } @@ -204,7 +204,7 @@ func ConfigCliFleetEthStagingJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-eth.staging.json", size: 2145, mode: os.FileMode(0644), modTime: time.Unix(1647526239, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-eth.staging.json", size: 2145, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa2, 0xe9, 0x85, 0x4b, 0x66, 0xa4, 0x1d, 0x4e, 0xaf, 0x21, 0xd7, 0xc2, 0x59, 0xf7, 0xd, 0xc2, 0x61, 0x4e, 0x4a, 0x9e, 0x38, 0x90, 0x6a, 0x2a, 0x16, 0xa6, 0x5c, 0x6d, 0x0, 0x5, 0x6, 0xb3}} return a, nil } @@ -224,7 +224,7 @@ func ConfigCliFleetEthTestJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-eth.test.json", size: 2174, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-eth.test.json", size: 2174, mode: os.FileMode(0644), modTime: time.Unix(1630498597, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x55, 0x19, 0xca, 0x8d, 0xaa, 0x69, 0x9b, 0xa2, 0xa1, 0xdd, 0xef, 0xf2, 0x63, 0x5e, 0xcd, 0xe2, 0x8f, 0xc7, 0x37, 0x7e, 0x41, 0xa1, 0xc1, 0x3f, 0x65, 0x80, 0xa, 0xa4, 0x27, 0x74, 0x8d, 0xc6}} return a, nil } @@ -244,7 +244,7 @@ func ConfigCliFleetStatusProdJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-status.prod.json", size: 1920, mode: os.FileMode(0644), modTime: time.Unix(1647854591, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-status.prod.json", size: 1920, mode: os.FileMode(0644), modTime: time.Unix(1647533729, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5, 0xf, 0x4a, 0x61, 0xd2, 0xfd, 0x7d, 0x59, 0xcf, 0x49, 0x81, 0x6, 0x71, 0xdb, 0x63, 0xe8, 0xeb, 0xdf, 0x9e, 0x65, 0x22, 0xae, 0x9b, 0xb0, 0x16, 0x17, 0xe0, 0x52, 0xe6, 0xb, 0xcf, 0x88}} return a, nil } @@ -264,7 +264,7 @@ func ConfigCliFleetStatusTestJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-status.test.json", size: 937, mode: os.FileMode(0644), modTime: time.Unix(1647602241, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-status.test.json", size: 937, mode: os.FileMode(0644), modTime: time.Unix(1646739279, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5c, 0x3b, 0xc5, 0xd2, 0xe9, 0xd3, 0x52, 0xd4, 0x5a, 0xf3, 0xed, 0x37, 0xed, 0xde, 0xda, 0xc1, 0x57, 0x37, 0x17, 0x8c, 0x40, 0xee, 0x12, 0x82, 0x14, 0x2c, 0x8b, 0xc7, 0x4b, 0x2, 0xf8, 0x82}} return a, nil } @@ -284,7 +284,7 @@ func ConfigCliFleetWakuv2ProdJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-wakuv2.prod.json", size: 747, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-wakuv2.prod.json", size: 747, mode: os.FileMode(0644), modTime: time.Unix(1629202661, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc3, 0x81, 0x84, 0xfd, 0x7d, 0x7e, 0x27, 0xc8, 0x5e, 0xb6, 0x38, 0xe1, 0x6, 0xa, 0xbc, 0x86, 0x87, 0x54, 0xa2, 0x2f, 0xe1, 0xa1, 0xc8, 0x6, 0x80, 0xfa, 0xed, 0xfe, 0x13, 0x6c, 0x81, 0xd9}} return a, nil } @@ -304,7 +304,7 @@ func ConfigCliFleetWakuv2TestJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/fleet-wakuv2.test.json", size: 748, mode: os.FileMode(0644), modTime: time.Unix(1637600491, 0)} + info := bindataFileInfo{name: "../config/cli/fleet-wakuv2.test.json", size: 748, mode: os.FileMode(0644), modTime: time.Unix(1629202661, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x77, 0x6d, 0x28, 0xb7, 0xc2, 0xf3, 0x22, 0xe3, 0x6d, 0xc1, 0xeb, 0x4b, 0x42, 0xe2, 0x6, 0xb0, 0x60, 0x30, 0xdb, 0xe3, 0x26, 0xff, 0x9, 0xf5, 0xea, 0xe6, 0x56, 0xce, 0xa8, 0x98, 0x61, 0x70}} return a, nil } @@ -324,7 +324,7 @@ func ConfigCliLesEnabledJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/les-enabled.json", size: 58, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "../config/cli/les-enabled.json", size: 58, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7e, 0xee, 0x27, 0xa7, 0x74, 0xa0, 0x46, 0xa1, 0x41, 0xed, 0x4d, 0x16, 0x5b, 0xf3, 0xf0, 0x7c, 0xc8, 0x2f, 0x6f, 0x47, 0xa4, 0xbb, 0x5f, 0x43, 0x33, 0xd, 0x9, 0x9d, 0xea, 0x9e, 0x15, 0xee}} return a, nil } @@ -344,7 +344,7 @@ func ConfigCliMailserverEnabledJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/cli/mailserver-enabled.json", size: 176, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "../config/cli/mailserver-enabled.json", size: 176, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x34, 0xec, 0x81, 0x8b, 0x99, 0xb6, 0xdb, 0xc0, 0x8b, 0x46, 0x97, 0x96, 0xc7, 0x58, 0x30, 0x33, 0xef, 0x54, 0x25, 0x87, 0x7b, 0xb9, 0x94, 0x6b, 0x18, 0xa4, 0x5b, 0x58, 0x67, 0x7c, 0x44, 0xa6}} return a, nil } @@ -364,7 +364,7 @@ func ConfigStatusChainGenesisJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "../config/status-chain-genesis.json", size: 612, mode: os.FileMode(0644), modTime: time.Unix(1599559876, 0)} + info := bindataFileInfo{name: "../config/status-chain-genesis.json", size: 612, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb, 0xf0, 0xc, 0x1, 0x95, 0x65, 0x6, 0x55, 0x48, 0x8f, 0x83, 0xa0, 0xb4, 0x81, 0xda, 0xad, 0x30, 0x6d, 0xb2, 0x78, 0x1b, 0x26, 0x4, 0x13, 0x12, 0x9, 0x6, 0xae, 0x3a, 0x2c, 0x1, 0x71}} return a, nil } @@ -384,7 +384,7 @@ func keysBootnodeKey() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/bootnode.key", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "keys/bootnode.key", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x31, 0xcf, 0x27, 0xd4, 0x96, 0x2e, 0x32, 0xcd, 0x58, 0x96, 0x2a, 0xe5, 0x8c, 0xa0, 0xf1, 0x73, 0x1f, 0xd6, 0xd6, 0x8b, 0xb, 0x73, 0xd3, 0x2c, 0x84, 0x1a, 0x56, 0xa4, 0x74, 0xb6, 0x95, 0x20}} return a, nil } @@ -404,7 +404,7 @@ func keysFirebaseauthkey() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/firebaseauthkey", size: 153, mode: os.FileMode(0644), modTime: time.Unix(1536843582, 0)} + info := bindataFileInfo{name: "keys/firebaseauthkey", size: 153, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe, 0x69, 0x23, 0x64, 0x7d, 0xf9, 0x14, 0x37, 0x6f, 0x2b, 0x1, 0xf0, 0xb0, 0xa4, 0xb2, 0xd0, 0x18, 0xcd, 0xf9, 0xeb, 0x57, 0xa3, 0xfd, 0x79, 0x25, 0xa7, 0x9c, 0x3, 0xce, 0x26, 0xec, 0xe1}} return a, nil } @@ -424,7 +424,7 @@ func keysTestAccount1StatusChainPk() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/test-account1-status-chain.pk", size: 489, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "keys/test-account1-status-chain.pk", size: 489, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8f, 0xba, 0x35, 0x1, 0x2b, 0x9d, 0xad, 0xf0, 0x2d, 0x3c, 0x4d, 0x6, 0xb5, 0x22, 0x2, 0x47, 0xd4, 0x1c, 0xf4, 0x31, 0x2f, 0xb, 0x5b, 0x27, 0x5d, 0x43, 0x97, 0x58, 0x2d, 0xf0, 0xe1, 0xbe}} return a, nil } @@ -444,7 +444,7 @@ func keysTestAccount1Pk() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/test-account1.pk", size: 491, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "keys/test-account1.pk", size: 491, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9, 0x43, 0xc2, 0xf4, 0x8c, 0xc6, 0x64, 0x25, 0x8c, 0x7, 0x8c, 0xa8, 0x89, 0x2b, 0x7b, 0x9b, 0x4f, 0x81, 0xcb, 0xce, 0x3d, 0xef, 0x82, 0x9c, 0x27, 0x27, 0xa9, 0xc5, 0x46, 0x70, 0x30, 0x38}} return a, nil } @@ -464,7 +464,7 @@ func keysTestAccount2StatusChainPk() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/test-account2-status-chain.pk", size: 489, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "keys/test-account2-status-chain.pk", size: 489, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9, 0xf8, 0x5c, 0xe9, 0x92, 0x96, 0x2d, 0x88, 0x2b, 0x8e, 0x42, 0x3f, 0xa4, 0x93, 0x6c, 0xad, 0xe9, 0xc0, 0x1b, 0x8a, 0x8, 0x8c, 0x5e, 0x7a, 0x84, 0xa2, 0xf, 0x9f, 0x77, 0x58, 0x2c, 0x2c}} return a, nil } @@ -484,7 +484,7 @@ func keysTestAccount2Pk() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/test-account2.pk", size: 491, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "keys/test-account2.pk", size: 491, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9f, 0x72, 0xd5, 0x95, 0x5c, 0x5a, 0x99, 0x9d, 0x2f, 0x21, 0x83, 0xd7, 0x10, 0x17, 0x4a, 0x3d, 0x65, 0xc9, 0x26, 0x1a, 0x2c, 0x9d, 0x65, 0x63, 0xd2, 0xa0, 0xfc, 0x7c, 0x0, 0x87, 0x38, 0x9f}} return a, nil } @@ -504,7 +504,7 @@ func keysTestAccount3BeforeEip55Pk() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "keys/test-account3-before-eip55.pk", size: 489, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "keys/test-account3-before-eip55.pk", size: 489, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x81, 0x40, 0x56, 0xc1, 0x5e, 0x10, 0x6e, 0x28, 0x15, 0x3, 0x4e, 0xc4, 0xc4, 0x71, 0x4d, 0x16, 0x99, 0xcc, 0x1b, 0x63, 0xee, 0x10, 0x20, 0xe4, 0x59, 0x52, 0x3f, 0xc0, 0xad, 0x15, 0x13, 0x72}} return a, nil } diff --git a/t/bindata.go b/t/bindata.go index 14abbfc1e..cf96ec39e 100644 --- a/t/bindata.go +++ b/t/bindata.go @@ -86,7 +86,7 @@ func configPublicChainAccountsJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "config/public-chain-accounts.json", size: 307, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "config/public-chain-accounts.json", size: 307, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x76, 0x5d, 0xc0, 0xfe, 0x57, 0x50, 0x18, 0xec, 0x2d, 0x61, 0x1b, 0xa9, 0x81, 0x11, 0x5f, 0x77, 0xf7, 0xb6, 0x67, 0x82, 0x1, 0x40, 0x68, 0x9d, 0xc5, 0x41, 0xaf, 0xce, 0x43, 0x81, 0x92, 0x96}} return a, nil } @@ -106,7 +106,7 @@ func configStatusChainAccountsJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "config/status-chain-accounts.json", size: 543, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "config/status-chain-accounts.json", size: 543, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x8e, 0xb3, 0x61, 0x51, 0x70, 0x3c, 0x12, 0x3e, 0xf1, 0x1c, 0x81, 0xfb, 0x9a, 0x7c, 0xe3, 0x63, 0xd0, 0x8f, 0x12, 0xc5, 0x2d, 0xf4, 0xea, 0x27, 0x33, 0xef, 0xca, 0xf9, 0x3f, 0x72, 0x44, 0xbf}} return a, nil } @@ -126,7 +126,7 @@ func configTestDataJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "config/test-data.json", size: 84, mode: os.FileMode(0644), modTime: time.Unix(1599559877, 0)} + info := bindataFileInfo{name: "config/test-data.json", size: 84, mode: os.FileMode(0644), modTime: time.Unix(1585751575, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xce, 0x9d, 0x80, 0xf5, 0x87, 0xfa, 0x57, 0x1d, 0xa1, 0xd5, 0x7a, 0x10, 0x3, 0xac, 0xd7, 0xf4, 0x64, 0x32, 0x96, 0x2b, 0xb7, 0x21, 0xb7, 0xa6, 0x80, 0x40, 0xe9, 0x65, 0xe3, 0xd6, 0xbd, 0x40}} return a, nil }