Added new Settings field ProfilePicturesShowTo

This commit is contained in:
Samuel Hawksby-Robinson 2021-02-12 15:35:34 +00:00 committed by Andrea Maria Piana
parent b009bac5fb
commit 97754cb907
5 changed files with 67 additions and 5 deletions

View File

@ -35,6 +35,7 @@
// 0019_blocks_ranges_extra_data.up.sql (89B)
// 0020_metrics.up.sql (235B)
// 0021_add_session_id_to_metrics.up.sql (55B)
// 0021_profile_pictures_show_to.sql (81B)
// 0022_pending_transfers.up.sql (706B)
// 1618237885_settings_anon_metrics_should_send.up.sql (80B)
// 1618395756_contacts_only.up.sql (136B)
@ -817,6 +818,26 @@ func _0021_add_session_id_to_metricsUpSql() (*asset, error) {
return a, nil
}
var __0021_profile_pictures_show_toSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x28\x4e\x2d\x29\xc9\xcc\x4b\x2f\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x28\x28\xca\x4f\xcb\xcc\x49\x8d\x2f\xc8\x4c\x2e\x29\x2d\x4a\x2d\x8e\x2f\xce\xc8\x2f\x8f\x2f\xc9\x57\xf0\xf4\x0b\x51\xf0\xf3\x0f\x51\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x51\x30\xb4\xe6\x02\x04\x00\x00\xff\xff\x2f\x7a\xa3\xb9\x51\x00\x00\x00")
func _0021_profile_pictures_show_toSqlBytes() ([]byte, error) {
return bindataRead(
__0021_profile_pictures_show_toSql,
"0021_profile_pictures_show_to.sql",
)
}
func _0021_profile_pictures_show_toSql() (*asset, error) {
bytes, err := _0021_profile_pictures_show_toSqlBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "0021_profile_pictures_show_to.sql", size: 81, mode: os.FileMode(0644), modTime: time.Unix(1628512469, 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
}
var __0022_pending_transfersUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x92\x4f\x6f\xe2\x30\x10\xc5\xef\xfe\x14\x73\x04\xc9\x87\xbd\x73\x72\xc0\x80\xb5\xc1\x46\xce\xb0\xc0\xc9\xf2\xe2\x14\xac\xe6\x9f\x62\xb7\x15\xdf\xbe\x22\xb4\x25\x50\x8a\x7a\x7d\xcf\xf3\x7b\xa3\xe7\x61\x29\x72\x0d\xc8\x92\x94\x43\x93\x57\xce\x57\x7b\x13\x5b\x5b\x05\xbb\x8b\xbe\xae\x02\x68\x2e\xd9\x82\x03\xaa\xbb\xb6\xa9\x0b\x37\x22\x64\xac\x39\x43\xfe\x81\x11\x53\x90\x0a\x81\x6f\x44\x86\xd9\x7d\xe8\x80\x00\x54\x79\x7c\xab\xdb\x67\xe3\x1d\xac\x64\x26\x66\x92\x4f\x20\x11\x33\x21\xb1\x1b\x97\xab\x34\xa5\x04\xe0\x60\xc3\x01\xfe\x31\x3d\x9e\x33\x7d\x65\x44\x5f\xe6\x21\xda\xb2\x79\x38\xfe\xd4\xd6\xa5\xb1\xce\xb5\x79\x08\xf7\x31\xf5\xad\x7d\x52\xc3\xb1\xfc\x5f\x17\x7d\x65\x6f\x83\x69\x5a\xbf\xcb\x21\x49\x55\xf2\xa9\x14\xbe\xf4\xf1\x4b\x79\xb5\xc5\xcb\xc5\x77\x36\x5a\x40\xbe\xc1\x2e\xe6\xd8\xe4\x7d\x9c\x75\xce\x9f\xba\xb0\x85\xb9\x7a\xb7\xd4\x62\xc1\xf4\x16\xfe\xf2\x2d\x0c\x2e\x15\xd1\xae\x87\x21\x19\xc2\x5a\xe0\x5c\xad\x10\xb4\x5a\x8b\xc9\x88\x10\x21\x33\xae\x11\x84\xfc\xe1\x87\xbe\x41\xe8\x55\x27\xb4\x57\x00\xed\xb6\xa4\xb7\xbb\xd1\x4b\xd5\x43\x92\xf1\x94\x8f\x11\xfa\xd0\x5e\x9a\xf9\x5d\xc0\x99\xfa\x07\xa6\x5a\x2d\x1e\x9d\xd5\x44\xab\xe5\x83\xdb\x3c\xbf\x7a\x0f\x00\x00\xff\xff\x05\xa2\xfe\xa8\xc2\x02\x00\x00")
func _0022_pending_transfersUpSqlBytes() ([]byte, error) {
@ -1258,6 +1279,8 @@ var _bindata = map[string]func() (*asset, error){
"0021_add_session_id_to_metrics.up.sql": _0021_add_session_id_to_metricsUpSql,
"0021_profile_pictures_show_to.sql": _0021_profile_pictures_show_toSql,
"0022_pending_transfers.up.sql": _0022_pending_transfersUpSql,
"1618237885_settings_anon_metrics_should_send.up.sql": _1618237885_settings_anon_metrics_should_sendUpSql,
@ -1363,6 +1386,7 @@ var _bintree = &bintree{nil, map[string]*bintree{
"0019_blocks_ranges_extra_data.up.sql": &bintree{_0019_blocks_ranges_extra_dataUpSql, map[string]*bintree{}},
"0020_metrics.up.sql": &bintree{_0020_metricsUpSql, map[string]*bintree{}},
"0021_add_session_id_to_metrics.up.sql": &bintree{_0021_add_session_id_to_metricsUpSql, map[string]*bintree{}},
"0021_profile_pictures_show_to.sql": &bintree{_0021_profile_pictures_show_toSql, map[string]*bintree{}},
"0022_pending_transfers.up.sql": &bintree{_0022_pending_transfersUpSql, map[string]*bintree{}},
"1618237885_settings_anon_metrics_should_send.up.sql": &bintree{_1618237885_settings_anon_metrics_should_sendUpSql, map[string]*bintree{}},
"1618395756_contacts_only.up.sql": &bintree{_1618395756_contacts_onlyUpSql, map[string]*bintree{}},

View File

@ -0,0 +1 @@
ALTER TABLE settings ADD COLUMN profile_pictures_show_to INT NOT NULL DEFAULT 1;

View File

@ -21,6 +21,12 @@ const (
ProfilePicturesVisibilityNone
)
const (
ProfilePicturesShowToContactsOnly = 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")
@ -110,6 +116,8 @@ type Settings struct {
// 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 uint `json:"profile-pictures-show-to"`
// ProfilePicturesVisibility indicates who we want to see profile pictures of (contacts, everyone or none)
ProfilePicturesVisibility uint `json:"profile-pictures-visibility"`
UseMailservers bool `json:"use-mailservers?"`
@ -372,6 +380,8 @@ func (db *Database) SaveSetting(setting string, value interface{}) error {
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":
@ -429,7 +439,7 @@ func (db *Database) GetNodeConfig(nodecfg interface{}) error {
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, 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_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 FROM settings WHERE synthetic_id = 'id'").Scan(
err := db.db.QueryRow("SELECT address, anon_metrics_should_send, chaos_mode, currency, current_network, custom_bootnodes, custom_bootnodes_enabled, dapps_address, 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 FROM settings WHERE synthetic_id = 'id'").Scan(
&s.Address,
&s.AnonMetricsShouldSend,
&s.ChaosMode,
@ -476,6 +486,7 @@ func (db *Database) GetSettings() (Settings, error) {
&s.MessagesFromContactsOnly,
&s.Usernames,
&s.Appearance,
&s.ProfilePicturesShowTo,
&s.ProfilePicturesVisibility,
&s.WalletRootAddress,
&s.WalletSetUpPassed,

View File

@ -777,9 +777,8 @@ func (m *Messenger) attachIdentityImagesToChatIdentity(context chatContext, ci *
return err
}
// TODO remove the use of ProfilePicturesVisibility and create a new settings field,
if s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityNone {
m.logger.Info(fmt.Sprintf("settings.ProfilePicturesVisibility is set to '%d', skipping attaching IdentityImages", s.ProfilePicturesVisibility))
if s.ProfilePicturesShowTo == accounts.ProfilePicturesShowToNone {
m.logger.Info(fmt.Sprintf("settings.ProfilePicturesShowTo is set to '%d', skipping attaching IdentityImages", s.ProfilePicturesShowTo))
return nil
}
@ -820,7 +819,7 @@ func (m *Messenger) attachIdentityImagesToChatIdentity(context chatContext, ci *
return fmt.Errorf("unknown ChatIdentity context '%s'", context)
}
if s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityContactsOnly {
if s.ProfilePicturesShowTo == accounts.ProfilePicturesShowToContactsOnly {
err := m.encryptIdentityImagesWithContactPubKeys(ci.Images)
if err != nil {
return err

View File

@ -86,8 +86,17 @@ func _1565345162_initial_schemaDownSql() (*asset, error) {
return nil, err
}
<<<<<<< HEAD:vendor/github.com/vacp2p/mvds/node/migrations/migrations.go
info := bindataFileInfo{name: "1565345162_initial_schema.down.sql", size: 23, mode: os.FileMode(0644), modTime: time.Unix(1565345447, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x7c, 0x69, 0xd2, 0x3, 0xea, 0x82, 0x7c, 0xb3, 0x44, 0x6c, 0xef, 0x64, 0x2c, 0x99, 0x62, 0xa2, 0x8b, 0x6f, 0x96, 0x4f, 0x34, 0x41, 0x87, 0xd5, 0x4e, 0x3, 0x7f, 0x4a, 0xd1, 0x91, 0x9, 0x99}}
=======
<<<<<<< HEAD
info := bindataFileInfo{name: "1561059285_add_whisper_keys.down.sql", size: 25, mode: os.FileMode(0644), modTime: time.Unix(1607354881, 0)}
=======
info := bindataFileInfo{name: "1561059285_add_whisper_keys.down.sql", size: 25, mode: os.FileMode(0644), modTime: time.Unix(1618493571, 0)}
>>>>>>> Added new Settings field ProfilePicturesShowTo
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb9, 0x31, 0x3f, 0xce, 0xfa, 0x44, 0x36, 0x1b, 0xb0, 0xec, 0x5d, 0xb, 0x90, 0xb, 0x21, 0x4f, 0xd5, 0xe5, 0x50, 0xed, 0xc7, 0x43, 0xdf, 0x83, 0xb4, 0x3a, 0xc1, 0x55, 0x2e, 0x53, 0x7c, 0x67}}
>>>>>>> Added new Settings field ProfilePicturesShowTo:protocol/transport/whisper/migrations/migrations.go
return a, nil
}
@ -106,8 +115,17 @@ func _1565345162_initial_schemaUpSql() (*asset, error) {
return nil, err
}
<<<<<<< HEAD:vendor/github.com/vacp2p/mvds/node/migrations/migrations.go
info := bindataFileInfo{name: "1565345162_initial_schema.up.sql", size: 86, mode: os.FileMode(0644), modTime: time.Unix(1565345708, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x78, 0x7c, 0xdd, 0x67, 0x61, 0x3e, 0x7f, 0xd4, 0xce, 0xb0, 0x17, 0xbe, 0x5a, 0xa7, 0x9e, 0x93, 0x34, 0xe8, 0xbb, 0x44, 0xfb, 0x88, 0xd6, 0x18, 0x6d, 0x9f, 0xb4, 0x22, 0xda, 0xbc, 0x87, 0x94}}
=======
<<<<<<< HEAD
info := bindataFileInfo{name: "1561059285_add_whisper_keys.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1607354881, 0)}
=======
info := bindataFileInfo{name: "1561059285_add_whisper_keys.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1618493571, 0)}
>>>>>>> Added new Settings field ProfilePicturesShowTo
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x25, 0x41, 0xc, 0x92, 0xdd, 0x9e, 0xff, 0x5d, 0xd0, 0x93, 0xe4, 0x24, 0x50, 0x29, 0xcf, 0xc6, 0xf7, 0x49, 0x3c, 0x73, 0xd9, 0x8c, 0xfa, 0xf2, 0xcf, 0xf6, 0x6f, 0xbc, 0x31, 0xe6, 0xf7, 0xe2}}
>>>>>>> Added new Settings field ProfilePicturesShowTo:protocol/transport/whisper/migrations/migrations.go
return a, nil
}
@ -126,8 +144,17 @@ func docGo() (*asset, error) {
return nil, err
}
<<<<<<< HEAD:vendor/github.com/vacp2p/mvds/node/migrations/migrations.go
info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1565345207, 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}}
=======
<<<<<<< HEAD
info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1607354881, 0)}
=======
info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1618493571, 0)}
>>>>>>> Added new Settings field ProfilePicturesShowTo
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}}
>>>>>>> Added new Settings field ProfilePicturesShowTo:protocol/transport/whisper/migrations/migrations.go
return a, nil
}