feat: display name

This commit is contained in:
Richard Ramos 2022-02-17 11:13:10 -04:00
parent 4f5121b4ef
commit 50ec6f97e0
30 changed files with 1331 additions and 531 deletions

View file

@ -1 +1 @@
0.94.13
0.95.0

View file

@ -1,19 +1,20 @@
// Code generated by go-bindata. DO NOT EDIT.
// Code generated by go-bindata.
// sources:
// 1640111208_dummy.up.sql (258B)
// 1642666031_add_removed_clock_to_bookmarks.up.sql (117B)
// 1643644541_gif_api_key_setting.up.sql (108B)
// 1644188994_recent_stickers.up.sql (79B)
// 1646659233_add_address_to_dapp_permisssion.up.sql (700B)
// 1646841105_add_emoji_account.up.sql (96B)
// doc.go (74B)
// 1640111208_dummy.up.sql
// 1642666031_add_removed_clock_to_bookmarks.up.sql
// 1643644541_gif_api_key_setting.up.sql
// 1644188994_recent_stickers.up.sql
// 1646659233_add_address_to_dapp_permisssion.up.sql
// 1646841105_add_emoji_account.up.sql
// 1647278782_display_name.up.sql
// doc.go
// DO NOT EDIT!
package migrations
import (
"bytes"
"compress/gzip"
"crypto/sha256"
"fmt"
"io"
"io/ioutil"
@ -26,7 +27,7 @@ import (
func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("read %q: %w", name, err)
return nil, fmt.Errorf("Read %q: %v", name, err)
}
var buf bytes.Buffer
@ -34,7 +35,7 @@ func bindataRead(data []byte, name string) ([]byte, error) {
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("read %q: %w", name, err)
return nil, fmt.Errorf("Read %q: %v", name, err)
}
if clErr != nil {
return nil, err
@ -44,9 +45,8 @@ func bindataRead(data []byte, name string) ([]byte, error) {
}
type asset struct {
bytes []byte
info os.FileInfo
digest [sha256.Size]byte
bytes []byte
info os.FileInfo
}
type bindataFileInfo struct {
@ -90,8 +90,8 @@ func _1640111208_dummyUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(0664), modTime: time.Unix(1647246959, 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}}
info := bindataFileInfo{name: "1640111208_dummy.up.sql", size: 258, mode: os.FileMode(436), modTime: time.Unix(1645543084, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -110,8 +110,8 @@ 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(0664), modTime: time.Unix(1647246959, 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}}
info := bindataFileInfo{name: "1642666031_add_removed_clock_to_bookmarks.up.sql", size: 117, mode: os.FileMode(436), modTime: time.Unix(1646418868, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -130,8 +130,8 @@ 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(0664), modTime: time.Unix(1647246959, 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}}
info := bindataFileInfo{name: "1643644541_gif_api_key_setting.up.sql", size: 108, mode: os.FileMode(436), modTime: time.Unix(1645543084, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -150,8 +150,8 @@ func _1644188994_recent_stickersUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(0664), modTime: time.Unix(1647246959, 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}}
info := bindataFileInfo{name: "1644188994_recent_stickers.up.sql", size: 79, mode: os.FileMode(436), modTime: time.Unix(1646853782, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -170,8 +170,8 @@ 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(0664), modTime: time.Unix(1647247370, 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}}
info := bindataFileInfo{name: "1646659233_add_address_to_dapp_permisssion.up.sql", size: 700, mode: os.FileMode(436), modTime: time.Unix(1647278692, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -190,8 +190,28 @@ func _1646841105_add_emoji_accountUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(0664), modTime: time.Unix(1647247370, 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}}
info := bindataFileInfo{name: "1646841105_add_emoji_account.up.sql", size: 96, mode: os.FileMode(436), modTime: time.Unix(1647278692, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var __1647278782_display_nameUpSql = []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\x48\xc9\x2c\x2e\xc8\x49\xac\x8c\xcf\x4b\xcc\x4d\x55\x08\x71\x8d\x08\x51\xf0\xf3\x0f\x51\xf0\x0b\xf5\xf1\x51\x70\x71\x75\x73\x0c\xf5\x09\x51\x50\x52\xb2\xe6\x0a\x0d\x70\x71\x0c\x41\x32\x21\xd8\x35\x04\x55\xab\x2d\x58\x19\x20\x00\x00\xff\xff\xc7\x11\xdd\x01\x6e\x00\x00\x00")
func _1647278782_display_nameUpSqlBytes() ([]byte, error) {
return bindataRead(
__1647278782_display_nameUpSql,
"1647278782_display_name.up.sql",
)
}
func _1647278782_display_nameUpSql() (*asset, error) {
bytes, err := _1647278782_display_nameUpSqlBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "1647278782_display_name.up.sql", size: 110, mode: os.FileMode(436), modTime: time.Unix(1647278807, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -210,8 +230,8 @@ func docGo() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(0664), modTime: time.Unix(1647246959, 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}}
info := bindataFileInfo{name: "doc.go", size: 74, mode: os.FileMode(436), modTime: time.Unix(1643209233, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -219,8 +239,8 @@ func docGo() (*asset, error) {
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
@ -230,12 +250,6 @@ func Asset(name string) ([]byte, error) {
return nil, fmt.Errorf("Asset %s not found", name)
}
// AssetString returns the asset contents as a string (instead of a []byte).
func AssetString(name string) (string, error) {
data, err := Asset(name)
return string(data), err
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
@ -247,18 +261,12 @@ func MustAsset(name string) []byte {
return a
}
// MustAssetString is like AssetString but panics when Asset would return an
// error. It simplifies safe initialization of global variables.
func MustAssetString(name string) string {
return string(MustAsset(name))
}
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
@ -268,33 +276,6 @@ func AssetInfo(name string) (os.FileInfo, error) {
return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetDigest returns the digest of the file with the given name. It returns an
// error if the asset could not be found or the digest could not be loaded.
func AssetDigest(name string) ([sha256.Size]byte, error) {
canonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[canonicalName]; ok {
a, err := f()
if err != nil {
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s can't read by error: %v", name, err)
}
return a.digest, nil
}
return [sha256.Size]byte{}, fmt.Errorf("AssetDigest %s not found", name)
}
// Digests returns a map of all known files and their checksums.
func Digests() (map[string][sha256.Size]byte, error) {
mp := make(map[string][sha256.Size]byte, len(_bindata))
for name := range _bindata {
a, err := _bindata[name]()
if err != nil {
return nil, err
}
mp[name] = a.digest
}
return mp, nil
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
@ -306,18 +287,16 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"1640111208_dummy.up.sql": _1640111208_dummyUpSql,
"1642666031_add_removed_clock_to_bookmarks.up.sql": _1642666031_add_removed_clock_to_bookmarksUpSql,
"1643644541_gif_api_key_setting.up.sql": _1643644541_gif_api_key_settingUpSql,
"1644188994_recent_stickers.up.sql": _1644188994_recent_stickersUpSql,
"1640111208_dummy.up.sql": _1640111208_dummyUpSql,
"1642666031_add_removed_clock_to_bookmarks.up.sql": _1642666031_add_removed_clock_to_bookmarksUpSql,
"1643644541_gif_api_key_setting.up.sql": _1643644541_gif_api_key_settingUpSql,
"1644188994_recent_stickers.up.sql": _1644188994_recent_stickersUpSql,
"1646659233_add_address_to_dapp_permisssion.up.sql": _1646659233_add_address_to_dapp_permisssionUpSql,
"1646841105_add_emoji_account.up.sql": _1646841105_add_emoji_accountUpSql,
"doc.go": docGo,
"1646841105_add_emoji_account.up.sql": _1646841105_add_emoji_accountUpSql,
"1647278782_display_name.up.sql": _1647278782_display_nameUpSql,
"doc.go": docGo,
}
// AssetDebug is true if the assets were built with the debug flag enabled.
const AssetDebug = false
// AssetDir returns the file names below a certain
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
@ -327,15 +306,15 @@ const AssetDebug = false
// img/
// a.png
// b.png
// then AssetDir("data") would return []string{"foo.txt", "img"},
// AssetDir("data/img") would return []string{"a.png", "b.png"},
// AssetDir("foo.txt") and AssetDir("notexist") would return an error, and
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
canonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(canonicalName, "/")
cannonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(cannonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
if node == nil {
@ -357,18 +336,18 @@ type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"1640111208_dummy.up.sql": {_1640111208_dummyUpSql, map[string]*bintree{}},
"1642666031_add_removed_clock_to_bookmarks.up.sql": {_1642666031_add_removed_clock_to_bookmarksUpSql, map[string]*bintree{}},
"1643644541_gif_api_key_setting.up.sql": {_1643644541_gif_api_key_settingUpSql, map[string]*bintree{}},
"1644188994_recent_stickers.up.sql": {_1644188994_recent_stickersUpSql, map[string]*bintree{}},
"1646659233_add_address_to_dapp_permisssion.up.sql": {_1646659233_add_address_to_dapp_permisssionUpSql, map[string]*bintree{}},
"1646841105_add_emoji_account.up.sql": {_1646841105_add_emoji_accountUpSql, map[string]*bintree{}},
"doc.go": {docGo, map[string]*bintree{}},
"1640111208_dummy.up.sql": &bintree{_1640111208_dummyUpSql, map[string]*bintree{}},
"1642666031_add_removed_clock_to_bookmarks.up.sql": &bintree{_1642666031_add_removed_clock_to_bookmarksUpSql, map[string]*bintree{}},
"1643644541_gif_api_key_setting.up.sql": &bintree{_1643644541_gif_api_key_settingUpSql, map[string]*bintree{}},
"1644188994_recent_stickers.up.sql": &bintree{_1644188994_recent_stickersUpSql, map[string]*bintree{}},
"1646659233_add_address_to_dapp_permisssion.up.sql": &bintree{_1646659233_add_address_to_dapp_permisssionUpSql, map[string]*bintree{}},
"1646841105_add_emoji_account.up.sql": &bintree{_1646841105_add_emoji_accountUpSql, map[string]*bintree{}},
"1647278782_display_name.up.sql": &bintree{_1647278782_display_nameUpSql, map[string]*bintree{}},
"doc.go": &bintree{docGo, map[string]*bintree{}},
}}
// RestoreAsset restores an asset under the given directory.
// RestoreAsset restores an asset under the given directory
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
@ -386,10 +365,14 @@ func RestoreAsset(dir, name string) error {
if err != nil {
return err
}
return os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
}
// RestoreAssets restores an asset under the given directory recursively.
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
@ -407,6 +390,7 @@ func RestoreAssets(dir, name string) error {
}
func _filePath(dir, name string) string {
canonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(canonicalName, "/")...)...)
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}

View file

@ -0,0 +1,2 @@
ALTER TABLE settings ADD COLUMN display_name TEXT NOT NULL DEFAULT "";
UPDATE settings SET display_name = "";

View file

@ -23,6 +23,7 @@ import (
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/profiling"
protocol "github.com/status-im/status-go/protocol"
"github.com/status-im/status-go/protocol/identity/alias"
"github.com/status-im/status-go/server"
"github.com/status-im/status-go/services/personal"
"github.com/status-im/status-go/services/typeddata"
@ -639,6 +640,10 @@ func GenerateAlias(pk string) string {
return name
}
func IsAlias(value string) string {
return prepareJSONResponse(alias.IsAlias(value), nil)
}
func Identicon(pk string) string {
// We ignore any error, empty string is considered an error
identicon, _ := protocol.Identicon(pk)

View file

@ -80,6 +80,7 @@ type Settings struct {
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"`
@ -187,6 +188,7 @@ INSERT INTO settings (
currency,
current_network,
dapps_address,
display_name,
eip1581_address,
installation_id,
key_uid,
@ -204,12 +206,13 @@ INSERT INTO settings (
wallet_root_address,
synthetic_id
) VALUES (
?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,'id')`,
s.Address,
s.Currency,
s.CurrentNetwork,
s.DappsAddress,
s.DisplayName,
s.EIP1581Address,
s.InstallationID,
s.KeyUID,
@ -262,6 +265,8 @@ func (db *Database) SaveSetting(setting string, value interface{}) error {
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 {
@ -501,7 +506,7 @@ func (db *Database) SaveSetting(setting string, value 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_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(
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,
@ -510,6 +515,7 @@ func (db *Database) GetSettings() (Settings, error) {
&s.CustomBootnodes,
&s.CustomBootnodesEnabled,
&s.DappsAddress,
&s.DisplayName,
&s.EIP1581Address,
&s.Fleet,
&s.HideHomeTooltip,
@ -917,6 +923,18 @@ func (db *Database) ENSName() (string, error) {
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)

View file

@ -193,6 +193,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
ResponseTo string `json:"responseTo"`
New bool `json:"new,omitempty"`
EnsName string `json:"ensName"`
DisplayName string `json:"displayName"`
Image string `json:"image,omitempty"`
Audio string `json:"audio,omitempty"`
AudioDurationMs uint64 `json:"audioDurationMs,omitempty"`
@ -228,6 +229,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
ResponseTo: m.ResponseTo,
New: m.New,
EnsName: m.EnsName,
DisplayName: m.DisplayName,
Image: m.ImageLocalURL,
Audio: m.AudioLocalURL,
CommunityID: m.CommunityID,
@ -262,6 +264,7 @@ func (m *Message) UnmarshalJSON(data []byte) error {
*Alias
ResponseTo string `json:"responseTo"`
EnsName string `json:"ensName"`
DisplayName string `json:"displayName"`
ChatID string `json:"chatId"`
Sticker *protobuf.StickerMessage `json:"sticker"`
AudioDurationMs uint64 `json:"audioDurationMs"`
@ -283,6 +286,7 @@ func (m *Message) UnmarshalJSON(data []byte) error {
}
m.ResponseTo = aux.ResponseTo
m.EnsName = aux.EnsName
m.DisplayName = aux.DisplayName
m.ChatId = aux.ChatID
m.ContentType = aux.ContentType
m.ParsedText = aux.ParsedText

View file

@ -27,7 +27,7 @@ func (c *Contact) CanonicalName() string {
}
if c.ENSVerified {
return c.Name
return c.EnsName
}
return c.Alias
@ -62,7 +62,7 @@ type Contact struct {
// Ethereum address of the contact
Address string `json:"address,omitempty"`
// ENS name of contact
Name string `json:"name,omitempty"`
EnsName string `json:"ensName,omitempty"`
// EnsVerified whether we verified the name of the contact
ENSVerified bool `json:"ensVerified"`
// Generated username name of the contact
@ -78,6 +78,9 @@ type Contact struct {
LocalNickname string `json:"localNickname,omitempty"`
// Display name of the contact
DisplayName string `json:"displayName"`
Images map[string]images.IdentityImage `json:"images"`
Added bool `json:"added"`

View file

@ -0,0 +1,613 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: protocol_message.proto
package encryption
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 SignedPreKey struct {
SignedPreKey []byte `protobuf:"bytes,1,opt,name=signed_pre_key,json=signedPreKey,proto3" json:"signed_pre_key,omitempty"`
Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
ProtocolVersion uint32 `protobuf:"varint,3,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SignedPreKey) Reset() { *m = SignedPreKey{} }
func (m *SignedPreKey) String() string { return proto.CompactTextString(m) }
func (*SignedPreKey) ProtoMessage() {}
func (*SignedPreKey) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{0}
}
func (m *SignedPreKey) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SignedPreKey.Unmarshal(m, b)
}
func (m *SignedPreKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SignedPreKey.Marshal(b, m, deterministic)
}
func (m *SignedPreKey) XXX_Merge(src proto.Message) {
xxx_messageInfo_SignedPreKey.Merge(m, src)
}
func (m *SignedPreKey) XXX_Size() int {
return xxx_messageInfo_SignedPreKey.Size(m)
}
func (m *SignedPreKey) XXX_DiscardUnknown() {
xxx_messageInfo_SignedPreKey.DiscardUnknown(m)
}
var xxx_messageInfo_SignedPreKey proto.InternalMessageInfo
func (m *SignedPreKey) GetSignedPreKey() []byte {
if m != nil {
return m.SignedPreKey
}
return nil
}
func (m *SignedPreKey) GetVersion() uint32 {
if m != nil {
return m.Version
}
return 0
}
func (m *SignedPreKey) GetProtocolVersion() uint32 {
if m != nil {
return m.ProtocolVersion
}
return 0
}
// X3DH prekey bundle
type Bundle struct {
// Identity key
Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
// Installation id
SignedPreKeys map[string]*SignedPreKey `protobuf:"bytes,2,rep,name=signed_pre_keys,json=signedPreKeys,proto3" json:"signed_pre_keys,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Prekey signature
Signature []byte `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"`
// When the bundle was created locally
Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Bundle) Reset() { *m = Bundle{} }
func (m *Bundle) String() string { return proto.CompactTextString(m) }
func (*Bundle) ProtoMessage() {}
func (*Bundle) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{1}
}
func (m *Bundle) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Bundle.Unmarshal(m, b)
}
func (m *Bundle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Bundle.Marshal(b, m, deterministic)
}
func (m *Bundle) XXX_Merge(src proto.Message) {
xxx_messageInfo_Bundle.Merge(m, src)
}
func (m *Bundle) XXX_Size() int {
return xxx_messageInfo_Bundle.Size(m)
}
func (m *Bundle) XXX_DiscardUnknown() {
xxx_messageInfo_Bundle.DiscardUnknown(m)
}
var xxx_messageInfo_Bundle proto.InternalMessageInfo
func (m *Bundle) GetIdentity() []byte {
if m != nil {
return m.Identity
}
return nil
}
func (m *Bundle) GetSignedPreKeys() map[string]*SignedPreKey {
if m != nil {
return m.SignedPreKeys
}
return nil
}
func (m *Bundle) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
func (m *Bundle) GetTimestamp() int64 {
if m != nil {
return m.Timestamp
}
return 0
}
type BundleContainer struct {
// X3DH prekey bundle
Bundle *Bundle `protobuf:"bytes,1,opt,name=bundle,proto3" json:"bundle,omitempty"`
// Private signed prekey
PrivateSignedPreKey []byte `protobuf:"bytes,2,opt,name=private_signed_pre_key,json=privateSignedPreKey,proto3" json:"private_signed_pre_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *BundleContainer) Reset() { *m = BundleContainer{} }
func (m *BundleContainer) String() string { return proto.CompactTextString(m) }
func (*BundleContainer) ProtoMessage() {}
func (*BundleContainer) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{2}
}
func (m *BundleContainer) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BundleContainer.Unmarshal(m, b)
}
func (m *BundleContainer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_BundleContainer.Marshal(b, m, deterministic)
}
func (m *BundleContainer) XXX_Merge(src proto.Message) {
xxx_messageInfo_BundleContainer.Merge(m, src)
}
func (m *BundleContainer) XXX_Size() int {
return xxx_messageInfo_BundleContainer.Size(m)
}
func (m *BundleContainer) XXX_DiscardUnknown() {
xxx_messageInfo_BundleContainer.DiscardUnknown(m)
}
var xxx_messageInfo_BundleContainer proto.InternalMessageInfo
func (m *BundleContainer) GetBundle() *Bundle {
if m != nil {
return m.Bundle
}
return nil
}
func (m *BundleContainer) GetPrivateSignedPreKey() []byte {
if m != nil {
return m.PrivateSignedPreKey
}
return nil
}
type DRHeader struct {
// Current ratchet public key
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// Number of the message in the sending chain
N uint32 `protobuf:"varint,2,opt,name=n,proto3" json:"n,omitempty"`
// Length of the previous sending chain
Pn uint32 `protobuf:"varint,3,opt,name=pn,proto3" json:"pn,omitempty"`
// Bundle ID
Id []byte `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DRHeader) Reset() { *m = DRHeader{} }
func (m *DRHeader) String() string { return proto.CompactTextString(m) }
func (*DRHeader) ProtoMessage() {}
func (*DRHeader) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{3}
}
func (m *DRHeader) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DRHeader.Unmarshal(m, b)
}
func (m *DRHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DRHeader.Marshal(b, m, deterministic)
}
func (m *DRHeader) XXX_Merge(src proto.Message) {
xxx_messageInfo_DRHeader.Merge(m, src)
}
func (m *DRHeader) XXX_Size() int {
return xxx_messageInfo_DRHeader.Size(m)
}
func (m *DRHeader) XXX_DiscardUnknown() {
xxx_messageInfo_DRHeader.DiscardUnknown(m)
}
var xxx_messageInfo_DRHeader proto.InternalMessageInfo
func (m *DRHeader) GetKey() []byte {
if m != nil {
return m.Key
}
return nil
}
func (m *DRHeader) GetN() uint32 {
if m != nil {
return m.N
}
return 0
}
func (m *DRHeader) GetPn() uint32 {
if m != nil {
return m.Pn
}
return 0
}
func (m *DRHeader) GetId() []byte {
if m != nil {
return m.Id
}
return nil
}
type DHHeader struct {
// Compressed ephemeral public key
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *DHHeader) Reset() { *m = DHHeader{} }
func (m *DHHeader) String() string { return proto.CompactTextString(m) }
func (*DHHeader) ProtoMessage() {}
func (*DHHeader) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{4}
}
func (m *DHHeader) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_DHHeader.Unmarshal(m, b)
}
func (m *DHHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_DHHeader.Marshal(b, m, deterministic)
}
func (m *DHHeader) XXX_Merge(src proto.Message) {
xxx_messageInfo_DHHeader.Merge(m, src)
}
func (m *DHHeader) XXX_Size() int {
return xxx_messageInfo_DHHeader.Size(m)
}
func (m *DHHeader) XXX_DiscardUnknown() {
xxx_messageInfo_DHHeader.DiscardUnknown(m)
}
var xxx_messageInfo_DHHeader proto.InternalMessageInfo
func (m *DHHeader) GetKey() []byte {
if m != nil {
return m.Key
}
return nil
}
type X3DHHeader struct {
// Ephemeral key used
Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
// Used bundle's signed prekey
Id []byte `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *X3DHHeader) Reset() { *m = X3DHHeader{} }
func (m *X3DHHeader) String() string { return proto.CompactTextString(m) }
func (*X3DHHeader) ProtoMessage() {}
func (*X3DHHeader) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{5}
}
func (m *X3DHHeader) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_X3DHHeader.Unmarshal(m, b)
}
func (m *X3DHHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_X3DHHeader.Marshal(b, m, deterministic)
}
func (m *X3DHHeader) XXX_Merge(src proto.Message) {
xxx_messageInfo_X3DHHeader.Merge(m, src)
}
func (m *X3DHHeader) XXX_Size() int {
return xxx_messageInfo_X3DHHeader.Size(m)
}
func (m *X3DHHeader) XXX_DiscardUnknown() {
xxx_messageInfo_X3DHHeader.DiscardUnknown(m)
}
var xxx_messageInfo_X3DHHeader proto.InternalMessageInfo
func (m *X3DHHeader) GetKey() []byte {
if m != nil {
return m.Key
}
return nil
}
func (m *X3DHHeader) GetId() []byte {
if m != nil {
return m.Id
}
return nil
}
// Hash Ratchet Header
type HRHeader struct {
// community key ID
KeyId uint32 `protobuf:"varint,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"`
// Community message number for this key_id
SeqNo uint32 `protobuf:"varint,2,opt,name=seq_no,json=seqNo,proto3" json:"seq_no,omitempty"`
// Community ID
GroupId string `protobuf:"bytes,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *HRHeader) Reset() { *m = HRHeader{} }
func (m *HRHeader) String() string { return proto.CompactTextString(m) }
func (*HRHeader) ProtoMessage() {}
func (*HRHeader) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{6}
}
func (m *HRHeader) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_HRHeader.Unmarshal(m, b)
}
func (m *HRHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_HRHeader.Marshal(b, m, deterministic)
}
func (m *HRHeader) XXX_Merge(src proto.Message) {
xxx_messageInfo_HRHeader.Merge(m, src)
}
func (m *HRHeader) XXX_Size() int {
return xxx_messageInfo_HRHeader.Size(m)
}
func (m *HRHeader) XXX_DiscardUnknown() {
xxx_messageInfo_HRHeader.DiscardUnknown(m)
}
var xxx_messageInfo_HRHeader proto.InternalMessageInfo
func (m *HRHeader) GetKeyId() uint32 {
if m != nil {
return m.KeyId
}
return 0
}
func (m *HRHeader) GetSeqNo() uint32 {
if m != nil {
return m.SeqNo
}
return 0
}
func (m *HRHeader) GetGroupId() string {
if m != nil {
return m.GroupId
}
return ""
}
// Direct message value
type EncryptedMessageProtocol struct {
X3DHHeader *X3DHHeader `protobuf:"bytes,1,opt,name=X3DH_header,json=X3DHHeader,proto3" json:"X3DH_header,omitempty"`
DRHeader *DRHeader `protobuf:"bytes,2,opt,name=DR_header,json=DRHeader,proto3" json:"DR_header,omitempty"`
DHHeader *DHHeader `protobuf:"bytes,101,opt,name=DH_header,json=DHHeader,proto3" json:"DH_header,omitempty"`
HRHeader *HRHeader `protobuf:"bytes,102,opt,name=HR_header,json=HRHeader,proto3" json:"HR_header,omitempty"`
// Encrypted payload
Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EncryptedMessageProtocol) Reset() { *m = EncryptedMessageProtocol{} }
func (m *EncryptedMessageProtocol) String() string { return proto.CompactTextString(m) }
func (*EncryptedMessageProtocol) ProtoMessage() {}
func (*EncryptedMessageProtocol) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{7}
}
func (m *EncryptedMessageProtocol) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EncryptedMessageProtocol.Unmarshal(m, b)
}
func (m *EncryptedMessageProtocol) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EncryptedMessageProtocol.Marshal(b, m, deterministic)
}
func (m *EncryptedMessageProtocol) XXX_Merge(src proto.Message) {
xxx_messageInfo_EncryptedMessageProtocol.Merge(m, src)
}
func (m *EncryptedMessageProtocol) XXX_Size() int {
return xxx_messageInfo_EncryptedMessageProtocol.Size(m)
}
func (m *EncryptedMessageProtocol) XXX_DiscardUnknown() {
xxx_messageInfo_EncryptedMessageProtocol.DiscardUnknown(m)
}
var xxx_messageInfo_EncryptedMessageProtocol proto.InternalMessageInfo
func (m *EncryptedMessageProtocol) GetX3DHHeader() *X3DHHeader {
if m != nil {
return m.X3DHHeader
}
return nil
}
func (m *EncryptedMessageProtocol) GetDRHeader() *DRHeader {
if m != nil {
return m.DRHeader
}
return nil
}
func (m *EncryptedMessageProtocol) GetDHHeader() *DHHeader {
if m != nil {
return m.DHHeader
}
return nil
}
func (m *EncryptedMessageProtocol) GetHRHeader() *HRHeader {
if m != nil {
return m.HRHeader
}
return nil
}
func (m *EncryptedMessageProtocol) GetPayload() []byte {
if m != nil {
return m.Payload
}
return nil
}
// Top-level protocol message
type ProtocolMessage struct {
// The device id of the sender
InstallationId string `protobuf:"bytes,2,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
// List of bundles
Bundles []*Bundle `protobuf:"bytes,3,rep,name=bundles,proto3" json:"bundles,omitempty"`
// One to one message, encrypted, indexed by installation_id
// TODO map here is redundant in case of community messages
EncryptedMessage map[string]*EncryptedMessageProtocol `protobuf:"bytes,101,rep,name=encrypted_message,json=encryptedMessage,proto3" json:"encrypted_message,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Public chats, not encrypted
PublicMessage []byte `protobuf:"bytes,102,opt,name=public_message,json=publicMessage,proto3" json:"public_message,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ProtocolMessage) Reset() { *m = ProtocolMessage{} }
func (m *ProtocolMessage) String() string { return proto.CompactTextString(m) }
func (*ProtocolMessage) ProtoMessage() {}
func (*ProtocolMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_4e37b52004a72e16, []int{8}
}
func (m *ProtocolMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ProtocolMessage.Unmarshal(m, b)
}
func (m *ProtocolMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ProtocolMessage.Marshal(b, m, deterministic)
}
func (m *ProtocolMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_ProtocolMessage.Merge(m, src)
}
func (m *ProtocolMessage) XXX_Size() int {
return xxx_messageInfo_ProtocolMessage.Size(m)
}
func (m *ProtocolMessage) XXX_DiscardUnknown() {
xxx_messageInfo_ProtocolMessage.DiscardUnknown(m)
}
var xxx_messageInfo_ProtocolMessage proto.InternalMessageInfo
func (m *ProtocolMessage) GetInstallationId() string {
if m != nil {
return m.InstallationId
}
return ""
}
func (m *ProtocolMessage) GetBundles() []*Bundle {
if m != nil {
return m.Bundles
}
return nil
}
func (m *ProtocolMessage) GetEncryptedMessage() map[string]*EncryptedMessageProtocol {
if m != nil {
return m.EncryptedMessage
}
return nil
}
func (m *ProtocolMessage) GetPublicMessage() []byte {
if m != nil {
return m.PublicMessage
}
return nil
}
func init() {
proto.RegisterType((*SignedPreKey)(nil), "encryption.SignedPreKey")
proto.RegisterType((*Bundle)(nil), "encryption.Bundle")
proto.RegisterMapType((map[string]*SignedPreKey)(nil), "encryption.Bundle.SignedPreKeysEntry")
proto.RegisterType((*BundleContainer)(nil), "encryption.BundleContainer")
proto.RegisterType((*DRHeader)(nil), "encryption.DRHeader")
proto.RegisterType((*DHHeader)(nil), "encryption.DHHeader")
proto.RegisterType((*X3DHHeader)(nil), "encryption.X3DHHeader")
proto.RegisterType((*HRHeader)(nil), "encryption.HRHeader")
proto.RegisterType((*EncryptedMessageProtocol)(nil), "encryption.EncryptedMessageProtocol")
proto.RegisterType((*ProtocolMessage)(nil), "encryption.ProtocolMessage")
proto.RegisterMapType((map[string]*EncryptedMessageProtocol)(nil), "encryption.ProtocolMessage.EncryptedMessageEntry")
}
func init() {
proto.RegisterFile("protocol_message.proto", fileDescriptor_4e37b52004a72e16)
}
var fileDescriptor_4e37b52004a72e16 = []byte{
// 642 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xdd, 0x4e, 0xdb, 0x4c,
0x10, 0x95, 0x6d, 0xf2, 0xc3, 0xe4, 0xf7, 0xdb, 0xaf, 0x20, 0x17, 0xa1, 0x2a, 0xb2, 0x40, 0x4d,
0xab, 0xca, 0x08, 0xa8, 0xd4, 0x8a, 0x4b, 0x0a, 0x52, 0xa0, 0xa2, 0x42, 0x8b, 0x54, 0x55, 0x5c,
0xd4, 0x72, 0xe2, 0x21, 0xac, 0x70, 0x6c, 0xe3, 0x75, 0x50, 0xfd, 0x02, 0xbd, 0xe9, 0x1b, 0xf6,
0x69, 0x2a, 0xef, 0x7a, 0x9d, 0x25, 0x24, 0x77, 0x99, 0xe3, 0x99, 0x39, 0x73, 0xce, 0xec, 0x04,
0xb6, 0x93, 0x34, 0xce, 0xe2, 0x49, 0x1c, 0x7a, 0x33, 0xe4, 0xdc, 0x9f, 0xa2, 0x2b, 0x00, 0x02,
0x18, 0x4d, 0xd2, 0x3c, 0xc9, 0x58, 0x1c, 0x39, 0x39, 0xb4, 0x6f, 0xd8, 0x34, 0xc2, 0xe0, 0x3a,
0xc5, 0xaf, 0x98, 0x93, 0x3d, 0xe8, 0x72, 0x11, 0x7b, 0x49, 0x8a, 0xde, 0x03, 0xe6, 0xb6, 0x31,
0x30, 0x86, 0x6d, 0xda, 0xe6, 0x7a, 0x96, 0x0d, 0x8d, 0x27, 0x4c, 0x39, 0x8b, 0x23, 0xdb, 0x1c,
0x18, 0xc3, 0x0e, 0x55, 0x21, 0x79, 0x07, 0xfd, 0x8a, 0x55, 0xa5, 0x58, 0x22, 0xa5, 0xa7, 0x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ab,
0xc3, 0x17, 0x01, 0xf9, 0x00, 0x0d, 0xf9, 0xfe, 0xb8, 0x6d, 0x89, 0x9b, 0x5c, 0xf5, 0x44, 0x55,
0x0a, 0xf9, 0x09, 0xff, 0xa1, 0xb2, 0x5c, 0xfd, 0x25, 0xd9, 0x28, 0xea, 0x0e, 0xf5, 0xba, 0xa5,
0x71, 0xdc, 0xe5, 0x3d, 0xc9, 0xbb, 0xee, 0xe3, 0x12, 0x4c, 0xf6, 0xa1, 0x9b, 0xcc, 0xc7, 0x21,
0x9b, 0x54, 0xcd, 0xef, 0x84, 0xd6, 0x8e, 0x44, 0xcb, 0xb4, 0x1d, 0x06, 0x5b, 0x2b, 0x3b, 0xae,
0x38, 0xe4, 0x93, 0xe7, 0x87, 0xbc, 0xa7, 0x4f, 0xb9, 0xee, 0xf5, 0x68, 0x47, 0x7d, 0x3a, 0xb8,
0x7d, 0x33, 0x65, 0xd9, 0xfd, 0x7c, 0xec, 0x4e, 0xe2, 0xd9, 0x81, 0xfa, 0x03, 0x3c, 0x58, 0x74,
0x19, 0xd7, 0x05, 0x78, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x20, 0x4c, 0xc2, 0xbb, 0xac, 0x05,
0x00, 0x00,
}

View file

@ -0,0 +1,33 @@
package alias
import (
"strings"
)
func IsAdjective(val string) bool {
for _, v := range adjectives {
if v == val {
return true
}
}
return false
}
func IsAnimal(val string) bool {
for _, v := range animals {
if v == val {
return true
}
}
return false
}
func IsAlias(alias string) bool {
aliasParts := strings.Fields(alias)
if len(aliasParts) == 3 {
if IsAdjective(strings.Title(aliasParts[0])) && IsAdjective(strings.Title(aliasParts[1])) && IsAnimal(strings.Title(aliasParts[2])) {
return true
}
}
return false
}

View file

@ -289,6 +289,10 @@ func ValidateReceivedChatMessage(message *protobuf.ChatMessage, whisperTimestamp
}
}
if err := ValidateDisplayName(&message.DisplayName); err != nil {
return err
}
return nil
}

View file

@ -780,10 +780,12 @@ func (m *Messenger) publishContactCode() error {
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err = m.sender.SendPublic(ctx, contactCodeTopic, rawMessage)
if err != nil {
m.logger.Warn("failed to send a contact code", zap.Error(err))
}
m.logger.Debug("contact code sent")
return err
}
@ -792,9 +794,7 @@ func (m *Messenger) publishContactCode() error {
// if the `shouldPublish` conditions are met
func (m *Messenger) attachChatIdentity(cca *protobuf.ContactCodeAdvertisement) error {
contactCodeTopic := transport.ContactCodeTopic(&m.identity.PublicKey)
shouldPublish, err := m.shouldPublishChatIdentity(contactCodeTopic)
if err != nil {
return err
}
@ -812,11 +812,13 @@ func (m *Messenger) attachChatIdentity(cca *protobuf.ContactCodeAdvertisement) e
if err != nil {
return err
}
if img == nil {
return errors.New("could not find image")
displayName, err := m.settings.DisplayName()
if err != nil {
return err
}
err = m.persistence.SaveWhenChatIdentityLastPublished(contactCodeTopic, img.Hash())
err = m.persistence.SaveWhenChatIdentityLastPublished(contactCodeTopic, m.getIdentityHash(displayName, img))
if err != nil {
return err
}
@ -875,11 +877,13 @@ func (m *Messenger) handleStandaloneChatIdentity(chat *Chat) error {
if err != nil {
return err
}
if img == nil {
return errors.New("could not find image")
displayName, err := m.settings.DisplayName()
if err != nil {
return err
}
err = m.persistence.SaveWhenChatIdentityLastPublished(chat.ID, img.Hash())
err = m.persistence.SaveWhenChatIdentityLastPublished(chat.ID, m.getIdentityHash(displayName, img))
if err != nil {
return err
}
@ -887,19 +891,31 @@ func (m *Messenger) handleStandaloneChatIdentity(chat *Chat) error {
return nil
}
func (m *Messenger) getIdentityHash(displayName string, img *userimage.IdentityImage) []byte {
if img == nil {
return crypto.Keccak256([]byte(displayName))
}
return crypto.Keccak256(img.Payload, []byte(displayName))
}
// shouldPublishChatIdentity returns true if the last time the ChatIdentity was attached was more than 24 hours ago
func (m *Messenger) shouldPublishChatIdentity(chatID string) (bool, error) {
if m.account == nil {
return false, nil
}
// Check we have at least one image
// Check we have at least one image or a display name
img, err := m.multiAccounts.GetIdentityImage(m.account.KeyUID, userimage.SmallDimName)
if err != nil {
return false, err
}
if img == nil {
displayName, err := m.settings.DisplayName()
if err != nil {
return false, err
}
if img == nil && displayName == "" {
return false, nil
}
@ -908,7 +924,7 @@ func (m *Messenger) shouldPublishChatIdentity(chatID string) (bool, error) {
return false, err
}
if !bytes.Equal(hash, img.Hash()) {
if !bytes.Equal(hash, m.getIdentityHash(displayName, img)) {
return true, nil
}
@ -923,11 +939,18 @@ func (m *Messenger) createChatIdentity(context chatContext) (*protobuf.ChatIdent
m.logger.Info(fmt.Sprintf("account keyUID '%s'", m.account.KeyUID))
m.logger.Info(fmt.Sprintf("context '%s'", context))
ci := &protobuf.ChatIdentity{
Clock: m.transport.GetCurrentTime(),
EnsName: "", // TODO add ENS name handling to dedicate PR
displayName, err := m.settings.DisplayName()
if err != nil {
return nil, err
}
err := m.attachIdentityImagesToChatIdentity(context, ci)
ci := &protobuf.ChatIdentity{
Clock: m.transport.GetCurrentTime(),
EnsName: "", // TODO add ENS name handling to dedicate PR
DisplayName: displayName,
}
err = m.attachIdentityImagesToChatIdentity(context, ci)
if err != nil {
return nil, err
}
@ -966,6 +989,10 @@ func (m *Messenger) attachIdentityImagesToChatIdentity(context chatContext, ci *
return err
}
if img == nil {
return nil
}
m.logger.Debug(fmt.Sprintf("%s images.IdentityImage '%s'", context, spew.Sdump(img)))
ciis[userimage.SmallDimName] = m.adaptIdentityImageToProtobuf(img)
@ -1062,7 +1089,7 @@ func (m *Messenger) handleENSVerified(records []*ens.VerificationRecord) {
}
contact.ENSVerified = record.Verified
contact.Name = record.Name
contact.EnsName = record.Name
contacts = append(contacts, contact)
}
@ -2299,6 +2326,12 @@ func (m *Messenger) SendChatMessages(ctx context.Context, messages []*common.Mes
// SendChatMessage takes a minimal message and sends it based on the corresponding chat
func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message) (*MessengerResponse, error) {
displayName, err := m.settings.DisplayName()
if err != nil {
return nil, err
}
message.DisplayName = displayName
if len(message.ImagePath) != 0 {
file, err := os.Open(message.ImagePath)
if err != nil {
@ -2368,7 +2401,7 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message
return nil, errors.New("Chat not found")
}
err := m.handleStandaloneChatIdentity(chat)
err = m.handleStandaloneChatIdentity(chat)
if err != nil {
return nil, err
}
@ -2475,7 +2508,12 @@ func (m *Messenger) ShareImageMessage(request *requests.ShareImageMessage) (*Mes
func (m *Messenger) SyncDevices(ctx context.Context, ensName, photoPath string) (err error) {
myID := contactIDFromPublicKey(&m.identity.PublicKey)
if _, err = m.sendContactUpdate(ctx, myID, ensName, photoPath); err != nil {
displayName, err := m.settings.DisplayName()
if err != nil {
return err
}
if _, err = m.sendContactUpdate(ctx, myID, displayName, ensName, photoPath); err != nil {
return err
}
@ -2722,7 +2760,7 @@ func (m *Messenger) syncContact(ctx context.Context, contact *Contact) error {
var ensName string
if contact.ENSVerified {
ensName = contact.Name
ensName = contact.EnsName
}
oneToOneChat, ok := m.allChats.Load(contact.ID)

View file

@ -142,7 +142,7 @@ func (m *Messenger) syncBackupContact(ctx context.Context, contact *Contact) *pr
var ensName string
if contact.ENSVerified {
ensName = contact.Name
ensName = contact.EnsName
}
oneToOneChat, ok := m.allChats.Load(contact.ID)

View file

@ -274,7 +274,7 @@ func (m *Messenger) CreateOneToOneChat(request *requests.CreateOneToOneChat) (*M
return nil, err
}
}
contact.Name = ensName
contact.EnsName = ensName
contact.ENSVerified = true
err = m.persistence.SaveContact(contact, nil)
if err != nil {

View file

@ -100,13 +100,13 @@ func (s *MessengerContactUpdateSuite) TestReceiveContactUpdate() {
s.Require().NoError(err)
receivedContact := response.Contacts[0]
s.Require().Equal(theirName, receivedContact.Name)
s.Require().Equal(theirName, receivedContact.EnsName)
s.Require().False(receivedContact.ENSVerified)
s.Require().NotEmpty(receivedContact.LastUpdated)
s.Require().True(receivedContact.HasAddedUs)
newPicture := "new-picture"
err = theirMessenger.SendContactUpdates(context.Background(), newName, newPicture)
err = theirMessenger.SendContactUpdates(context.Background(), newEnsName, newPicture)
s.Require().NoError(err)
// Wait for the message to reach its destination
@ -122,7 +122,7 @@ func (s *MessengerContactUpdateSuite) TestReceiveContactUpdate() {
receivedContact = response.Contacts[0]
s.Require().Equal(theirContactID, receivedContact.ID)
s.Require().Equal(newName, receivedContact.Name)
s.Require().Equal(newEnsName, receivedContact.EnsName)
s.Require().False(receivedContact.ENSVerified)
s.Require().NotEmpty(receivedContact.LastUpdated)
s.Require().NoError(theirMessenger.Shutdown())
@ -174,7 +174,7 @@ func (s *MessengerContactUpdateSuite) TestAddContactWithENS() {
s.Require().NoError(err)
s.Require().NotNil(response)
s.Require().Len(response.Contacts, 1)
s.Require().Equal(ensName, response.Contacts[0].Name)
s.Require().Equal(ensName, response.Contacts[0].EnsName)
s.Require().True(response.Contacts[0].ENSVerified)
s.Require().Len(response.Contacts, 1)

View file

@ -79,6 +79,10 @@ func (m *Messenger) AddContact(ctx context.Context, request *requests.AddContact
contact.LocalNickname = request.Nickname
}
if len(request.DisplayName) != 0 {
contact.DisplayName = request.DisplayName
}
if !contact.Added {
contact.Added = true
}
@ -137,8 +141,13 @@ func (m *Messenger) AddContact(ctx context.Context, request *requests.AddContact
return nil, err
}
displayName, err := m.settings.DisplayName()
if err != nil {
return nil, err
}
// Finally we send a contact update so they are notified we added them
response, err := m.sendContactUpdate(context.Background(), pubKey, ensName, "")
response, err := m.sendContactUpdate(context.Background(), pubKey, displayName, ensName, "")
if err != nil {
return nil, err
}
@ -414,14 +423,19 @@ func (m *Messenger) UnblockContact(contactID string) error {
func (m *Messenger) SendContactUpdates(ctx context.Context, ensName, profileImage string) (err error) {
myID := contactIDFromPublicKey(&m.identity.PublicKey)
if _, err = m.sendContactUpdate(ctx, myID, ensName, profileImage); err != nil {
displayName, err := m.settings.DisplayName()
if err != nil {
return err
}
if _, err = m.sendContactUpdate(ctx, myID, displayName, ensName, profileImage); err != nil {
return err
}
// TODO: This should not be sending paired messages, as we do it above
m.allContacts.Range(func(contactID string, contact *Contact) (shouldContinue bool) {
if contact.Added {
if _, err = m.sendContactUpdate(ctx, contact.ID, ensName, profileImage); err != nil {
if _, err = m.sendContactUpdate(ctx, contact.ID, displayName, ensName, profileImage); err != nil {
return false
}
}
@ -438,10 +452,15 @@ func (m *Messenger) SendContactUpdates(ctx context.Context, ensName, profileImag
// SendContactUpdate sends a contact update to a user and adds the user to contacts
func (m *Messenger) SendContactUpdate(ctx context.Context, chatID, ensName, profileImage string) (*MessengerResponse, error) {
return m.sendContactUpdate(ctx, chatID, ensName, profileImage)
displayName, err := m.settings.DisplayName()
if err != nil {
return nil, err
}
return m.sendContactUpdate(ctx, chatID, displayName, ensName, profileImage)
}
func (m *Messenger) sendContactUpdate(ctx context.Context, chatID, ensName, profileImage string) (*MessengerResponse, error) {
func (m *Messenger) sendContactUpdate(ctx context.Context, chatID, displayName, ensName, profileImage string) (*MessengerResponse, error) {
var response MessengerResponse
contact, ok := m.allContacts.Load(chatID)
@ -466,8 +485,10 @@ func (m *Messenger) sendContactUpdate(ctx context.Context, chatID, ensName, prof
contactUpdate := &protobuf.ContactUpdate{
Clock: clock,
DisplayName: displayName,
EnsName: ensName,
ProfileImage: profileImage}
ProfileImage: profileImage,
}
encodedMessage, err := proto.Marshal(contactUpdate)
if err != nil {
return nil, err
@ -505,7 +526,7 @@ func (m *Messenger) addENSNameToContact(contact *Contact) error {
return nil
}
contact.Name = ensRecord.Name
contact.EnsName = ensRecord.Name
contact.ENSVerified = true
return nil

View file

@ -0,0 +1,71 @@
package protocol
import (
"errors"
"regexp"
"strings"
"github.com/status-im/status-go/protocol/identity/alias"
)
var ErrInvalidDisplayNameRegExp = errors.New("only letters, numbers, underscores and hyphens allowed")
var ErrInvalidDisplayNameEthSuffix = errors.New(`usernames ending with "eth" are not allowed`)
var ErrInvalidDisplayNameNotAllowed = errors.New("name is not allowed")
func ValidateDisplayName(displayName *string) error {
name := strings.TrimSpace(*displayName)
*displayName = name
if name == "" {
return nil
}
// ^[\\w-\\s]{5,24}$ to allow spaces
if match, _ := regexp.MatchString("^[\\w-\\s]{5,24}$", name); !match {
return ErrInvalidDisplayNameRegExp
}
// .eth should not happen due to the regexp above, but let's keep it here in case the regexp is changed in the future
if strings.HasSuffix(name, "_eth") || strings.HasSuffix(name, ".eth") || strings.HasSuffix(name, "-eth") {
return ErrInvalidDisplayNameEthSuffix
}
if alias.IsAlias(name) {
return ErrInvalidDisplayNameNotAllowed
}
return nil
}
func (m *Messenger) SetDisplayName(displayName string) error {
currDisplayName, err := m.settings.DisplayName()
if err != nil {
return err
}
if currDisplayName == displayName {
return nil // Do nothing
}
if err = ValidateDisplayName(&displayName); err != nil {
return err
}
m.account.Name = displayName // We might need to do the same when syncing settings?
err = m.multiAccounts.SaveAccount(*m.account)
if err != nil {
return err
}
err = m.settings.SaveSetting("display-name", displayName)
if err != nil {
return err
}
err = m.resetLastPublishedTimeForChatIdentity()
if err != nil {
return err
}
return m.publishContactCode()
}

View file

@ -346,8 +346,8 @@ func (m *Messenger) HandleSyncInstallationContact(state *ReceivedMessageState, m
if message.Added {
contact.Added = true
}
if message.EnsName != "" && contact.Name != message.EnsName {
contact.Name = message.EnsName
if message.EnsName != "" && contact.EnsName != message.EnsName {
contact.EnsName = message.EnsName
publicKey, err := contact.PublicKey()
if err != nil {
return err
@ -543,6 +543,10 @@ func (m *Messenger) HandleContactUpdate(state *ReceivedMessageState, message pro
return ErrMessageNotAllowed
}
if err = ValidateDisplayName(&message.DisplayName); err != nil {
return err
}
if !ok {
chat = OneToOneFromPublicKey(state.CurrentMessageState.PublicKey, state.Timesource)
// We don't want to show the chat to the user
@ -553,10 +557,15 @@ func (m *Messenger) HandleContactUpdate(state *ReceivedMessageState, message pro
if contact.LastUpdated < message.Clock {
logger.Info("Updating contact")
if contact.Name != message.EnsName {
contact.Name = message.EnsName
if contact.EnsName != message.EnsName {
contact.EnsName = message.EnsName
contact.ENSVerified = false
}
if len(message.DisplayName) != 0 {
contact.DisplayName = message.DisplayName
}
contact.HasAddedUs = true
contact.LastUpdated = message.Clock
state.ModifiedContacts.Store(contact.ID, true)
@ -934,6 +943,11 @@ func (m *Messenger) HandleChatMessage(state *ReceivedMessageState) error {
}
}
if contact.DisplayName != receivedMessage.DisplayName && len(receivedMessage.DisplayName) != 0 {
contact.DisplayName = receivedMessage.DisplayName
state.ModifiedContacts.Store(contact.ID, true)
}
if receivedMessage.ContentType == protobuf.ChatMessage_COMMUNITY {
m.logger.Debug("Handling community content type")
@ -1420,6 +1434,18 @@ func (m *Messenger) HandleChatIdentity(state *ReceivedMessageState, ci protobuf.
return err
}
contact := state.CurrentMessageState.Contact
if err = ValidateDisplayName(&ci.DisplayName); err != nil {
return err
}
if contact.DisplayName != ci.DisplayName && len(ci.DisplayName) != 0 {
contact.DisplayName = ci.DisplayName
state.ModifiedContacts.Store(contact.ID, true)
state.AllContacts.Store(contact.ID, contact)
}
viewFromContacts := s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityContactsOnly
viewFromNoOne := s.ProfilePicturesVisibility == accounts.ProfilePicturesVisibilityNone
@ -1450,7 +1476,6 @@ func (m *Messenger) HandleChatIdentity(state *ReceivedMessageState, ci protobuf.
return ErrMessageNotAllowed
}
}
contact := state.CurrentMessageState.Contact
err = DecryptIdentityImagesWithIdentityPrivateKey(ci.Images, m.identity, state.CurrentMessageState.PublicKey)
if err != nil {

View file

@ -40,7 +40,7 @@ const (
testContract = "0x314159265dd8dbb310642f98f50c066173c1259b"
testValue = "2000"
testTransactionHash = "0x412a851ac2ae51cad34a56c8a9cfee55d577ac5e1ac71cf488a2f2093a373799"
newName = "new-name"
newEnsName = "new-name"
)
func TestMessengerSuite(t *testing.T) {
@ -708,7 +708,7 @@ func (s *MessengerSuite) TestRetrieveBlockedContact() {
publicKeyHex := "0x" + hex.EncodeToString(crypto.FromECDSAPub(&theirMessenger.identity.PublicKey))
blockedContact := Contact{
ID: publicKeyHex,
Name: "contact-name",
EnsName: "contact-name",
LastUpdated: 20,
Blocked: true,
}
@ -995,7 +995,7 @@ func (s *MessengerSuite) TestChangeNameGroupChat() {
)
s.Require().NoError(err)
_, err = s.m.ChangeGroupChatName(context.Background(), ourChat.ID, newName)
_, err = s.m.ChangeGroupChatName(context.Background(), ourChat.ID, newEnsName)
s.NoError(err)
// Retrieve their messages so that the chat is created
@ -1008,7 +1008,7 @@ func (s *MessengerSuite) TestChangeNameGroupChat() {
s.Require().Len(response.Chats(), 1)
actualChat := response.Chats()[0]
s.Require().Equal(newName, actualChat.Name)
s.Require().Equal(newEnsName, actualChat.Name)
s.Require().NoError(theirMessenger.Shutdown())
}
@ -1297,7 +1297,7 @@ func (s *MessengerSuite) TestChatPersistencePrivateGroupChat() {
func (s *MessengerSuite) TestBlockContact() {
contact := Contact{
ID: testPK,
Name: "contact-name",
EnsName: "contact-name",
LastUpdated: 20,
Added: true,
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,2 @@
ALTER TABLE contacts ADD COLUMN display_name TEXT NOT NULL DEFAULT "";
UPDATE contacts SET display_name = "";

View file

@ -482,6 +482,7 @@ func (db sqlitePersistence) Contacts() ([]*Contact, error) {
v.name,
v.verified,
c.alias,
c.display_name,
c.identicon,
c.last_updated,
c.last_updated_locally,
@ -506,6 +507,7 @@ func (db sqlitePersistence) Contacts() ([]*Contact, error) {
var (
contact Contact
nickname sql.NullString
displayName sql.NullString
imageType sql.NullString
ensName sql.NullString
ensVerified sql.NullBool
@ -525,6 +527,7 @@ func (db sqlitePersistence) Contacts() ([]*Contact, error) {
&ensName,
&ensVerified,
&contact.Alias,
&displayName,
&contact.Identicon,
&contact.LastUpdated,
&lastUpdatedLocally,
@ -544,8 +547,12 @@ func (db sqlitePersistence) Contacts() ([]*Contact, error) {
contact.LocalNickname = nickname.String
}
if displayName.Valid {
contact.DisplayName = displayName.String
}
if ensName.Valid {
contact.Name = ensName.String
contact.EnsName = ensName.String
}
if ensVerified.Valid {
@ -710,6 +717,7 @@ func (db sqlitePersistence) SaveContact(contact *Contact, tx *sql.Tx) (err error
id,
address,
alias,
display_name,
identicon,
last_updated,
last_updated_locally,
@ -721,7 +729,7 @@ func (db sqlitePersistence) SaveContact(contact *Contact, tx *sql.Tx) (err error
name,
photo,
tribute_to_talk
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`)
if err != nil {
return
@ -732,6 +740,7 @@ func (db sqlitePersistence) SaveContact(contact *Contact, tx *sql.Tx) (err error
contact.ID,
contact.Address,
contact.Alias,
contact.DisplayName,
contact.Identicon,
contact.LastUpdated,
contact.LastUpdatedLocally,

View file

@ -62,7 +62,7 @@ type ChatIdentity struct {
EnsName string `protobuf:"bytes,2,opt,name=ens_name,json=ensName,proto3" json:"ens_name,omitempty"`
// images is a string indexed mapping of images associated with an identity
Images map[string]*IdentityImage `protobuf:"bytes,3,rep,name=images,proto3" json:"images,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// display name is the user set identity, valid only for organisations
// display name is the user set identity
DisplayName string `protobuf:"bytes,4,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
// description is the user set description, valid only for organisations
Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"`

View file

@ -16,7 +16,7 @@ message ChatIdentity {
// images is a string indexed mapping of images associated with an identity
map<string, IdentityImage> images = 3;
// display name is the user set identity, valid only for organisations
// display name is the user set identity
string display_name = 4;
// description is the user set description, valid only for organisations

View file

@ -434,7 +434,9 @@ type ChatMessage struct {
// *ChatMessage_Community
Payload isChatMessage_Payload `protobuf_oneof:"payload"`
// Grant for community chat messages
Grant []byte `protobuf:"bytes,13,opt,name=grant,proto3" json:"grant,omitempty"`
Grant []byte `protobuf:"bytes,13,opt,name=grant,proto3" json:"grant,omitempty"`
// Message author's display name, introduced in version 1
DisplayName string `protobuf:"bytes,14,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -591,6 +593,13 @@ func (m *ChatMessage) GetGrant() []byte {
return nil
}
func (m *ChatMessage) GetDisplayName() string {
if m != nil {
return m.DisplayName
}
return ""
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*ChatMessage) XXX_OneofWrappers() []interface{} {
return []interface{}{
@ -617,50 +626,51 @@ func init() {
}
var fileDescriptor_263952f55fd35689 = []byte{
// 719 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0x9b, 0x48,
0x14, 0x0e, 0x36, 0x18, 0xf3, 0xb0, 0x23, 0x34, 0xc9, 0x26, 0xec, 0x6a, 0x77, 0xe3, 0xb5, 0x56,
0x5a, 0x9f, 0xbc, 0x52, 0x9a, 0x4a, 0x91, 0x7a, 0x22, 0x36, 0x72, 0x68, 0x0a, 0x76, 0x07, 0xdc,
0x36, 0xbd, 0x20, 0x82, 0xa7, 0x31, 0x4a, 0x00, 0xcb, 0x8c, 0xa5, 0xfa, 0x47, 0xf5, 0xda, 0x6b,
0x7f, 0x48, 0x0f, 0xfd, 0x2b, 0xd5, 0x0c, 0xc6, 0x10, 0x4b, 0x4d, 0x72, 0xe2, 0xbd, 0xc7, 0xfb,
0xbe, 0xf9, 0xe6, 0x9b, 0x79, 0x03, 0x28, 0x9c, 0x07, 0xd4, 0x8f, 0x49, 0x96, 0x05, 0xb7, 0xa4,
0xbf, 0x58, 0xa6, 0x34, 0x45, 0x4d, 0xfe, 0xb9, 0x59, 0x7d, 0xfa, 0x43, 0x25, 0xc9, 0x2a, 0xce,
0xf2, 0x72, 0xf7, 0x1c, 0xf6, 0x5d, 0x1a, 0x85, 0x77, 0x64, 0x69, 0xe7, 0xed, 0x08, 0x81, 0x38,
0x0f, 0xb2, 0xb9, 0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 0x44, 0x83, 0x0b,
0x65, 0xfb, 0xe0, 0x5d, 0xb4, 0x3f, 0xaa, 0xfd, 0xff, 0x5f, 0x15, 0x1e, 0xde, 0x34, 0x78, 0xf4,
0xe2, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xb9, 0xa5, 0x8e, 0xdc, 0x05, 0x00, 0x00,
// 734 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0xc3, 0x44,
0x10, 0xad, 0x13, 0x27, 0x8e, 0xc7, 0x49, 0x64, 0x6d, 0x4b, 0x6b, 0x10, 0xd0, 0x34, 0x42, 0x22,
0xa7, 0x20, 0x95, 0x22, 0x55, 0xe2, 0xe4, 0x26, 0x56, 0x6a, 0x8a, 0x9d, 0xb0, 0x76, 0x80, 0x72,
0xb1, 0x5c, 0x7b, 0x69, 0xac, 0xc6, 0x1f, 0x8a, 0x37, 0x12, 0xb9, 0xf2, 0x7f, 0xb8, 0x72, 0xe5,
0x87, 0xf0, 0x67, 0xd0, 0xae, 0xe3, 0xd8, 0x8d, 0x44, 0xdb, 0x53, 0x66, 0x26, 0xf3, 0x9e, 0xdf,
0xbe, 0xd9, 0x59, 0x40, 0xc1, 0xca, 0xa7, 0x5e, 0x4c, 0xf2, 0xdc, 0x7f, 0x26, 0xe3, 0x6c, 0x93,
0xd2, 0x14, 0x75, 0xf8, 0xcf, 0xd3, 0xf6, 0xf7, 0xcf, 0x14, 0x92, 0x6c, 0xe3, 0xbc, 0x28, 0x0f,
0x6f, 0xa1, 0xef, 0xd0, 0x28, 0x78, 0x21, 0x1b, 0xab, 0x68, 0x47, 0x08, 0xc4, 0x95, 0x9f, 0xaf,
0x34, 0x61, 0x20, 0x8c, 0x64, 0xcc, 0x63, 0x56, 0xcb, 0xfc, 0xe0, 0x45, 0x6b, 0x0c, 0x84, 0x51,
0x0b, 0xf3, 0x78, 0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1, 0xc2, 0x9d, 0x7c,
0x78, 0x13, 0xef, 0x7a, 0xbf, 0x29, 0xe3, 0x6f, 0xbe, 0x2f, 0x6d, 0x7e, 0x6a, 0xf3, 0xe8, 0xdb,
0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x91, 0x87, 0x42, 0xf9, 0xff, 0x05, 0x00, 0x00,
}

View file

@ -88,6 +88,9 @@ message ChatMessage {
// Grant for community chat messages
bytes grant = 13;
// Message author's display name, introduced in version 1
string display_name = 14;
enum ContentType {
UNKNOWN_CONTENT_TYPE = 0;
TEXT_PLAIN = 1;
@ -103,4 +106,6 @@ message ChatMessage {
// Only local
SYSTEM_MESSAGE_GAP = 10;
}
}

View file

@ -24,6 +24,7 @@ type ContactUpdate struct {
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
EnsName string `protobuf:"bytes,2,opt,name=ens_name,json=ensName,proto3" json:"ens_name,omitempty"`
ProfileImage string `protobuf:"bytes,3,opt,name=profile_image,json=profileImage,proto3" json:"profile_image,omitempty"`
DisplayName string `protobuf:"bytes,4,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -75,6 +76,13 @@ func (m *ContactUpdate) GetProfileImage() string {
return ""
}
func (m *ContactUpdate) GetDisplayName() string {
if m != nil {
return m.DisplayName
}
return ""
}
func init() {
proto.RegisterType((*ContactUpdate)(nil), "protobuf.ContactUpdate")
}
@ -84,14 +92,16 @@ func init() {
}
var fileDescriptor_a5036fff2565fb15 = []byte{
// 144 bytes of a gzipped FileDescriptorProto
// 166 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0xce, 0xcf, 0x2b,
0x49, 0x4c, 0x2e, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x00, 0x53, 0x49, 0xa5, 0x69,
0x4a, 0xa9, 0x5c, 0xbc, 0xce, 0x10, 0xa9, 0xd0, 0x82, 0x94, 0xc4, 0x92, 0x54, 0x21, 0x11, 0x2e,
0xd6, 0xe4, 0x9c, 0xfc, 0xe4, 0x6c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, 0x20, 0x08, 0x47, 0x48,
0x92, 0x8b, 0x23, 0x35, 0xaf, 0x38, 0x3e, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49, 0x81, 0x51, 0x83,
0x33, 0x88, 0x3d, 0x35, 0xaf, 0xd8, 0x2f, 0x31, 0x37, 0x55, 0x48, 0x99, 0x8b, 0xb7, 0xa0, 0x28,
0x3f, 0x2d, 0x33, 0x27, 0x35, 0x3e, 0x33, 0x37, 0x31, 0x3d, 0x55, 0x82, 0x19, 0x2c, 0xcf, 0x03,
0x15, 0xf4, 0x04, 0x89, 0x39, 0xf1, 0x46, 0x71, 0xeb, 0xe9, 0x5b, 0xc3, 0x6c, 0x4d, 0x62, 0x03,
0xb3, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x78, 0x67, 0xeb, 0x60, 0x97, 0x00, 0x00, 0x00,
0x4a, 0x1d, 0x8c, 0x5c, 0xbc, 0xce, 0x10, 0xb9, 0xd0, 0x82, 0x94, 0xc4, 0x92, 0x54, 0x21, 0x11,
0x2e, 0xd6, 0xe4, 0x9c, 0xfc, 0xe4, 0x6c, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x96, 0x20, 0x08, 0x47,
0x48, 0x92, 0x8b, 0x23, 0x35, 0xaf, 0x38, 0x3e, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x49, 0x81, 0x51,
0x83, 0x33, 0x88, 0x3d, 0x35, 0xaf, 0xd8, 0x2f, 0x31, 0x37, 0x55, 0x48, 0x99, 0x8b, 0xb7, 0xa0,
0x28, 0x3f, 0x2d, 0x33, 0x27, 0x35, 0x3e, 0x33, 0x37, 0x31, 0x3d, 0x55, 0x82, 0x19, 0x2c, 0xcf,
0x03, 0x15, 0xf4, 0x04, 0x89, 0x09, 0x29, 0x72, 0xf1, 0xa4, 0x64, 0x16, 0x17, 0xe4, 0x24, 0x56,
0x42, 0xcc, 0x60, 0x01, 0xab, 0xe1, 0x86, 0x8a, 0x81, 0xcc, 0x71, 0xe2, 0x8d, 0xe2, 0xd6, 0xd3,
0xb7, 0x86, 0xb9, 0x2c, 0x89, 0x0d, 0xcc, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd0, 0xfa,
0xcb, 0x28, 0xbb, 0x00, 0x00, 0x00,
}

View file

@ -7,4 +7,5 @@ message ContactUpdate {
uint64 clock = 1;
string ens_name = 2;
string profile_image = 3;
string display_name = 4;
}

View file

@ -295,9 +295,9 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationFromContactO
// Add alice has a contact
aliceContact := &Contact{
ID: types.EncodeHex(crypto.FromECDSAPub(&alice.identity.PublicKey)),
Name: "Some Contact",
Added: true,
ID: types.EncodeHex(crypto.FromECDSAPub(&alice.identity.PublicKey)),
EnsName: "Some Contact",
Added: true,
}
_, err = bob.AddContact(context.Background(), &requests.AddContact{ID: types.Hex2Bytes(aliceContact.ID)})
@ -441,9 +441,9 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationRetries() {
// Add alice has a contact
aliceContact := &Contact{
ID: types.EncodeHex(crypto.FromECDSAPub(&alice.identity.PublicKey)),
Name: "Some Contact",
Added: true,
ID: types.EncodeHex(crypto.FromECDSAPub(&alice.identity.PublicKey)),
EnsName: "Some Contact",
Added: true,
}
_, err = bob.AddContact(context.Background(), &requests.AddContact{ID: types.Hex2Bytes(aliceContact.ID)})
@ -451,9 +451,9 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationRetries() {
// Add frank has a contact
frankContact := &Contact{
ID: types.EncodeHex(crypto.FromECDSAPub(&frank.identity.PublicKey)),
Name: "Some Contact",
Added: true,
ID: types.EncodeHex(crypto.FromECDSAPub(&frank.identity.PublicKey)),
EnsName: "Some Contact",
Added: true,
}
_, err = bob.AddContact(context.Background(), &requests.AddContact{ID: types.Hex2Bytes(frankContact.ID)})
@ -539,8 +539,8 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationRetries() {
// The message has been sent, but not received, now we remove a contact so that the token is invalidated
frankContact = &Contact{
ID: types.EncodeHex(crypto.FromECDSAPub(&frank.identity.PublicKey)),
Name: "Some Contact",
ID: types.EncodeHex(crypto.FromECDSAPub(&frank.identity.PublicKey)),
EnsName: "Some Contact",
}
_, err = bob.RemoveContact(context.Background(), frankContact.ID)
s.Require().NoError(err)

View file

@ -9,9 +9,10 @@ import (
var ErrAddContactInvalidID = errors.New("add-contact: invalid id")
type AddContact struct {
ID types.HexBytes `json:"id"`
Nickname string `json:"nickname"`
ENSName string `json:"ensName"`
ID types.HexBytes `json:"id"`
Nickname string `json:"nickname"`
DisplayName string `json:"displayName"`
ENSName string `json:"ensName"`
}
func (a *AddContact) Validate() error {

View file

@ -683,6 +683,10 @@ func (api *PublicAPI) SendContactUpdate(ctx context.Context, contactID, name, pi
return api.service.messenger.SendContactUpdate(ctx, contactID, name, picture)
}
func (api *PublicAPI) SetDisplayName(ctx context.Context, displayName string) error {
return api.service.messenger.SetDisplayName(displayName)
}
func (api *PublicAPI) SendPairInstallation(ctx context.Context) (*protocol.MessengerResponse, error) {
return api.service.messenger.SendPairInstallation(ctx)
}