Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private Profile Photos #2151

Merged
merged 13 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.88.6
0.89.2
124 changes: 74 additions & 50 deletions appdatabase/migrations/bindata.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE settings ADD COLUMN profile_pictures_show_to INT NOT NULL DEFAULT 1;
6 changes: 3 additions & 3 deletions mailserver/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions multiaccounts/accounts/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ const (
uniqueWalletConstraint = "UNIQUE constraint failed: accounts.wallet"
)

type ProfilePicturesVisibilityType int

const (
ProfilePicturesVisibilityContactsOnly = iota + 1
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")
Expand Down Expand Up @@ -110,20 +120,22 @@ 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 ProfilePicturesShowToType `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?"`
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"`
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"`
}

func NewDB(db *sql.DB) *Database {
Expand Down Expand Up @@ -372,6 +384,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":
Expand Down Expand Up @@ -429,7 +443,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,
Expand Down Expand Up @@ -476,6 +490,7 @@ func (db *Database) GetSettings() (Settings, error) {
&s.MessagesFromContactsOnly,
&s.Usernames,
&s.Appearance,
&s.ProfilePicturesShowTo,
&s.ProfilePicturesVisibility,
&s.WalletRootAddress,
&s.WalletSetUpPassed,
Expand Down
1 change: 1 addition & 0 deletions multiaccounts/accounts/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
PublicKey: "0x04211fe0f69772ecf7eb0b5bfc7678672508a9fb01f2d699096f0d59ef7fe1a0cb1e648a80190db1c0f5f088872444d846f2956d0bd84069f3f9f69335af852ac0",
SigningPhrase: "yurt joey vibe",
SendPushNotifications: true,
ProfilePicturesShowTo: ProfilePicturesShowToContactsOnly,
ProfilePicturesVisibility: ProfilePicturesVisibilityContactsOnly,
DefaultSyncPeriod: 86400,
UseMailservers: true,
Expand Down
14 changes: 7 additions & 7 deletions multiaccounts/migrations/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions protocol/anonmetrics/migrations/migrations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion protocol/common/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import (

"golang.org/x/crypto/sha3"

"github.com/ethereum/go-ethereum/crypto/ecies"

"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
)

const nonceLength = 12
const (
nonceLength = 12
defaultECHDSharedKeyLength = 16
defaultECHDMACLength = 16
)

var ErrInvalidCiphertextLength = errors.New("invalid cyphertext length")

Expand Down Expand Up @@ -86,3 +92,11 @@ func HexToPubkey(pk string) (*ecdsa.PublicKey, error) {
}
return crypto.UnmarshalPubkey(bytes)
}

func MakeECDHSharedKey(yourPrivateKey *ecdsa.PrivateKey, theirPubKey *ecdsa.PublicKey) ([]byte, error) {
return ecies.ImportECDSA(yourPrivateKey).GenerateShared(
ecies.ImportECDSAPublic(theirPubKey),
defaultECHDSharedKeyLength,
defaultECHDMACLength,
)
}
Loading