settings

package
v0.104.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2022 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AnonMetricsShouldSend = SettingField{
							// contains filtered or unexported fields
	}
	Appearance = SettingField{
				// contains filtered or unexported fields
	}
	AutoMessageEnabled = SettingField{
						// contains filtered or unexported fields
	}
	BackupEnabled = SettingField{
					// contains filtered or unexported fields
	}
	BackupFetched = SettingField{
					// contains filtered or unexported fields
	}
	ChaosMode = SettingField{
				// contains filtered or unexported fields
	}
	Currency = SettingField{
				// contains filtered or unexported fields
	}
	CurrentUserStatus = SettingField{
						// contains filtered or unexported fields
	}
	CustomBootNodes = SettingField{
					// contains filtered or unexported fields
	}
	CustomBootNodesEnabled = SettingField{
							// contains filtered or unexported fields
	}
	DappsAddress = SettingField{
					// contains filtered or unexported fields
	}
	DefaultSyncPeriod = SettingField{
						// contains filtered or unexported fields
	}
	DisplayName = SettingField{
				// contains filtered or unexported fields
	}
	EIP1581Address = SettingField{
					// contains filtered or unexported fields
	}
	Fleet = SettingField{
			// contains filtered or unexported fields
	}
	GifAPIKey = SettingField{
				// contains filtered or unexported fields
	}
	GifFavourites = SettingField{
					// contains filtered or unexported fields
	}
	GifRecents = SettingField{
				// contains filtered or unexported fields
	}
	HideHomeTooltip = SettingField{
					// contains filtered or unexported fields
	}
	KeycardInstanceUID = SettingField{
						// contains filtered or unexported fields
	}
	KeycardPairedOn = SettingField{
					// contains filtered or unexported fields
	}
	KeycardPairing = SettingField{
					// contains filtered or unexported fields
	}
	LastBackup = SettingField{
				// contains filtered or unexported fields
	}
	LastUpdated = SettingField{
				// contains filtered or unexported fields
	}
	LatestDerivedPath = SettingField{
						// contains filtered or unexported fields
	}
	LinkPreviewRequestEnabled = SettingField{
								// contains filtered or unexported fields
	}
	LinkPreviewsEnabledSites = SettingField{
								// contains filtered or unexported fields
	}
	LogLevel = SettingField{
				// contains filtered or unexported fields
	}
	MessagesFromContactsOnly = SettingField{
								// contains filtered or unexported fields
	}
	Mnemonic = SettingField{
				// contains filtered or unexported fields
	}
	MutualContactEnabled = SettingField{
							// contains filtered or unexported fields
	}
	Name = SettingField{
			// contains filtered or unexported fields
	}
	NetworksCurrentNetwork = SettingField{
							// contains filtered or unexported fields
	}
	NetworksNetworks = SettingField{
						// contains filtered or unexported fields
	}
	NodeConfig = SettingField{
				// contains filtered or unexported fields
	}
	// NotificationsEnabled - we should remove this and realated things once mobile team starts usign `settings_notifications` package
	NotificationsEnabled = SettingField{
							// contains filtered or unexported fields
	}
	OpenseaEnabled = SettingField{
					// contains filtered or unexported fields
	}
	PhotoPath = SettingField{
				// contains filtered or unexported fields
	}
	PinnedMailservers = SettingField{
						// contains filtered or unexported fields
	}
	PreferredName = SettingField{
					// contains filtered or unexported fields
	}
	PreviewPrivacy = SettingField{
					// contains filtered or unexported fields
	}
	ProfilePicturesShowTo = SettingField{
							// contains filtered or unexported fields
	}
	ProfilePicturesVisibility = SettingField{
								// contains filtered or unexported fields
	}
	PublicKey = SettingField{
				// contains filtered or unexported fields
	}
	PushNotificationsBlockMentions = SettingField{
									// contains filtered or unexported fields
	}
	PushNotificationsFromContactsOnly = SettingField{
										// contains filtered or unexported fields
	}
	PushNotificationsServerEnabled = SettingField{
									// contains filtered or unexported fields
	}
	RememberSyncingChoice = SettingField{
							// contains filtered or unexported fields
	}
	RemotePushNotificationsEnabled = SettingField{
									// contains filtered or unexported fields
	}
	SendPushNotifications = SettingField{
							// contains filtered or unexported fields
	}
	SendStatusUpdates = SettingField{
						// contains filtered or unexported fields
	}
	StickersPacksInstalled = SettingField{
							// contains filtered or unexported fields
	}
	StickersPacksPending = SettingField{
							// contains filtered or unexported fields
	}
	StickersRecentStickers = SettingField{
							// contains filtered or unexported fields
	}
	SyncingOnMobileNetwork = SettingField{
							// contains filtered or unexported fields
	}
	TelemetryServerURL = SettingField{
						// contains filtered or unexported fields
	}
	TestNetworksEnabled = SettingField{
						// contains filtered or unexported fields
	}
	UseMailservers = SettingField{
					// contains filtered or unexported fields
	}
	Usernames = SettingField{
				// contains filtered or unexported fields
	}
	WakuBloomFilterMode = SettingField{
						// contains filtered or unexported fields
	}
	WalletSetUpPassed = SettingField{
						// contains filtered or unexported fields
	}
	WalletVisibleTokens = SettingField{
						// contains filtered or unexported fields
	}
	WebviewAllowPermissionRequests = SettingField{
									// contains filtered or unexported fields
	}
	WalletRootAddress = SettingField{
						// contains filtered or unexported fields
	}

	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,
		MutualContactEnabled,
		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,
		TestNetworksEnabled,
		UseMailservers,
		Usernames,
		WakuBloomFilterMode,
		WalletRootAddress,
		WalletSetUpPassed,
		WalletVisibleTokens,
		WebviewAllowPermissionRequests,
	}
)
View Source
var (
	ErrTypeAssertionFailed = errors.New("type assertion of interface value failed")
)

Functions

func AddressHandler

func AddressHandler(value interface{}) (interface{}, error)

func BoolFromSyncProtobuf

func BoolFromSyncProtobuf(ss *protobuf.SyncSetting) interface{}

func BoolHandler

func BoolHandler(value interface{}) (interface{}, error)

func BytesFromSyncProtobuf

func BytesFromSyncProtobuf(ss *protobuf.SyncSetting) interface{}

func Int64FromSyncProtobuf

func Int64FromSyncProtobuf(ss *protobuf.SyncSetting) interface{}

func JSONBlobHandler

func JSONBlobHandler(value interface{}) (interface{}, error)

func NodeConfigHandler

func NodeConfigHandler(value interface{}) (interface{}, error)

func StringFromSyncProtobuf

func StringFromSyncProtobuf(ss *protobuf.SyncSetting) interface{}

Types

type Database

type Database struct {
	SyncQueue chan SyncSettingField
	// contains filtered or unexported fields
}

Database sql wrapper for operations with browser objects.

func MakeNewDB

func MakeNewDB(db *sql.DB) (*Database, error)

MakeNewDB ensures that a singleton instance of Database is returned per sqlite db file

func (*Database) AutoMessageEnabled

func (db *Database) AutoMessageEnabled() (result bool, err error)

func (*Database) BackupEnabled

func (db *Database) BackupEnabled() (result bool, err error)

func (*Database) BackupFetched

func (db *Database) BackupFetched() (result bool, err error)

func (*Database) CanSyncOnMobileNetwork

func (db *Database) CanSyncOnMobileNetwork() (result bool, err error)

func (*Database) CanUseMailservers

func (db *Database) CanUseMailservers() (result bool, err error)

func (*Database) CreateSettings

func (db *Database) CreateSettings(s Settings, n params.NodeConfig) error

TODO remove photoPath from settings

func (*Database) DisplayName

func (db *Database) DisplayName() (string, error)

func (*Database) ENSName

func (db *Database) ENSName() (string, error)

func (*Database) GetCurrency added in v0.100.0

func (db *Database) GetCurrency() (string, error)

func (*Database) GetCurrentStatus

func (db *Database) GetCurrentStatus(status interface{}) error

func (*Database) GetDappsAddress

func (db *Database) GetDappsAddress() (rst types.Address, err error)

func (*Database) GetDefaultSyncPeriod

func (db *Database) GetDefaultSyncPeriod() (result uint32, err error)

func (*Database) GetFleet

func (db *Database) GetFleet() (string, error)

func (*Database) GetInstalledStickerPacks

func (db *Database) GetInstalledStickerPacks() (rst *json.RawMessage, err error)

func (*Database) GetLatestDerivedPath

func (db *Database) GetLatestDerivedPath() (result uint, err error)

func (*Database) GetMessagesFromContactsOnly

func (db *Database) GetMessagesFromContactsOnly() (result bool, err error)

func (*Database) GetNotificationsEnabled

func (db *Database) GetNotificationsEnabled() (result bool, err error)

We should remove this and realated things once mobile team starts usign `settings_notifications` package

func (*Database) GetPendingStickerPacks

func (db *Database) GetPendingStickerPacks() (rst *json.RawMessage, err error)

func (*Database) GetPinnedMailservers

func (db *Database) GetPinnedMailservers() (rst map[string]string, err error)

func (*Database) GetPreferredUsername

func (db *Database) GetPreferredUsername() (string, error)

func (*Database) GetProfilePicturesVisibility

func (db *Database) GetProfilePicturesVisibility() (result int, err error)

func (*Database) GetPublicKey

func (db *Database) GetPublicKey() (string, error)

func (*Database) GetRecentStickers

func (db *Database) GetRecentStickers() (rst *json.RawMessage, err error)

func (*Database) GetSettingLastSynced

func (db *Database) GetSettingLastSynced(setting SettingField) (result uint64, err error)

func (*Database) GetSettings

func (db *Database) GetSettings() (Settings, error)

func (*Database) GetTestNetworksEnabled added in v0.101.1

func (db *Database) GetTestNetworksEnabled() (result bool, err error)

func (*Database) GetWalletRootAddress added in v0.98.6

func (db *Database) GetWalletRootAddress() (rst types.Address, err error)

func (*Database) GifAPIKey

func (db *Database) GifAPIKey() (string, error)

func (*Database) GifFavorites

func (db *Database) GifFavorites() (favorites json.RawMessage, err error)

func (*Database) GifRecents

func (db *Database) GifRecents() (recents json.RawMessage, err error)

func (*Database) LastBackup

func (db *Database) LastBackup() (result uint64, err error)

func (*Database) MutualContactEnabled added in v0.101.1

func (db *Database) MutualContactEnabled() (result bool, err error)

func (*Database) SaveSetting

func (db *Database) SaveSetting(setting string, value interface{}) error

SaveSetting stores data from any non-sync source If the field requires syncing the field data is pushed on to the SyncQueue

func (*Database) SaveSettingField

func (db *Database) SaveSettingField(sf SettingField, value interface{}) error

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 (*Database) SaveSyncSetting

func (db *Database) SaveSyncSetting(setting SettingField, value interface{}, clock uint64) error

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 (*Database) SetBackupFetched

func (db *Database) SetBackupFetched(fetched bool) error

func (*Database) SetLastBackup

func (db *Database) SetLastBackup(time uint64) error

func (*Database) SetPinnedMailservers

func (db *Database) SetPinnedMailservers(mailservers map[string]string) error

func (*Database) SetSettingLastSynced

func (db *Database) SetSettingLastSynced(setting SettingField, clock uint64) error

func (*Database) SetUseMailservers

func (db *Database) SetUseMailservers(value bool) error

func (*Database) ShouldBroadcastUserStatus

func (db *Database) ShouldBroadcastUserStatus() (result bool, err error)

func (*Database) TestNetworksEnabled added in v0.100.1

func (db *Database) TestNetworksEnabled() (rst bool, err error)

type ProfilePicturesShowToType

type ProfilePicturesShowToType int
const (
	ProfilePicturesShowToContactsOnly ProfilePicturesShowToType = iota + 1
	ProfilePicturesShowToEveryone
	ProfilePicturesShowToNone
)

type ProfilePicturesVisibilityType

type ProfilePicturesVisibilityType int
const (
	ProfilePicturesVisibilityContactsOnly ProfilePicturesVisibilityType = iota + 1
	ProfilePicturesVisibilityEveryone
	ProfilePicturesVisibilityNone
)

type SettingField

type SettingField struct {
	// contains filtered or unexported fields
}

SettingField represents an individual setting in the database, it contains context dependant names and optional pre-store value parsing, along with optional *SyncProtobufFactory

func GetFieldFromProtobufType

func GetFieldFromProtobufType(pbt protobuf.SyncSetting_Type) (SettingField, error)

func (SettingField) CanSync

func (s SettingField) CanSync(source SyncSource) bool

CanSync checks if a SettingField has functions supporting the syncing of

func (SettingField) GetDBName

func (s SettingField) GetDBName() string

func (SettingField) GetReactName

func (s SettingField) GetReactName() string

func (SettingField) SyncProtobufFactory

func (s SettingField) SyncProtobufFactory() *SyncProtobufFactory

func (SettingField) ValueHandler

func (s SettingField) ValueHandler() ValueHandler

type Settings

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"`
	MutualContactEnabled      bool             `json:"mutual-contact-enabled?"`
	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"`
	TestNetworksEnabled            bool                          `json:"test-networks-enabled?,omitempty"`
}

Settings represents the entire setting row stored in the application db

type SyncProtobufFactory

type SyncProtobufFactory struct {
	// contains filtered or unexported fields
}

SyncProtobufFactory represents a collection of functionality to generate and parse *protobuf.SyncSetting

func (*SyncProtobufFactory) ExtractValueFromProtobuf

func (spf *SyncProtobufFactory) ExtractValueFromProtobuf() SyncSettingProtobufToValue

func (*SyncProtobufFactory) FromInterface

func (*SyncProtobufFactory) FromStruct

func (*SyncProtobufFactory) Inactive

func (spf *SyncProtobufFactory) Inactive() bool

func (*SyncProtobufFactory) SyncSettingProtobufType

func (spf *SyncProtobufFactory) SyncSettingProtobufType() protobuf.SyncSetting_Type

type SyncSettingField

type SyncSettingField struct {
	SettingField
	Value interface{}
}

SyncSettingField represents a binding between a Value and a SettingField

func (SyncSettingField) MarshalJSON

func (s SyncSettingField) MarshalJSON() ([]byte, error)

type SyncSettingProtobufFactoryInterface

type SyncSettingProtobufFactoryInterface func(interface{}, uint64, string) (*common.RawMessage, error)

type SyncSettingProtobufFactoryStruct

type SyncSettingProtobufFactoryStruct func(Settings, uint64, string) (*common.RawMessage, error)

type SyncSettingProtobufToValue

type SyncSettingProtobufToValue func(setting *protobuf.SyncSetting) interface{}

type SyncSource

type SyncSource int
const (
	FromInterface SyncSource = iota + 1
	FromStruct
)

type ValueHandler

type ValueHandler func(interface{}) (interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL