diff --git a/protocol/identity/profile_showcase.go b/protocol/identity/profile_showcase.go index e6fb9198614..99b35ea1b60 100644 --- a/protocol/identity/profile_showcase.go +++ b/protocol/identity/profile_showcase.go @@ -2,16 +2,34 @@ package identity import "reflect" -type VisibleProfileShowcaseEntry struct { - EntryID string `json:"entryId"` +type ProfileShowcaseCommunity struct { + CommunityID string `json:"communityId"` + Order int `json:"order"` +} + +type ProfileShowcaseAccount struct { + Address string `json:"address"` + Name string `json:"name"` + ColorID string `json:"colorId"` + Emoji string `json:"emoji"` Order int `json:"order"` } +type ProfileShowcaseCollectible struct { + UID string `json:"uid"` + Order int `json:"order"` +} + +type ProfileShowcaseAsset struct { + Symbol string `json:"symbol"` + Order int `json:"order"` +} + type ProfileShowcase struct { - Communities []*VisibleProfileShowcaseEntry `json:"communities"` - Accounts []*VisibleProfileShowcaseEntry `json:"accounts"` - Collectibles []*VisibleProfileShowcaseEntry `json:"collectibles"` - Assets []*VisibleProfileShowcaseEntry `json:"assets"` + Communities []*ProfileShowcaseCommunity `json:"communities"` + Accounts []*ProfileShowcaseAccount `json:"accounts"` + Collectibles []*ProfileShowcaseCollectible `json:"collectibles"` + Assets []*ProfileShowcaseAsset `json:"assets"` } func (p1 ProfileShowcase) Equal(p2 ProfileShowcase) bool { diff --git a/protocol/messenger_profile_showcase.go b/protocol/messenger_profile_showcase.go index 6593d225b71..5edc28d21d1 100644 --- a/protocol/messenger_profile_showcase.go +++ b/protocol/messenger_profile_showcase.go @@ -4,126 +4,137 @@ import ( "crypto/ecdsa" crand "crypto/rand" "errors" - "fmt" "google.golang.org/protobuf/proto" + "github.com/status-im/status-go/eth-node/crypto" + "github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/protocol/common" "github.com/status-im/status-go/protocol/identity" "github.com/status-im/status-go/protocol/protobuf" ) -type ProfileShowcasePreferences struct { - Communities []*ProfileShowcaseEntry `json:"communities"` - Accounts []*ProfileShowcaseEntry `json:"accounts"` - Collectibles []*ProfileShowcaseEntry `json:"collectibles"` - Assets []*ProfileShowcaseEntry `json:"assets"` -} - -func toProfileShowcaseUpdateEntries(entries []*ProfileShowcaseEntry, visibility ProfileShowcaseVisibility) []*protobuf.ProfileShowcaseEntry { - result := []*protobuf.ProfileShowcaseEntry{} - - for _, entry := range entries { - if entry.ShowcaseVisibility != visibility { +func toProfileShowcaseCommunityProto(preferences []*ProfileShowcaseCommunityPreference, visibility ProfileShowcaseVisibility) []*protobuf.ProfileShowcaseCommunity { + communities := []*protobuf.ProfileShowcaseCommunity{} + for _, preference := range preferences { + if preference.ShowcaseVisibility != visibility { continue } - update := &protobuf.ProfileShowcaseEntry{ - EntryId: entry.ID, - Order: uint32(entry.Order), - } - result = append(result, update) - } - return result -} -func fromProfileShowcaseUpdateEntries(messages []*protobuf.ProfileShowcaseEntry) []*identity.VisibleProfileShowcaseEntry { - entries := []*identity.VisibleProfileShowcaseEntry{} - for _, entry := range messages { - entries = append(entries, &identity.VisibleProfileShowcaseEntry{ - EntryID: entry.EntryId, - Order: int(entry.Order), + communities = append(communities, &protobuf.ProfileShowcaseCommunity{ + CommunityId: preference.CommunityID, + Order: uint32(preference.Order), }) } - return entries + return communities } -func (p *ProfileShowcasePreferences) Validate() error { - for _, community := range p.Communities { - if community.EntryType != ProfileShowcaseEntryTypeCommunity { - return fmt.Errorf("communities must contain only entriers of type ProfileShowcaseEntryTypeCommunity") +func toProfileShowcaseAccountProto(preferences []*ProfileShowcaseAccountPreference, visibility ProfileShowcaseVisibility) []*protobuf.ProfileShowcaseAccount { + accounts := []*protobuf.ProfileShowcaseAccount{} + for _, preference := range preferences { + if preference.ShowcaseVisibility != visibility { + continue } - } - for _, community := range p.Accounts { - if community.EntryType != ProfileShowcaseEntryTypeAccount { - return fmt.Errorf("accounts must contain only entriers of type ProfileShowcaseEntryTypeAccount") - } + accounts = append(accounts, &protobuf.ProfileShowcaseAccount{ + Address: preference.Address, + Name: preference.Name, + ColorId: preference.ColorID, + Emoji: preference.Emoji, + Order: uint32(preference.Order), + }) } + return accounts +} - for _, community := range p.Collectibles { - if community.EntryType != ProfileShowcaseEntryTypeCollectible { - return fmt.Errorf("collectibles must contain only entriers of type ProfileShowcaseEntryTypeCollectible") +func toProfileShowcaseCollectibleProto(preferences []*ProfileShowcaseCollectiblePreference, visibility ProfileShowcaseVisibility) []*protobuf.ProfileShowcaseCollectible { + collectibles := []*protobuf.ProfileShowcaseCollectible{} + for _, preference := range preferences { + if preference.ShowcaseVisibility != visibility { + continue } + + collectibles = append(collectibles, &protobuf.ProfileShowcaseCollectible{ + Uid: preference.UID, + Order: uint32(preference.Order), + }) } + return collectibles +} - for _, community := range p.Assets { - if community.EntryType != ProfileShowcaseEntryTypeAsset { - return fmt.Errorf("assets must contain only entriers of type ProfileShowcaseEntryTypeAsset") +func toProfileShowcaseAssetProto(preferences []*ProfileShowcaseAssetPreference, visibility ProfileShowcaseVisibility) []*protobuf.ProfileShowcaseAsset { + assets := []*protobuf.ProfileShowcaseAsset{} + for _, preference := range preferences { + if preference.ShowcaseVisibility != visibility { + continue } + + assets = append(assets, &protobuf.ProfileShowcaseAsset{ + Symbol: preference.Symbol, + Order: uint32(preference.Order), + }) } - return nil + return assets } -func (m *Messenger) SetProfileShowcasePreferences(preferences ProfileShowcasePreferences) error { - err := preferences.Validate() - if err != nil { - return err +func fromProfileShowcaseCommunityProto(messages []*protobuf.ProfileShowcaseCommunity) []*identity.ProfileShowcaseCommunity { + communities := []*identity.ProfileShowcaseCommunity{} + for _, entry := range messages { + communities = append(communities, &identity.ProfileShowcaseCommunity{ + CommunityID: entry.CommunityId, + Order: int(entry.Order), + }) } + return communities +} - allPreferences := []*ProfileShowcaseEntry{} - - allPreferences = append(allPreferences, preferences.Communities...) - allPreferences = append(allPreferences, preferences.Accounts...) - allPreferences = append(allPreferences, preferences.Collectibles...) - allPreferences = append(allPreferences, preferences.Assets...) - - err = m.persistence.SaveProfileShowcasePreferences(allPreferences) - if err != nil { - return err +func fromProfileShowcaseAccountProto(messages []*protobuf.ProfileShowcaseAccount) []*identity.ProfileShowcaseAccount { + accounts := []*identity.ProfileShowcaseAccount{} + for _, entry := range messages { + accounts = append(accounts, &identity.ProfileShowcaseAccount{ + Address: entry.Address, + Name: entry.Name, + ColorID: entry.ColorId, + Emoji: entry.Emoji, + Order: int(entry.Order), + }) } - - return m.publishContactCode() + return accounts } -func (m *Messenger) GetProfileShowcasePreferences() (*ProfileShowcasePreferences, error) { - // NOTE: in the future default profile preferences should be filled in for each group according to special rules, - // that's why they should be grouped here - communities, err := m.persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeCommunity) - if err != nil { - return nil, err +func fromProfileShowcaseCollectibleProto(messages []*protobuf.ProfileShowcaseCollectible) []*identity.ProfileShowcaseCollectible { + collectibles := []*identity.ProfileShowcaseCollectible{} + for _, entry := range messages { + collectibles = append(collectibles, &identity.ProfileShowcaseCollectible{ + UID: entry.Uid, + Order: int(entry.Order), + }) } + return collectibles +} - accounts, err := m.persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeAccount) - if err != nil { - return nil, err +func fromProfileShowcaseAssetProto(messages []*protobuf.ProfileShowcaseAsset) []*identity.ProfileShowcaseAsset { + assets := []*identity.ProfileShowcaseAsset{} + for _, entry := range messages { + assets = append(assets, &identity.ProfileShowcaseAsset{ + Symbol: entry.Symbol, + Order: int(entry.Order), + }) } + return assets +} - collectibles, err := m.persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeCollectible) +func (m *Messenger) SetProfileShowcasePreferences(preferences *ProfileShowcasePreferences) error { + err := m.persistence.SaveProfileShowcasePreferences(preferences) if err != nil { - return nil, err + return err } - assets, err := m.persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeAsset) - if err != nil { - return nil, err - } + return m.publishContactCode() +} - return &ProfileShowcasePreferences{ - Communities: communities, - Accounts: accounts, - Collectibles: collectibles, - Assets: assets, - }, nil +func (m *Messenger) GetProfileShowcasePreferences() (*ProfileShowcasePreferences, error) { + return m.persistence.GetProfileShowcasePreferences() } func (m *Messenger) EncryptProfileShowcaseEntriesWithContactPubKeys(entries *protobuf.ProfileShowcaseEntries, contacts []*Contact) (*protobuf.ProfileShowcaseEntriesEncrypted, error) { @@ -223,24 +234,24 @@ func (m *Messenger) GetProfileShowcaseForSelfIdentity() (*protobuf.ProfileShowca } forEveryone := &protobuf.ProfileShowcaseEntries{ - Communities: toProfileShowcaseUpdateEntries(preferences.Communities, ProfileShowcaseVisibilityEveryone), - Accounts: toProfileShowcaseUpdateEntries(preferences.Accounts, ProfileShowcaseVisibilityEveryone), - Collectibles: toProfileShowcaseUpdateEntries(preferences.Collectibles, ProfileShowcaseVisibilityEveryone), - Assets: toProfileShowcaseUpdateEntries(preferences.Assets, ProfileShowcaseVisibilityEveryone), + Communities: toProfileShowcaseCommunityProto(preferences.Communities, ProfileShowcaseVisibilityEveryone), + Accounts: toProfileShowcaseAccountProto(preferences.Accounts, ProfileShowcaseVisibilityEveryone), + Collectibles: toProfileShowcaseCollectibleProto(preferences.Collectibles, ProfileShowcaseVisibilityEveryone), + Assets: toProfileShowcaseAssetProto(preferences.Assets, ProfileShowcaseVisibilityEveryone), } forContacts := &protobuf.ProfileShowcaseEntries{ - Communities: toProfileShowcaseUpdateEntries(preferences.Communities, ProfileShowcaseVisibilityContacts), - Accounts: toProfileShowcaseUpdateEntries(preferences.Accounts, ProfileShowcaseVisibilityContacts), - Collectibles: toProfileShowcaseUpdateEntries(preferences.Collectibles, ProfileShowcaseVisibilityContacts), - Assets: toProfileShowcaseUpdateEntries(preferences.Assets, ProfileShowcaseVisibilityContacts), + Communities: toProfileShowcaseCommunityProto(preferences.Communities, ProfileShowcaseVisibilityContacts), + Accounts: toProfileShowcaseAccountProto(preferences.Accounts, ProfileShowcaseVisibilityContacts), + Collectibles: toProfileShowcaseCollectibleProto(preferences.Collectibles, ProfileShowcaseVisibilityContacts), + Assets: toProfileShowcaseAssetProto(preferences.Assets, ProfileShowcaseVisibilityContacts), } forIDVerifiedContacts := &protobuf.ProfileShowcaseEntries{ - Communities: toProfileShowcaseUpdateEntries(preferences.Communities, ProfileShowcaseVisibilityIDVerifiedContacts), - Accounts: toProfileShowcaseUpdateEntries(preferences.Accounts, ProfileShowcaseVisibilityIDVerifiedContacts), - Collectibles: toProfileShowcaseUpdateEntries(preferences.Collectibles, ProfileShowcaseVisibilityIDVerifiedContacts), - Assets: toProfileShowcaseUpdateEntries(preferences.Assets, ProfileShowcaseVisibilityIDVerifiedContacts), + Communities: toProfileShowcaseCommunityProto(preferences.Communities, ProfileShowcaseVisibilityIDVerifiedContacts), + Accounts: toProfileShowcaseAccountProto(preferences.Accounts, ProfileShowcaseVisibilityIDVerifiedContacts), + Collectibles: toProfileShowcaseCollectibleProto(preferences.Collectibles, ProfileShowcaseVisibilityIDVerifiedContacts), + Assets: toProfileShowcaseAssetProto(preferences.Assets, ProfileShowcaseVisibilityIDVerifiedContacts), } mutualContacts := []*Contact{} @@ -274,15 +285,15 @@ func (m *Messenger) GetProfileShowcaseForSelfIdentity() (*protobuf.ProfileShowca } func (m *Messenger) BuildProfileShowcaseFromIdentity(senderPubKey *ecdsa.PublicKey, message *protobuf.ProfileShowcase) (*identity.ProfileShowcase, error) { - communities := []*identity.VisibleProfileShowcaseEntry{} - accounts := []*identity.VisibleProfileShowcaseEntry{} - collectibles := []*identity.VisibleProfileShowcaseEntry{} - assets := []*identity.VisibleProfileShowcaseEntry{} + communities := []*identity.ProfileShowcaseCommunity{} + accounts := []*identity.ProfileShowcaseAccount{} + collectibles := []*identity.ProfileShowcaseCollectible{} + assets := []*identity.ProfileShowcaseAsset{} - communities = append(communities, fromProfileShowcaseUpdateEntries(message.ForEveryone.Communities)...) - accounts = append(accounts, fromProfileShowcaseUpdateEntries(message.ForEveryone.Accounts)...) - collectibles = append(collectibles, fromProfileShowcaseUpdateEntries(message.ForEveryone.Collectibles)...) - assets = append(assets, fromProfileShowcaseUpdateEntries(message.ForEveryone.Assets)...) + communities = append(communities, fromProfileShowcaseCommunityProto(message.ForEveryone.Communities)...) + accounts = append(accounts, fromProfileShowcaseAccountProto(message.ForEveryone.Accounts)...) + collectibles = append(collectibles, fromProfileShowcaseCollectibleProto(message.ForEveryone.Collectibles)...) + assets = append(assets, fromProfileShowcaseAssetProto(message.ForEveryone.Assets)...) forContacts, err := m.DecryptProfileShowcaseEntriesWithContactPubKeys(senderPubKey, message.ForContacts) if err != nil { @@ -290,10 +301,10 @@ func (m *Messenger) BuildProfileShowcaseFromIdentity(senderPubKey *ecdsa.PublicK } if forContacts != nil { - communities = append(communities, fromProfileShowcaseUpdateEntries(forContacts.Communities)...) - accounts = append(accounts, fromProfileShowcaseUpdateEntries(forContacts.Accounts)...) - collectibles = append(collectibles, fromProfileShowcaseUpdateEntries(forContacts.Collectibles)...) - assets = append(assets, fromProfileShowcaseUpdateEntries(forContacts.Assets)...) + communities = append(communities, fromProfileShowcaseCommunityProto(forContacts.Communities)...) + accounts = append(accounts, fromProfileShowcaseAccountProto(forContacts.Accounts)...) + collectibles = append(collectibles, fromProfileShowcaseCollectibleProto(forContacts.Collectibles)...) + assets = append(assets, fromProfileShowcaseAssetProto(forContacts.Assets)...) } forIDVerifiedContacts, err := m.DecryptProfileShowcaseEntriesWithContactPubKeys(senderPubKey, message.ForIdVerifiedContacts) @@ -302,16 +313,30 @@ func (m *Messenger) BuildProfileShowcaseFromIdentity(senderPubKey *ecdsa.PublicK } if forIDVerifiedContacts != nil { - communities = append(communities, fromProfileShowcaseUpdateEntries(forIDVerifiedContacts.Communities)...) - accounts = append(accounts, fromProfileShowcaseUpdateEntries(forIDVerifiedContacts.Accounts)...) - collectibles = append(collectibles, fromProfileShowcaseUpdateEntries(forIDVerifiedContacts.Collectibles)...) - assets = append(assets, fromProfileShowcaseUpdateEntries(forIDVerifiedContacts.Assets)...) + communities = append(communities, fromProfileShowcaseCommunityProto(forIDVerifiedContacts.Communities)...) + accounts = append(accounts, fromProfileShowcaseAccountProto(forIDVerifiedContacts.Accounts)...) + collectibles = append(collectibles, fromProfileShowcaseCollectibleProto(forIDVerifiedContacts.Collectibles)...) + assets = append(assets, fromProfileShowcaseAssetProto(forIDVerifiedContacts.Assets)...) } - return &identity.ProfileShowcase{ + showcase := &identity.ProfileShowcase{ Communities: communities, Accounts: accounts, Collectibles: collectibles, Assets: assets, - }, nil + } + + contactID := types.EncodeHex(crypto.FromECDSAPub(senderPubKey)) + + err = m.persistence.ClearProfileShowcaseForContact(contactID) + if err != nil { + return nil, err + } + + err = m.persistence.SaveProfileShowcaseForContact(contactID, showcase) + if err != nil { + return nil, err + } + + return showcase, nil } diff --git a/protocol/messenger_profile_showcase_test.go b/protocol/messenger_profile_showcase_test.go index 1354c3de08d..7a75c5310cb 100644 --- a/protocol/messenger_profile_showcase_test.go +++ b/protocol/messenger_profile_showcase_test.go @@ -150,57 +150,52 @@ func (s *TestMessengerProfileShowcase) verifiedContact(theirMessenger *Messenger s.Require().Equal(common.ContactVerificationStateTrusted, resp.Messages()[0].ContactVerificationState) } -func (s *TestMessengerProfileShowcase) prepareShowcasePreferences() ProfileShowcasePreferences { - communityEntry1 := &ProfileShowcaseEntry{ - ID: "0x01312357798976434", - EntryType: ProfileShowcaseEntryTypeCommunity, +func (s *TestMessengerProfileShowcase) prepareShowcasePreferences() *ProfileShowcasePreferences { + communityEntry1 := &ProfileShowcaseCommunityPreference{ + CommunityID: "0x01312357798976434", ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, Order: 10, } - communityEntry2 := &ProfileShowcaseEntry{ - ID: "0x01312357798976535", - EntryType: ProfileShowcaseEntryTypeCommunity, + communityEntry2 := &ProfileShowcaseCommunityPreference{ + CommunityID: "0x01312357798976535", ShowcaseVisibility: ProfileShowcaseVisibilityContacts, Order: 11, } - communityEntry3 := &ProfileShowcaseEntry{ - ID: "0x01312353452343552", - EntryType: ProfileShowcaseEntryTypeCommunity, + communityEntry3 := &ProfileShowcaseCommunityPreference{ + CommunityID: "0x01312353452343552", ShowcaseVisibility: ProfileShowcaseVisibilityIDVerifiedContacts, Order: 12, } - accountEntry := &ProfileShowcaseEntry{ - ID: "0cx34662234", - EntryType: ProfileShowcaseEntryTypeAccount, + accountEntry := &ProfileShowcaseAccountPreference{ + Address: "0cx34662234", + Name: "Status Account", + ColorID: "blue", + Emoji: ">:-]", ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, Order: 17, } - collectibleEntry := &ProfileShowcaseEntry{ - ID: "0x12378534257568678487683576", - EntryType: ProfileShowcaseEntryTypeCollectible, + collectibleEntry := &ProfileShowcaseCollectiblePreference{ + UID: "0x12378534257568678487683576", ShowcaseVisibility: ProfileShowcaseVisibilityIDVerifiedContacts, Order: 17, } - assetEntry := &ProfileShowcaseEntry{ - ID: "0x139ii4uu423", - EntryType: ProfileShowcaseEntryTypeAsset, + assetEntry := &ProfileShowcaseAssetPreference{ + Symbol: "SNT", ShowcaseVisibility: ProfileShowcaseVisibilityNoOne, Order: 17, } - request := ProfileShowcasePreferences{ - Communities: []*ProfileShowcaseEntry{communityEntry1, communityEntry2, communityEntry3}, - Accounts: []*ProfileShowcaseEntry{accountEntry}, - Collectibles: []*ProfileShowcaseEntry{collectibleEntry}, - Assets: []*ProfileShowcaseEntry{assetEntry}, + return &ProfileShowcasePreferences{ + Communities: []*ProfileShowcaseCommunityPreference{communityEntry1, communityEntry2, communityEntry3}, + Accounts: []*ProfileShowcaseAccountPreference{accountEntry}, + Collectibles: []*ProfileShowcaseCollectiblePreference{collectibleEntry}, + Assets: []*ProfileShowcaseAssetPreference{assetEntry}, } - - return request } func (s *TestMessengerProfileShowcase) TestSetAndGetProfileShowcasePreferences() { @@ -237,34 +232,37 @@ func (s *TestMessengerProfileShowcase) TestEncryptAndDecryptProfileShowcaseEntri s.mutualContact(theirMessenger) entries := &protobuf.ProfileShowcaseEntries{ - Communities: []*protobuf.ProfileShowcaseEntry{ - &protobuf.ProfileShowcaseEntry{ - EntryId: "0x01312357798976535235432345", - Order: 12, + Communities: []*protobuf.ProfileShowcaseCommunity{ + &protobuf.ProfileShowcaseCommunity{ + CommunityId: "0x01312357798976535235432345", + Order: 12, }, - &protobuf.ProfileShowcaseEntry{ - EntryId: "0x12378534257568678487683576", - Order: 11, + &protobuf.ProfileShowcaseCommunity{ + CommunityId: "0x12378534257568678487683576", + Order: 11, }, }, - Accounts: []*protobuf.ProfileShowcaseEntry{ - &protobuf.ProfileShowcaseEntry{ - EntryId: "0x00000323245", + Accounts: []*protobuf.ProfileShowcaseAccount{ + &protobuf.ProfileShowcaseAccount{ + Address: "0x00000323245", + Name: "Default", + ColorId: "red", + Emoji: "(=^ ◡ ^=)", Order: 1, }, }, - Assets: []*protobuf.ProfileShowcaseEntry{ - &protobuf.ProfileShowcaseEntry{ - EntryId: "ETH", - Order: 2, + Assets: []*protobuf.ProfileShowcaseAsset{ + &protobuf.ProfileShowcaseAsset{ + Symbol: "ETH", + Order: 2, }, - &protobuf.ProfileShowcaseEntry{ - EntryId: "DAI", - Order: 3, + &protobuf.ProfileShowcaseAsset{ + Symbol: "DAI", + Order: 3, }, - &protobuf.ProfileShowcaseEntry{ - EntryId: "SNT", - Order: 1, + &protobuf.ProfileShowcaseAsset{ + Symbol: "SNT", + Order: 1, }, }, } @@ -275,10 +273,27 @@ func (s *TestMessengerProfileShowcase) TestEncryptAndDecryptProfileShowcaseEntri s.Require().NoError(err) s.Require().Equal(2, len(entriesBack.Communities)) - s.Require().Equal(entries.Communities[0].EntryId, entriesBack.Communities[0].EntryId) + s.Require().Equal(entries.Communities[0].CommunityId, entriesBack.Communities[0].CommunityId) s.Require().Equal(entries.Communities[0].Order, entriesBack.Communities[0].Order) - s.Require().Equal(entries.Communities[1].EntryId, entriesBack.Communities[1].EntryId) + s.Require().Equal(entries.Communities[1].CommunityId, entriesBack.Communities[1].CommunityId) s.Require().Equal(entries.Communities[1].Order, entriesBack.Communities[1].Order) + + s.Require().Equal(1, len(entriesBack.Accounts)) + s.Require().Equal(entries.Accounts[0].Address, entriesBack.Accounts[0].Address) + s.Require().Equal(entries.Accounts[0].Name, entriesBack.Accounts[0].Name) + s.Require().Equal(entries.Accounts[0].ColorId, entriesBack.Accounts[0].ColorId) + s.Require().Equal(entries.Accounts[0].Emoji, entriesBack.Accounts[0].Emoji) + s.Require().Equal(entries.Accounts[0].Order, entriesBack.Accounts[0].Order) + + s.Require().Equal(0, len(entriesBack.Collectibles)) + + s.Require().Equal(3, len(entriesBack.Assets)) + s.Require().Equal(entries.Assets[0].Symbol, entriesBack.Assets[0].Symbol) + s.Require().Equal(entries.Assets[0].Order, entriesBack.Assets[0].Order) + s.Require().Equal(entries.Assets[1].Symbol, entriesBack.Assets[1].Symbol) + s.Require().Equal(entries.Assets[1].Order, entriesBack.Assets[1].Order) + s.Require().Equal(entries.Assets[2].Symbol, entriesBack.Assets[2].Symbol) + s.Require().Equal(entries.Assets[2].Order, entriesBack.Assets[2].Order) } func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() { @@ -328,16 +343,20 @@ func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() { profileShowcase := resp.Contacts[0].ProfileShowcase s.Require().Len(profileShowcase.Communities, 2) + // For everyone - s.Require().Equal(profileShowcase.Communities[0].EntryID, request.Communities[0].ID) + s.Require().Equal(profileShowcase.Communities[0].CommunityID, request.Communities[0].CommunityID) s.Require().Equal(profileShowcase.Communities[0].Order, request.Communities[0].Order) // For contacts - s.Require().Equal(profileShowcase.Communities[1].EntryID, request.Communities[1].ID) + s.Require().Equal(profileShowcase.Communities[1].CommunityID, request.Communities[1].CommunityID) s.Require().Equal(profileShowcase.Communities[1].Order, request.Communities[1].Order) s.Require().Len(profileShowcase.Accounts, 1) - s.Require().Equal(profileShowcase.Accounts[0].EntryID, request.Accounts[0].ID) + s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address) + s.Require().Equal(profileShowcase.Accounts[0].Name, request.Accounts[0].Name) + s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID) + s.Require().Equal(profileShowcase.Accounts[0].Emoji, request.Accounts[0].Emoji) s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order) s.Require().Len(profileShowcase.Collectibles, 0) @@ -357,24 +376,28 @@ func (s *TestMessengerProfileShowcase) TestShareShowcasePreferences() { profileShowcase = resp.Contacts[0].ProfileShowcase s.Require().Len(profileShowcase.Communities, 3) + // For everyone - s.Require().Equal(profileShowcase.Communities[0].EntryID, request.Communities[0].ID) + s.Require().Equal(profileShowcase.Communities[0].CommunityID, request.Communities[0].CommunityID) s.Require().Equal(profileShowcase.Communities[0].Order, request.Communities[0].Order) // For contacts - s.Require().Equal(profileShowcase.Communities[1].EntryID, request.Communities[1].ID) + s.Require().Equal(profileShowcase.Communities[1].CommunityID, request.Communities[1].CommunityID) s.Require().Equal(profileShowcase.Communities[1].Order, request.Communities[1].Order) // For id verified - s.Require().Equal(profileShowcase.Communities[2].EntryID, request.Communities[2].ID) + s.Require().Equal(profileShowcase.Communities[2].CommunityID, request.Communities[2].CommunityID) s.Require().Equal(profileShowcase.Communities[2].Order, request.Communities[2].Order) s.Require().Len(profileShowcase.Accounts, 1) - s.Require().Equal(profileShowcase.Accounts[0].EntryID, request.Accounts[0].ID) + s.Require().Equal(profileShowcase.Accounts[0].Address, request.Accounts[0].Address) + s.Require().Equal(profileShowcase.Accounts[0].Name, request.Accounts[0].Name) + s.Require().Equal(profileShowcase.Accounts[0].ColorID, request.Accounts[0].ColorID) + s.Require().Equal(profileShowcase.Accounts[0].Emoji, request.Accounts[0].Emoji) s.Require().Equal(profileShowcase.Accounts[0].Order, request.Accounts[0].Order) s.Require().Len(profileShowcase.Collectibles, 1) - s.Require().Equal(profileShowcase.Collectibles[0].EntryID, request.Collectibles[0].ID) + s.Require().Equal(profileShowcase.Collectibles[0].UID, request.Collectibles[0].UID) s.Require().Equal(profileShowcase.Collectibles[0].Order, request.Collectibles[0].Order) s.Require().Len(profileShowcase.Assets, 0) diff --git a/protocol/migrations/migrations.go b/protocol/migrations/migrations.go index f3a0be1c194..ff2f1467af2 100644 --- a/protocol/migrations/migrations.go +++ b/protocol/migrations/migrations.go @@ -109,7 +109,7 @@ // 1698137562_fix_encryption_key_id.up.sql (758B) // 1698414646_add_padding.up.sql (69B) // 1698746210_add_signature_to_revealed_addresses.up.sql (87B) -// 1698839882_profile_showcase_contacts.up.sql (240B) +// 1699041816_profile_showcase_contacts.up.sql (1.788kB) // README.md (554B) // doc.go (850B) @@ -2360,23 +2360,23 @@ func _1698746210_add_signature_to_revealed_addressesUpSql() (*asset, error) { return a, nil } -var __1698839882_profile_showcase_contactsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\x09\xf2\x0f\x50\x08\x71\x74\xf2\x71\x55\x28\x28\xca\x4f\xcb\xcc\x49\x8d\x2f\xce\xc8\x2f\x4f\x4e\x2c\x4e\x8d\x4f\xce\xcf\x2b\x49\x4c\x2e\x29\xb6\xe6\xe2\x72\x0e\x72\x75\x0c\x71\x25\xa4\x50\x41\x83\x4b\x41\x41\x41\x01\xca\x8d\xcf\x4c\x51\x08\x71\x8d\x08\x51\xf0\xf3\x0f\x51\xf0\x0b\xf5\xf1\xd1\x01\xcb\xa6\xe6\x95\x14\x55\xe2\x95\x2b\xa9\x2c\x48\x55\xf0\xf4\xc3\x2e\x99\x5f\x94\x92\x5a\x04\x96\x75\x71\x75\x73\x0c\xf5\x09\x51\x30\x80\x48\x07\x04\x79\xfa\x3a\x06\x45\x2a\x78\xbb\x46\x2a\x68\x20\x9c\xa0\x03\xb7\x50\x93\x4b\xd3\x9a\x0b\x10\x00\x00\xff\xff\x05\x86\x7c\xa2\xf0\x00\x00\x00") +var __1699041816_profile_showcase_contactsUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x93\xcd\x6e\xc2\x30\x0c\x80\xef\x7d\x0a\x8b\x13\x48\x20\xed\xce\xa9\x2b\x41\x43\xeb\x5a\x54\x85\x69\x9c\xaa\x92\x9a\x91\xa9\x6d\x50\x9c\x0e\xf1\xf6\x13\x94\x4c\xa5\xfc\x4c\x9d\x60\xda\xd9\x76\xfc\xd9\xce\x37\x8a\xc2\x29\x70\xf7\xd1\x67\xb0\xd6\x6a\x29\x33\x8c\x69\xa5\x36\x22\x21\x8c\xd7\x1a\x97\xa8\xb1\x10\x48\x43\xe7\x5a\xa2\x50\x85\x49\x84\xa1\xa1\xe3\x0c\x06\x30\x56\xa5\x06\x93\x2c\x32\x24\x58\x2a\x0d\x64\x94\x96\xc5\x3b\xa8\x4d\x61\x4b\xc1\x96\x42\xad\x87\xe3\x45\xcc\xe5\xec\x72\x93\x3c\x2f\x0b\x69\x24\x52\x9d\x0c\xba\x0e\x00\x80\x8d\x6e\x63\x99\x02\x67\x6f\x1c\xa6\xd1\xe4\xc5\x8d\xe6\xf0\xcc\xe6\x10\x06\xe0\x85\xc1\xd8\x9f\x78\x1c\x22\x36\xf5\x5d\x8f\xf5\xf7\x65\x9f\x92\xe4\x42\x66\xd2\x6c\x61\x12\x70\x08\x42\x0e\xc1\xcc\xf7\x61\xc4\xc6\xee\xcc\xe7\xf0\x50\xa5\x91\xd2\x26\x56\x3a\x45\xbd\x4f\xfb\x8e\x3a\xbd\xa1\xf3\x03\x76\x22\x84\x2a\x0b\x73\x8e\x39\x49\x53\x8d\x44\x2d\x70\x8b\x24\xc7\x2a\xdd\x22\x74\x3a\xfd\xc3\xfc\x99\xd2\xbb\xd9\x9b\x01\xcc\xd5\x87\x84\x57\x37\xf2\x9e\xdc\xe8\x24\x7a\xff\xf9\x85\xca\x32\x14\x46\xee\xbe\xc3\x99\x1d\x94\xff\xed\x5c\x44\x78\xf6\x58\xb4\xcd\x17\x2a\xfb\x63\xd6\x2b\x36\x9d\x98\xb4\x0b\x62\x22\x56\x70\xb0\xb1\x85\x4e\xd6\xdf\x8b\x2e\x59\xf8\xeb\xc8\xf6\x27\xee\x1f\xbb\x50\x5b\x5f\x5d\xb7\xde\xa8\x5f\x2b\xec\xb5\xf1\xaa\x01\x7f\x24\xd5\x71\xef\x9b\xdb\x73\xb3\x45\x1c\xa0\xdb\xee\xe0\xc8\xad\xc6\x1e\xca\x3b\xdf\xae\xfc\xc5\xc9\x2a\xb7\x1a\xa0\x75\xb1\xee\xc4\x5a\xb5\x38\xc1\xfd\x0a\x00\x00\xff\xff\x81\xb9\xed\xee\xfc\x06\x00\x00") -func _1698839882_profile_showcase_contactsUpSqlBytes() ([]byte, error) { +func _1699041816_profile_showcase_contactsUpSqlBytes() ([]byte, error) { return bindataRead( - __1698839882_profile_showcase_contactsUpSql, - "1698839882_profile_showcase_contacts.up.sql", + __1699041816_profile_showcase_contactsUpSql, + "1699041816_profile_showcase_contacts.up.sql", ) } -func _1698839882_profile_showcase_contactsUpSql() (*asset, error) { - bytes, err := _1698839882_profile_showcase_contactsUpSqlBytes() +func _1699041816_profile_showcase_contactsUpSql() (*asset, error) { + bytes, err := _1699041816_profile_showcase_contactsUpSqlBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "1698839882_profile_showcase_contacts.up.sql", size: 240, mode: os.FileMode(0644), modTime: time.Unix(1699003041, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xd5, 0x7a, 0xb4, 0x76, 0xcf, 0x34, 0x63, 0x6a, 0xd9, 0x62, 0xc9, 0x5d, 0x3e, 0x52, 0xa8, 0x45, 0xe0, 0xac, 0xf6, 0xe, 0x67, 0x6a, 0x44, 0x58, 0x49, 0xb6, 0x66, 0x1d, 0xef, 0x58, 0x4c, 0xde}} + info := bindataFileInfo{name: "1699041816_profile_showcase_contacts.up.sql", size: 1788, mode: os.FileMode(0644), modTime: time.Unix(1699054365, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2e, 0xaf, 0xf5, 0x76, 0x9b, 0x73, 0xe5, 0xc, 0xf1, 0x88, 0x35, 0xc7, 0xc0, 0x1, 0xb3, 0xc8, 0x2c, 0x72, 0x9f, 0x3d, 0xbb, 0x37, 0x3, 0xc, 0x99, 0x54, 0xaa, 0x36, 0xa7, 0x4f, 0x23, 0x9}} return a, nil } @@ -2729,7 +2729,7 @@ var _bindata = map[string]func() (*asset, error){ "1698746210_add_signature_to_revealed_addresses.up.sql": _1698746210_add_signature_to_revealed_addressesUpSql, - "1698839882_profile_showcase_contacts.up.sql": _1698839882_profile_showcase_contactsUpSql, + "1699041816_profile_showcase_contacts.up.sql": _1699041816_profile_showcase_contactsUpSql, "README.md": readmeMd, @@ -2886,7 +2886,7 @@ var _bintree = &bintree{nil, map[string]*bintree{ "1698137562_fix_encryption_key_id.up.sql": &bintree{_1698137562_fix_encryption_key_idUpSql, map[string]*bintree{}}, "1698414646_add_padding.up.sql": &bintree{_1698414646_add_paddingUpSql, map[string]*bintree{}}, "1698746210_add_signature_to_revealed_addresses.up.sql": &bintree{_1698746210_add_signature_to_revealed_addressesUpSql, map[string]*bintree{}}, - "1698839882_profile_showcase_contacts.up.sql": &bintree{_1698839882_profile_showcase_contactsUpSql, map[string]*bintree{}}, + "1699041816_profile_showcase_contacts.up.sql": &bintree{_1699041816_profile_showcase_contactsUpSql, map[string]*bintree{}}, "README.md": &bintree{readmeMd, map[string]*bintree{}}, "doc.go": &bintree{docGo, map[string]*bintree{}}, }} diff --git a/protocol/migrations/sqlite/1698839882_profile_showcase_contacts.up.sql b/protocol/migrations/sqlite/1698839882_profile_showcase_contacts.up.sql deleted file mode 100644 index 7565ea22592..00000000000 --- a/protocol/migrations/sqlite/1698839882_profile_showcase_contacts.up.sql +++ /dev/null @@ -1,9 +0,0 @@ -DROP TABLE profile_showcase_contacts; - -CREATE TABLE profile_showcase_contacts ( - contact_id TEXT NOT NULL, - entry_id TEXT NOT NULL, - entry_type INT NOT NULL, - entry_order INT DEFAULT 0, - PRIMARY KEY (contact_id, entry_id) -); diff --git a/protocol/migrations/sqlite/1699041816_profile_showcase_contacts.up.sql b/protocol/migrations/sqlite/1699041816_profile_showcase_contacts.up.sql new file mode 100644 index 00000000000..287d8a853c4 --- /dev/null +++ b/protocol/migrations/sqlite/1699041816_profile_showcase_contacts.up.sql @@ -0,0 +1,62 @@ +DROP TABLE profile_showcase_preferences; +DROP TABLE profile_showcase_contacts; + +-- Four tables for storing own profile showcase preferences +CREATE TABLE profile_showcase_communities_preferences ( + community_id TEXT PRIMARY KEY ON CONFLICT REPLACE, + visibility INT NOT NULL DEFAULT 0, + sort_order INT DEFAULT 0 +); + +CREATE TABLE profile_showcase_accounts_preferences ( + address TEXT PRIMARY KEY ON CONFLICT REPLACE, + name TEXT DEFAULT "", + color_id DEFAULT "", + emoji VARCHAR DEFAULT "", + visibility INT NOT NULL DEFAULT 0, + sort_order INT DEFAULT 0 +); + +CREATE TABLE profile_showcase_collectibles_preferences ( + uid TEXT PRIMARY KEY ON CONFLICT REPLACE, + visibility INT NOT NULL DEFAULT 0, + sort_order INT DEFAULT 0 +); + +CREATE TABLE profile_showcase_assets_preferences ( + symbol TEXT PRIMARY KEY ON CONFLICT REPLACE, + visibility INT NOT NULL DEFAULT 0, + sort_order INT DEFAULT 0 +); + +-- Four tables for storing profile showcase for each contact +CREATE TABLE profile_showcase_communities_contacts ( + community_id TEXT NOT NULL, + sort_order INT DEFAULT 0, + contact_id TEXT NOT NULL, + PRIMARY KEY (community_id, contact_id) +); + +CREATE TABLE profile_showcase_accounts_contacts ( + address TEXT NOT NULL, + name TEXT DEFAULT "", + color_id DEFAULT "", + emoji VARCHAR DEFAULT "", + sort_order INT DEFAULT 0, + contact_id TEXT NOT NULL, + PRIMARY KEY (address, contact_id) +); + +CREATE TABLE profile_showcase_collectibles_contacts ( + uid TEXT NOT NULL, + sort_order INT DEFAULT 0, + contact_id TEXT NOT NULL, + PRIMARY KEY (uid, contact_id) +); + +CREATE TABLE profile_showcase_assets_contacts ( + symbol TEXT NOT NULL, + sort_order INT DEFAULT 0, + contact_id TEXT NOT NULL, + PRIMARY KEY (symbol, contact_id) +); diff --git a/protocol/persistence_profile_showcase.go b/protocol/persistence_profile_showcase.go index 809c490ee55..3066c2eb939 100644 --- a/protocol/persistence_profile_showcase.go +++ b/protocol/persistence_profile_showcase.go @@ -7,15 +7,6 @@ import ( "github.com/status-im/status-go/protocol/identity" ) -type ProfileShowcaseEntryType int - -const ( - ProfileShowcaseEntryTypeCommunity ProfileShowcaseEntryType = iota - ProfileShowcaseEntryTypeAccount - ProfileShowcaseEntryTypeCollectible - ProfileShowcaseEntryTypeAsset -) - type ProfileShowcaseVisibility int const ( @@ -25,27 +16,74 @@ const ( ProfileShowcaseVisibilityEveryone ) -const insertOrUpdateProfilePreferencesQuery = "INSERT OR REPLACE INTO profile_showcase_preferences(id, entry_type, visibility, sort_order) VALUES (?, ?, ?, ?)" -const selectAllProfilePreferencesQuery = "SELECT id, entry_type, visibility, sort_order FROM profile_showcase_preferences" -const selectProfilePreferencesByTypeQuery = "SELECT id, entry_type, visibility, sort_order FROM profile_showcase_preferences WHERE entry_type = ?" +const upsertProfileShowcaseCommunityPreferenceQuery = "INSERT OR REPLACE INTO profile_showcase_communities_preferences(community_id, visibility, sort_order) VALUES (?, ?, ?)" +const selectProfileShowcaseCommunityPreferenceQuery = "SELECT community_id, visibility, sort_order FROM profile_showcase_communities_preferences" + +const upsertProfileShowcaseAccountPreferenceQuery = "INSERT OR REPLACE INTO profile_showcase_accounts_preferences(address, name, color_id, emoji, visibility, sort_order) VALUES (?, ?, ?, ?, ?, ?)" +const selectProfileShowcaseAccountPreferenceQuery = "SELECT address, name, color_id, emoji, visibility, sort_order FROM profile_showcase_accounts_preferences" + +const upsertProfileShowcaseCollectiblePreferenceQuery = "INSERT OR REPLACE INTO profile_showcase_collectibles_preferences(uid, visibility, sort_order) VALUES (?, ?, ?)" +const selectProfileShowcaseCollectiblePreferenceQuery = "SELECT uid, visibility, sort_order FROM profile_showcase_collectibles_preferences" + +const upsertProfileShowcaseAssetPreferenceQuery = "INSERT OR REPLACE INTO profile_showcase_assets_preferences(symbol, visibility, sort_order) VALUES (?, ?, ?)" +const selectProfileShowcaseAssetPreferenceQuery = "SELECT symbol, visibility, sort_order FROM profile_showcase_assets_preferences" + +const upsertContactProfileShowcaseCommunityQuery = "INSERT OR REPLACE INTO profile_showcase_communities_contacts(contact_id, community_id, sort_order) VALUES (?, ?, ?)" +const selectContactProfileShowcaseCommunityQuery = "SELECT community_id, sort_order FROM profile_showcase_communities_contacts WHERE contact_id = ?" +const removeContactProfileShowcaseCommunityQuery = "DELETE FROM profile_showcase_communities_contacts WHERE contact_id = ?" + +const upsertContactProfileShowcaseAccountQuery = "INSERT OR REPLACE INTO profile_showcase_accounts_contacts(contact_id, address, name, color_id, emoji, sort_order) VALUES (?, ?, ?, ?, ?, ?)" +const selectContactProfileShowcaseAccountQuery = "SELECT address, name, color_id, emoji, sort_order FROM profile_showcase_accounts_contacts WHERE contact_id = ?" +const removeContactProfileShowcaseAccountQuery = "DELETE FROM profile_showcase_accounts_contacts WHERE contact_id = ?" + +const upsertContactProfileShowcaseCollectibleQuery = "INSERT OR REPLACE INTO profile_showcase_collectibles_contacts(contact_id, uid, sort_order) VALUES (?, ?, ?)" +const selectContactProfileShowcaseCollectibleQuery = "SELECT uid, sort_order FROM profile_showcase_collectibles_contacts WHERE contact_id = ?" +const removeContactProfileShowcaseCollectibleQuery = "DELETE FROM profile_showcase_collectibles_contacts WHERE contact_id = ?" -const removeProfileShowcaseContactQuery = "DELETE FROM profile_showcase_contacts WHERE contact_id = ?" -const insertOrUpdateProfileShowcaseContactQuery = "INSERT OR REPLACE INTO profile_showcase_contacts(contact_id, entry_id, entry_type, entry_order) VALUES (?, ?, ?, ?)" -const selectProfileShowcaseByContactQuery = "SELECT entry_id, entry_order, entry_type FROM profile_showcase_contacts WHERE contact_id = ?" +const upsertContactProfileShowcaseAssetQuery = "INSERT OR REPLACE INTO profile_showcase_assets_contacts(contact_id, symbol, sort_order) VALUES (?, ?, ?)" +const selectContactProfileShowcaseAssetQuery = "SELECT symbol, sort_order FROM profile_showcase_assets_contacts WHERE contact_id = ?" +const removeContactProfileShowcaseAssetQuery = "DELETE FROM profile_showcase_assets_contacts WHERE contact_id = ?" + +type ProfileShowcaseCommunityPreference struct { + CommunityID string `json:"community_id"` + ShowcaseVisibility ProfileShowcaseVisibility `json:"showcaseVisibility"` + Order int `json:"order"` +} + +type ProfileShowcaseAccountPreference struct { + Address string `json:"address"` + Name string `json:"name"` + ColorID string `json:"colorId"` + Emoji string `json:"emoji"` + ShowcaseVisibility ProfileShowcaseVisibility `json:"showcaseVisibility"` + Order int `json:"order"` +} + +type ProfileShowcaseCollectiblePreference struct { + UID string `json:"uid"` + ShowcaseVisibility ProfileShowcaseVisibility `json:"showcaseVisibility"` + Order int `json:"order"` +} -type ProfileShowcaseEntry struct { - ID string `json:"id"` - EntryType ProfileShowcaseEntryType `json:"entryType"` +type ProfileShowcaseAssetPreference struct { + Symbol string `json:"symbol"` ShowcaseVisibility ProfileShowcaseVisibility `json:"showcaseVisibility"` Order int `json:"order"` } -func (db sqlitePersistence) SaveProfileShowcasePreference(entry *ProfileShowcaseEntry) error { - _, err := db.db.Exec(insertOrUpdateProfilePreferencesQuery, - entry.ID, - entry.EntryType, - entry.ShowcaseVisibility, - entry.Order, +type ProfileShowcasePreferences struct { + Communities []*ProfileShowcaseCommunityPreference `json:"communities"` + Accounts []*ProfileShowcaseAccountPreference `json:"accounts"` + Collectibles []*ProfileShowcaseCollectiblePreference `json:"collectibles"` + Assets []*ProfileShowcaseAssetPreference `json:"assets"` +} + +// Queries for showcase preferences +func (db sqlitePersistence) saveProfileShowcaseCommunityPreference(tx *sql.Tx, community *ProfileShowcaseCommunityPreference) error { + _, err := tx.Exec(upsertProfileShowcaseCommunityPreferenceQuery, + community.CommunityID, + community.ShowcaseVisibility, + community.Order, ) if err != nil { @@ -55,117 +93,213 @@ func (db sqlitePersistence) SaveProfileShowcasePreference(entry *ProfileShowcase return nil } -func (db sqlitePersistence) SaveProfileShowcasePreferences(entries []*ProfileShowcaseEntry) error { - tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) +func (db sqlitePersistence) getProfileShowcaseCommunitiesPreferences(tx *sql.Tx) ([]*ProfileShowcaseCommunityPreference, error) { + rows, err := tx.Query(selectProfileShowcaseCommunityPreferenceQuery) if err != nil { - return err + return nil, err } - defer func() { - if err == nil { - err = tx.Commit() - return - } - // don't shadow original error - _ = tx.Rollback() - }() - for _, entry := range entries { - _, err = tx.Exec(insertOrUpdateProfilePreferencesQuery, - entry.ID, - entry.EntryType, - entry.ShowcaseVisibility, - entry.Order, + communities := []*ProfileShowcaseCommunityPreference{} + + for rows.Next() { + community := &ProfileShowcaseCommunityPreference{} + + err := rows.Scan( + &community.CommunityID, + &community.ShowcaseVisibility, + &community.Order, ) if err != nil { - return err + return nil, err } + + communities = append(communities, community) + } + return communities, nil +} + +func (db sqlitePersistence) saveProfileShowcaseAccountPreference(tx *sql.Tx, account *ProfileShowcaseAccountPreference) error { + _, err := tx.Exec(upsertProfileShowcaseAccountPreferenceQuery, + account.Address, + account.Name, + account.ColorID, + account.Emoji, + account.ShowcaseVisibility, + account.Order, + ) + + if err != nil { + return err } return nil } -func (db sqlitePersistence) parseProfileShowcasePreferencesRows(rows *sql.Rows) ([]*ProfileShowcaseEntry, error) { - entries := []*ProfileShowcaseEntry{} +func (db sqlitePersistence) getProfileShowcaseAccountsPreferences(tx *sql.Tx) ([]*ProfileShowcaseAccountPreference, error) { + rows, err := tx.Query(selectProfileShowcaseAccountPreferenceQuery) + if err != nil { + return nil, err + } + + accounts := []*ProfileShowcaseAccountPreference{} for rows.Next() { - entry := &ProfileShowcaseEntry{} + account := &ProfileShowcaseAccountPreference{} err := rows.Scan( - &entry.ID, - &entry.EntryType, - &entry.ShowcaseVisibility, - &entry.Order, + &account.Address, + &account.Name, + &account.ColorID, + &account.Emoji, + &account.ShowcaseVisibility, + &account.Order, ) if err != nil { return nil, err } - entries = append(entries, entry) + accounts = append(accounts, account) } - return entries, nil + return accounts, nil } -func (db sqlitePersistence) GetAllProfileShowcasePreferences() ([]*ProfileShowcaseEntry, error) { - rows, err := db.db.Query(selectAllProfilePreferencesQuery) +func (db sqlitePersistence) saveProfileShowcaseCollectiblePreference(tx *sql.Tx, collectible *ProfileShowcaseCollectiblePreference) error { + _, err := tx.Exec(upsertProfileShowcaseCollectiblePreferenceQuery, + collectible.UID, + collectible.ShowcaseVisibility, + collectible.Order, + ) + if err != nil { - return nil, err + return err } - defer rows.Close() - return db.parseProfileShowcasePreferencesRows(rows) + return nil } -func (db sqlitePersistence) GetProfileShowcasePreferencesByType(entryType ProfileShowcaseEntryType) ([]*ProfileShowcaseEntry, error) { - rows, err := db.db.Query(selectProfilePreferencesByTypeQuery, entryType) +func (db sqlitePersistence) getProfileShowcaseCollectiblesPreferences(tx *sql.Tx) ([]*ProfileShowcaseCollectiblePreference, error) { + rows, err := tx.Query(selectProfileShowcaseCollectiblePreferenceQuery) if err != nil { return nil, err } - defer rows.Close() - return db.parseProfileShowcasePreferencesRows(rows) + collectibles := []*ProfileShowcaseCollectiblePreference{} + + for rows.Next() { + collectible := &ProfileShowcaseCollectiblePreference{} + + err := rows.Scan( + &collectible.UID, + &collectible.ShowcaseVisibility, + &collectible.Order, + ) + + if err != nil { + return nil, err + } + + collectibles = append(collectibles, collectible) + } + return collectibles, nil +} + +func (db sqlitePersistence) saveProfileShowcaseAssetPreference(tx *sql.Tx, asset *ProfileShowcaseAssetPreference) error { + _, err := tx.Exec(upsertProfileShowcaseAssetPreferenceQuery, + asset.Symbol, + asset.ShowcaseVisibility, + asset.Order, + ) + + if err != nil { + return err + } + + return nil } -func (db sqlitePersistence) GetProfileShowcaseForContact(contactID string) (*identity.ProfileShowcase, error) { - rows, err := db.db.Query(selectProfileShowcaseByContactQuery, contactID) +func (db sqlitePersistence) getProfileShowcaseAssetsPreferences(tx *sql.Tx) ([]*ProfileShowcaseAssetPreference, error) { + rows, err := tx.Query(selectProfileShowcaseAssetPreferenceQuery) if err != nil { return nil, err } - defer rows.Close() - showcase := &identity.ProfileShowcase{} + assets := []*ProfileShowcaseAssetPreference{} for rows.Next() { - var entryType ProfileShowcaseEntryType - entry := &identity.VisibleProfileShowcaseEntry{} + asset := &ProfileShowcaseAssetPreference{} err := rows.Scan( - &entry.EntryID, - &entry.Order, - &entryType, + &asset.Symbol, + &asset.ShowcaseVisibility, + &asset.Order, ) + if err != nil { return nil, err } - switch entryType { - case ProfileShowcaseEntryTypeCommunity: - showcase.Communities = append(showcase.Communities, entry) - case ProfileShowcaseEntryTypeAccount: - showcase.Accounts = append(showcase.Accounts, entry) - case ProfileShowcaseEntryTypeCollectible: - showcase.Collectibles = append(showcase.Collectibles, entry) - case ProfileShowcaseEntryTypeAsset: - showcase.Assets = append(showcase.Assets, entry) + assets = append(assets, asset) + } + return assets, nil +} + +// Queries for contacts showcase +func (db sqlitePersistence) saveProfileShowcaseCommunityContact(tx *sql.Tx, contactID string, community *identity.ProfileShowcaseCommunity) error { + _, err := tx.Exec(upsertContactProfileShowcaseCommunityQuery, + contactID, + community.CommunityID, + community.Order, + ) + + if err != nil { + return err + } + + return nil +} + +func (db sqlitePersistence) getProfileShowcaseCommunitiesContact(tx *sql.Tx, contactID string) ([]*identity.ProfileShowcaseCommunity, error) { + rows, err := tx.Query(selectContactProfileShowcaseCommunityQuery, contactID) + if err != nil { + return nil, err + } + + communities := []*identity.ProfileShowcaseCommunity{} + + for rows.Next() { + community := &identity.ProfileShowcaseCommunity{} + + err := rows.Scan(&community.CommunityID, &community.Order) + if err != nil { + return nil, err } + + communities = append(communities, community) + } + return communities, nil +} + +func (db sqlitePersistence) clearProfileShowcaseCommunityContact(tx *sql.Tx, contactID string) error { + _, err := tx.Exec(removeContactProfileShowcaseCommunityQuery, contactID) + if err != nil { + return err } - return showcase, nil + return nil } -func (db sqlitePersistence) ClearProfileShowcaseForContact(contactID string) error { - _, err := db.db.Exec(removeProfileShowcaseContactQuery, contactID) +func (db sqlitePersistence) saveProfileShowcaseAccountContact(tx *sql.Tx, contactID string, account *identity.ProfileShowcaseAccount) error { + _, err := tx.Exec(upsertContactProfileShowcaseAccountQuery, + contactID, + account.Address, + account.Name, + account.ColorID, + account.Emoji, + account.Order, + ) + if err != nil { return err } @@ -173,22 +307,212 @@ func (db sqlitePersistence) ClearProfileShowcaseForContact(contactID string) err return nil } -func (db sqlitePersistence) saveProfileShowcaseContactEntries(tx *sql.Tx, contactID string, entryType ProfileShowcaseEntryType, entries []*identity.VisibleProfileShowcaseEntry) error { - for _, entry := range entries { - _, err := tx.Exec(insertOrUpdateProfileShowcaseContactQuery, - contactID, - entry.EntryID, - entryType, - entry.Order, - ) +func (db sqlitePersistence) getProfileShowcaseAccountsContact(tx *sql.Tx, contactID string) ([]*identity.ProfileShowcaseAccount, error) { + rows, err := tx.Query(selectContactProfileShowcaseAccountQuery, contactID) + if err != nil { + return nil, err + } + accounts := []*identity.ProfileShowcaseAccount{} + + for rows.Next() { + account := &identity.ProfileShowcaseAccount{} + + err := rows.Scan(&account.Address, &account.Name, &account.ColorID, &account.Emoji, &account.Order) + if err != nil { + return nil, err + } + + accounts = append(accounts, account) + } + return accounts, nil +} + +func (db sqlitePersistence) clearProfileShowcaseAccountsContact(tx *sql.Tx, contactID string) error { + _, err := tx.Exec(removeContactProfileShowcaseAccountQuery, contactID) + if err != nil { + return err + } + + return nil +} + +func (db sqlitePersistence) saveProfileShowcaseCollectibleContact(tx *sql.Tx, contactID string, community *identity.ProfileShowcaseCollectible) error { + _, err := tx.Exec(upsertContactProfileShowcaseCollectibleQuery, + contactID, + community.UID, + community.Order, + ) + + if err != nil { + return err + } + + return nil +} + +func (db sqlitePersistence) getProfileShowcaseCollectiblesContact(tx *sql.Tx, contactID string) ([]*identity.ProfileShowcaseCollectible, error) { + rows, err := tx.Query(selectContactProfileShowcaseCollectibleQuery, contactID) + if err != nil { + return nil, err + } + + collectibles := []*identity.ProfileShowcaseCollectible{} + + for rows.Next() { + collectible := &identity.ProfileShowcaseCollectible{} + + err := rows.Scan(&collectible.UID, &collectible.Order) + if err != nil { + return nil, err + } + + collectibles = append(collectibles, collectible) + } + return collectibles, nil +} + +func (db sqlitePersistence) clearProfileShowcaseCollectiblesContact(tx *sql.Tx, contactID string) error { + _, err := tx.Exec(removeContactProfileShowcaseCollectibleQuery, contactID) + if err != nil { + return err + } + + return nil +} + +func (db sqlitePersistence) saveProfileShowcaseAssetContact(tx *sql.Tx, contactID string, asset *identity.ProfileShowcaseAsset) error { + _, err := tx.Exec(upsertContactProfileShowcaseAssetQuery, + contactID, + asset.Symbol, + asset.Order, + ) + + if err != nil { + return err + } + + return nil +} + +func (db sqlitePersistence) getProfileShowcaseAssetsContact(tx *sql.Tx, contactID string) ([]*identity.ProfileShowcaseAsset, error) { + rows, err := tx.Query(selectContactProfileShowcaseAssetQuery, contactID) + if err != nil { + return nil, err + } + + assets := []*identity.ProfileShowcaseAsset{} + + for rows.Next() { + asset := &identity.ProfileShowcaseAsset{} + + err := rows.Scan(&asset.Symbol, &asset.Order) + if err != nil { + return nil, err + } + + assets = append(assets, asset) + } + return assets, nil +} + +func (db sqlitePersistence) clearProfileShowcaseAssetsContact(tx *sql.Tx, contactID string) error { + _, err := tx.Exec(removeContactProfileShowcaseAssetQuery, contactID) + if err != nil { + return err + } + + return nil +} + +// public functions +func (db sqlitePersistence) SaveProfileShowcasePreferences(preferences *ProfileShowcasePreferences) error { + tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) + if err != nil { + return err + } + defer func() { + if err == nil { + err = tx.Commit() + return + } + // don't shadow original error + _ = tx.Rollback() + }() + + for _, community := range preferences.Communities { + err = db.saveProfileShowcaseCommunityPreference(tx, community) + if err != nil { + return err + } + } + + for _, account := range preferences.Accounts { + err = db.saveProfileShowcaseAccountPreference(tx, account) + if err != nil { + return err + } + } + + for _, collectible := range preferences.Collectibles { + err = db.saveProfileShowcaseCollectiblePreference(tx, collectible) if err != nil { return err } } + + for _, asset := range preferences.Assets { + err = db.saveProfileShowcaseAssetPreference(tx, asset) + if err != nil { + return err + } + } + return nil } +func (db sqlitePersistence) GetProfileShowcasePreferences() (*ProfileShowcasePreferences, error) { + tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) + if err != nil { + return nil, err + } + defer func() { + if err == nil { + err = tx.Commit() + return + } + // don't shadow original error + _ = tx.Rollback() + }() + + communities, err := db.getProfileShowcaseCommunitiesPreferences(tx) + if err != nil { + return nil, err + } + + accounts, err := db.getProfileShowcaseAccountsPreferences(tx) + if err != nil { + return nil, err + } + + collectibles, err := db.getProfileShowcaseCollectiblesPreferences(tx) + if err != nil { + return nil, err + } + + assets, err := db.getProfileShowcaseAssetsPreferences(tx) + if err != nil { + return nil, err + } + + return &ProfileShowcasePreferences{ + Communities: communities, + Accounts: accounts, + Collectibles: collectibles, + Assets: assets, + }, nil +} + func (db sqlitePersistence) SaveProfileShowcaseForContact(contactID string, showcase *identity.ProfileShowcase) error { tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) if err != nil { @@ -203,29 +527,109 @@ func (db sqlitePersistence) SaveProfileShowcaseForContact(contactID string, show _ = tx.Rollback() }() - // Remove old entries first - _, err = tx.Exec(removeProfileShowcaseContactQuery, contactID) + for _, community := range showcase.Communities { + err = db.saveProfileShowcaseCommunityContact(tx, contactID, community) + if err != nil { + return err + } + } + + for _, account := range showcase.Accounts { + err = db.saveProfileShowcaseAccountContact(tx, contactID, account) + if err != nil { + return err + } + } + + for _, collectible := range showcase.Collectibles { + err = db.saveProfileShowcaseCollectibleContact(tx, contactID, collectible) + if err != nil { + return err + } + } + + for _, asset := range showcase.Assets { + err = db.saveProfileShowcaseAssetContact(tx, contactID, asset) + if err != nil { + return err + } + } + + return nil +} + +func (db sqlitePersistence) GetProfileShowcaseForContact(contactID string) (*identity.ProfileShowcase, error) { + tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) + if err != nil { + return nil, err + } + defer func() { + if err == nil { + err = tx.Commit() + return + } + // don't shadow original error + _ = tx.Rollback() + }() + + communities, err := db.getProfileShowcaseCommunitiesContact(tx, contactID) + if err != nil { + return nil, err + } + + accounts, err := db.getProfileShowcaseAccountsContact(tx, contactID) + if err != nil { + return nil, err + } + + collectibles, err := db.getProfileShowcaseCollectiblesContact(tx, contactID) + if err != nil { + return nil, err + } + + assets, err := db.getProfileShowcaseAssetsContact(tx, contactID) + if err != nil { + return nil, err + } + + return &identity.ProfileShowcase{ + Communities: communities, + Accounts: accounts, + Collectibles: collectibles, + Assets: assets, + }, nil +} + +func (db sqlitePersistence) ClearProfileShowcaseForContact(contactID string) error { + tx, err := db.db.BeginTx(context.Background(), &sql.TxOptions{}) if err != nil { return err } + defer func() { + if err == nil { + err = tx.Commit() + return + } + // don't shadow original error + _ = tx.Rollback() + }() - // Save all profile showcase entries - err = db.saveProfileShowcaseContactEntries(tx, contactID, ProfileShowcaseEntryTypeCommunity, showcase.Communities) + err = db.clearProfileShowcaseCommunityContact(tx, contactID) if err != nil { return err } - err = db.saveProfileShowcaseContactEntries(tx, contactID, ProfileShowcaseEntryTypeAccount, showcase.Accounts) + err = db.clearProfileShowcaseAccountsContact(tx, contactID) if err != nil { return err } - err = db.saveProfileShowcaseContactEntries(tx, contactID, ProfileShowcaseEntryTypeCollectible, showcase.Collectibles) + err = db.clearProfileShowcaseCollectiblesContact(tx, contactID) if err != nil { return err } - err = db.saveProfileShowcaseContactEntries(tx, contactID, ProfileShowcaseEntryTypeAsset, showcase.Assets) + err = db.clearProfileShowcaseAssetsContact(tx, contactID) if err != nil { return err } diff --git a/protocol/persistence_profile_showcase_test.go b/protocol/persistence_profile_showcase_test.go index ff719451497..f5aeeea85ca 100644 --- a/protocol/persistence_profile_showcase_test.go +++ b/protocol/persistence_profile_showcase_test.go @@ -21,67 +21,91 @@ func (s *TestProfileShowcasePersistence) TestProfileShowcasePreferences() { s.Require().NoError(err) persistence := newSQLitePersistence(db) - preferences := []*ProfileShowcaseEntry{ - &ProfileShowcaseEntry{ - ID: "0x32433445133424", - EntryType: ProfileShowcaseEntryTypeCommunity, - ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, - Order: 0, - }, - &ProfileShowcaseEntry{ - ID: "0x12333245443413412", - EntryType: ProfileShowcaseEntryTypeAccount, - ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, - Order: 0, + preferences := &ProfileShowcasePreferences{ + Communities: []*ProfileShowcaseCommunityPreference{ + &ProfileShowcaseCommunityPreference{ + CommunityID: "0x32433445133424", + ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, + Order: 0, + }, }, - &ProfileShowcaseEntry{ - ID: "b4ef5ce9-5a10-4c88-a2ff-5bc371f82930", - EntryType: ProfileShowcaseEntryTypeCollectible, - ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, - Order: 0, + Accounts: []*ProfileShowcaseAccountPreference{ + &ProfileShowcaseAccountPreference{ + Address: "0x32433445133424", + Name: "Status Account", + ColorID: "blue", + Emoji: "-_-", + ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, + Order: 0, + }, + &ProfileShowcaseAccountPreference{ + Address: "0x3845354643324", + Name: "Money Box", + ColorID: "red", + Emoji: ":o)", + ShowcaseVisibility: ProfileShowcaseVisibilityContacts, + Order: 1, + }, }, - &ProfileShowcaseEntry{ - ID: "ETH", - EntryType: ProfileShowcaseEntryTypeAsset, - ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, - Order: 0, + Assets: []*ProfileShowcaseAssetPreference{ + &ProfileShowcaseAssetPreference{ + Symbol: "ETH", + ShowcaseVisibility: ProfileShowcaseVisibilityEveryone, + Order: 0, + }, + &ProfileShowcaseAssetPreference{ + Symbol: "DAI", + ShowcaseVisibility: ProfileShowcaseVisibilityIDVerifiedContacts, + Order: 2, + }, + &ProfileShowcaseAssetPreference{ + Symbol: "SNT", + ShowcaseVisibility: ProfileShowcaseVisibilityNoOne, + Order: 3, + }, }, } err = persistence.SaveProfileShowcasePreferences(preferences) s.Require().NoError(err) - preferencesBack, err := persistence.GetAllProfileShowcasePreferences() + preferencesBack, err := persistence.GetProfileShowcasePreferences() s.Require().NoError(err) - s.Require().Equal(len(preferences), len(preferencesBack)) - - for i, entry := range preferences { - s.Require().Equal(entry.ID, preferencesBack[i].ID) - s.Require().Equal(entry.EntryType, preferencesBack[i].EntryType) - s.Require().Equal(entry.ShowcaseVisibility, preferencesBack[i].ShowcaseVisibility) - s.Require().Equal(entry.Order, preferencesBack[i].Order) - } - - preferencesBack, err = persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeCommunity) - s.Require().NoError(err) - s.Require().Equal(1, len(preferencesBack)) - s.Require().Equal(preferences[0].ID, preferencesBack[0].ID) - - preferencesBack, err = persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeAccount) - s.Require().NoError(err) - s.Require().Equal(1, len(preferencesBack)) - s.Require().Equal(preferences[1].ID, preferencesBack[0].ID) - - preferencesBack, err = persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeCollectible) - s.Require().NoError(err) - s.Require().Equal(1, len(preferencesBack)) - s.Require().Equal(preferences[2].ID, preferencesBack[0].ID) - - preferencesBack, err = persistence.GetProfileShowcasePreferencesByType(ProfileShowcaseEntryTypeAsset) - s.Require().NoError(err) - s.Require().Equal(1, len(preferencesBack)) - s.Require().Equal(preferences[3].ID, preferencesBack[0].ID) + s.Require().Len(preferencesBack.Communities, 1) + s.Require().Equal(preferences.Communities[0].CommunityID, preferencesBack.Communities[0].CommunityID) + s.Require().Equal(preferences.Communities[0].ShowcaseVisibility, preferencesBack.Communities[0].ShowcaseVisibility) + s.Require().Equal(preferences.Communities[0].Order, preferencesBack.Communities[0].Order) + + s.Require().Len(preferencesBack.Accounts, 2) + s.Require().Equal(preferences.Accounts[0].Address, preferencesBack.Accounts[0].Address) + s.Require().Equal(preferences.Accounts[0].Name, preferencesBack.Accounts[0].Name) + s.Require().Equal(preferences.Accounts[0].ColorID, preferencesBack.Accounts[0].ColorID) + s.Require().Equal(preferences.Accounts[0].Emoji, preferencesBack.Accounts[0].Emoji) + s.Require().Equal(preferences.Accounts[0].ShowcaseVisibility, preferencesBack.Accounts[0].ShowcaseVisibility) + s.Require().Equal(preferences.Accounts[0].Order, preferencesBack.Accounts[0].Order) + + s.Require().Equal(preferences.Accounts[1].Address, preferencesBack.Accounts[1].Address) + s.Require().Equal(preferences.Accounts[1].Name, preferencesBack.Accounts[1].Name) + s.Require().Equal(preferences.Accounts[1].ColorID, preferencesBack.Accounts[1].ColorID) + s.Require().Equal(preferences.Accounts[1].Emoji, preferencesBack.Accounts[1].Emoji) + s.Require().Equal(preferences.Accounts[1].ShowcaseVisibility, preferencesBack.Accounts[1].ShowcaseVisibility) + s.Require().Equal(preferences.Accounts[1].Order, preferencesBack.Accounts[1].Order) + + s.Require().Len(preferencesBack.Collectibles, 0) + + s.Require().Len(preferencesBack.Assets, 3) + s.Require().Equal(preferences.Assets[0].Symbol, preferencesBack.Assets[0].Symbol) + s.Require().Equal(preferences.Assets[0].ShowcaseVisibility, preferencesBack.Assets[0].ShowcaseVisibility) + s.Require().Equal(preferences.Assets[0].Order, preferencesBack.Assets[0].Order) + + s.Require().Equal(preferences.Assets[1].Symbol, preferencesBack.Assets[1].Symbol) + s.Require().Equal(preferences.Assets[1].ShowcaseVisibility, preferencesBack.Assets[1].ShowcaseVisibility) + s.Require().Equal(preferences.Assets[1].Order, preferencesBack.Assets[1].Order) + + s.Require().Equal(preferences.Assets[2].Symbol, preferencesBack.Assets[2].Symbol) + s.Require().Equal(preferences.Assets[2].ShowcaseVisibility, preferencesBack.Assets[2].ShowcaseVisibility) + s.Require().Equal(preferences.Assets[2].Order, preferencesBack.Assets[2].Order) } func (s *TestProfileShowcasePersistence) TestProfileShowcaseContacts() { @@ -90,20 +114,20 @@ func (s *TestProfileShowcasePersistence) TestProfileShowcaseContacts() { persistence := newSQLitePersistence(db) showcase1 := &identity.ProfileShowcase{ - Communities: []*identity.VisibleProfileShowcaseEntry{ - &identity.VisibleProfileShowcaseEntry{ - EntryID: "0x012312234234234", - Order: 6, + Communities: []*identity.ProfileShowcaseCommunity{ + &identity.ProfileShowcaseCommunity{ + CommunityID: "0x012312234234234", + Order: 6, }, - &identity.VisibleProfileShowcaseEntry{ - EntryID: "0x04523233466753", - Order: 7, + &identity.ProfileShowcaseCommunity{ + CommunityID: "0x04523233466753", + Order: 7, }, }, - Assets: []*identity.VisibleProfileShowcaseEntry{ - &identity.VisibleProfileShowcaseEntry{ - EntryID: "ETH", - Order: 1, + Assets: []*identity.ProfileShowcaseAsset{ + &identity.ProfileShowcaseAsset{ + Symbol: "ETH", + Order: 1, }, }, } @@ -111,20 +135,20 @@ func (s *TestProfileShowcasePersistence) TestProfileShowcaseContacts() { s.Require().NoError(err) showcase2 := &identity.ProfileShowcase{ - Communities: []*identity.VisibleProfileShowcaseEntry{ - &identity.VisibleProfileShowcaseEntry{ - EntryID: "0x012312234234234", // same id to check query - Order: 3, + Communities: []*identity.ProfileShowcaseCommunity{ + &identity.ProfileShowcaseCommunity{ + CommunityID: "0x012312234234234", // same id to check query + Order: 3, }, - &identity.VisibleProfileShowcaseEntry{ - EntryID: "0x096783478384593", - Order: 7, + &identity.ProfileShowcaseCommunity{ + CommunityID: "0x096783478384593", + Order: 7, }, }, - Collectibles: []*identity.VisibleProfileShowcaseEntry{ - &identity.VisibleProfileShowcaseEntry{ - EntryID: "d378662f-3d71-44e0-81ee-ff7f1778c13a", - Order: 1, + Collectibles: []*identity.ProfileShowcaseCollectible{ + &identity.ProfileShowcaseCollectible{ + UID: "d378662f-3d71-44e0-81ee-ff7f1778c13a", + Order: 1, }, }, } diff --git a/protocol/protobuf/profile_showcase.pb.go b/protocol/protobuf/profile_showcase.pb.go index d663fc559bb..89d5ae7d858 100644 --- a/protocol/protobuf/profile_showcase.pb.go +++ b/protocol/protobuf/profile_showcase.pb.go @@ -20,17 +20,17 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type ProfileShowcaseEntry struct { +type ProfileShowcaseCommunity struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EntryId string `protobuf:"bytes,1,opt,name=entry_id,json=entryId,proto3" json:"entry_id,omitempty"` - Order uint32 `protobuf:"varint,2,opt,name=order,proto3" json:"order,omitempty"` + CommunityId string `protobuf:"bytes,1,opt,name=community_id,json=communityId,proto3" json:"community_id,omitempty"` + Order uint32 `protobuf:"varint,2,opt,name=order,proto3" json:"order,omitempty"` } -func (x *ProfileShowcaseEntry) Reset() { - *x = ProfileShowcaseEntry{} +func (x *ProfileShowcaseCommunity) Reset() { + *x = ProfileShowcaseCommunity{} if protoimpl.UnsafeEnabled { mi := &file_profile_showcase_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -38,13 +38,13 @@ func (x *ProfileShowcaseEntry) Reset() { } } -func (x *ProfileShowcaseEntry) String() string { +func (x *ProfileShowcaseCommunity) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ProfileShowcaseEntry) ProtoMessage() {} +func (*ProfileShowcaseCommunity) ProtoMessage() {} -func (x *ProfileShowcaseEntry) ProtoReflect() protoreflect.Message { +func (x *ProfileShowcaseCommunity) ProtoReflect() protoreflect.Message { mi := &file_profile_showcase_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -56,19 +56,208 @@ func (x *ProfileShowcaseEntry) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ProfileShowcaseEntry.ProtoReflect.Descriptor instead. -func (*ProfileShowcaseEntry) Descriptor() ([]byte, []int) { +// Deprecated: Use ProfileShowcaseCommunity.ProtoReflect.Descriptor instead. +func (*ProfileShowcaseCommunity) Descriptor() ([]byte, []int) { return file_profile_showcase_proto_rawDescGZIP(), []int{0} } -func (x *ProfileShowcaseEntry) GetEntryId() string { +func (x *ProfileShowcaseCommunity) GetCommunityId() string { if x != nil { - return x.EntryId + return x.CommunityId } return "" } -func (x *ProfileShowcaseEntry) GetOrder() uint32 { +func (x *ProfileShowcaseCommunity) GetOrder() uint32 { + if x != nil { + return x.Order + } + return 0 +} + +type ProfileShowcaseAccount struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + ColorId string `protobuf:"bytes,3,opt,name=color_id,json=colorId,proto3" json:"color_id,omitempty"` + Emoji string `protobuf:"bytes,4,opt,name=emoji,proto3" json:"emoji,omitempty"` + Order uint32 `protobuf:"varint,5,opt,name=order,proto3" json:"order,omitempty"` +} + +func (x *ProfileShowcaseAccount) Reset() { + *x = ProfileShowcaseAccount{} + if protoimpl.UnsafeEnabled { + mi := &file_profile_showcase_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProfileShowcaseAccount) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProfileShowcaseAccount) ProtoMessage() {} + +func (x *ProfileShowcaseAccount) ProtoReflect() protoreflect.Message { + mi := &file_profile_showcase_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProfileShowcaseAccount.ProtoReflect.Descriptor instead. +func (*ProfileShowcaseAccount) Descriptor() ([]byte, []int) { + return file_profile_showcase_proto_rawDescGZIP(), []int{1} +} + +func (x *ProfileShowcaseAccount) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *ProfileShowcaseAccount) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ProfileShowcaseAccount) GetColorId() string { + if x != nil { + return x.ColorId + } + return "" +} + +func (x *ProfileShowcaseAccount) GetEmoji() string { + if x != nil { + return x.Emoji + } + return "" +} + +func (x *ProfileShowcaseAccount) GetOrder() uint32 { + if x != nil { + return x.Order + } + return 0 +} + +type ProfileShowcaseCollectible struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"` + Order uint32 `protobuf:"varint,2,opt,name=order,proto3" json:"order,omitempty"` +} + +func (x *ProfileShowcaseCollectible) Reset() { + *x = ProfileShowcaseCollectible{} + if protoimpl.UnsafeEnabled { + mi := &file_profile_showcase_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProfileShowcaseCollectible) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProfileShowcaseCollectible) ProtoMessage() {} + +func (x *ProfileShowcaseCollectible) ProtoReflect() protoreflect.Message { + mi := &file_profile_showcase_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProfileShowcaseCollectible.ProtoReflect.Descriptor instead. +func (*ProfileShowcaseCollectible) Descriptor() ([]byte, []int) { + return file_profile_showcase_proto_rawDescGZIP(), []int{2} +} + +func (x *ProfileShowcaseCollectible) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *ProfileShowcaseCollectible) GetOrder() uint32 { + if x != nil { + return x.Order + } + return 0 +} + +type ProfileShowcaseAsset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Symbol string `protobuf:"bytes,1,opt,name=symbol,proto3" json:"symbol,omitempty"` + Order uint32 `protobuf:"varint,2,opt,name=order,proto3" json:"order,omitempty"` +} + +func (x *ProfileShowcaseAsset) Reset() { + *x = ProfileShowcaseAsset{} + if protoimpl.UnsafeEnabled { + mi := &file_profile_showcase_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProfileShowcaseAsset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProfileShowcaseAsset) ProtoMessage() {} + +func (x *ProfileShowcaseAsset) ProtoReflect() protoreflect.Message { + mi := &file_profile_showcase_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ProfileShowcaseAsset.ProtoReflect.Descriptor instead. +func (*ProfileShowcaseAsset) Descriptor() ([]byte, []int) { + return file_profile_showcase_proto_rawDescGZIP(), []int{3} +} + +func (x *ProfileShowcaseAsset) GetSymbol() string { + if x != nil { + return x.Symbol + } + return "" +} + +func (x *ProfileShowcaseAsset) GetOrder() uint32 { if x != nil { return x.Order } @@ -80,16 +269,16 @@ type ProfileShowcaseEntries struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Communities []*ProfileShowcaseEntry `protobuf:"bytes,1,rep,name=communities,proto3" json:"communities,omitempty"` - Accounts []*ProfileShowcaseEntry `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty"` - Collectibles []*ProfileShowcaseEntry `protobuf:"bytes,3,rep,name=collectibles,proto3" json:"collectibles,omitempty"` - Assets []*ProfileShowcaseEntry `protobuf:"bytes,4,rep,name=assets,proto3" json:"assets,omitempty"` + Communities []*ProfileShowcaseCommunity `protobuf:"bytes,1,rep,name=communities,proto3" json:"communities,omitempty"` + Accounts []*ProfileShowcaseAccount `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty"` + Collectibles []*ProfileShowcaseCollectible `protobuf:"bytes,3,rep,name=collectibles,proto3" json:"collectibles,omitempty"` + Assets []*ProfileShowcaseAsset `protobuf:"bytes,4,rep,name=assets,proto3" json:"assets,omitempty"` } func (x *ProfileShowcaseEntries) Reset() { *x = ProfileShowcaseEntries{} if protoimpl.UnsafeEnabled { - mi := &file_profile_showcase_proto_msgTypes[1] + mi := &file_profile_showcase_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -102,7 +291,7 @@ func (x *ProfileShowcaseEntries) String() string { func (*ProfileShowcaseEntries) ProtoMessage() {} func (x *ProfileShowcaseEntries) ProtoReflect() protoreflect.Message { - mi := &file_profile_showcase_proto_msgTypes[1] + mi := &file_profile_showcase_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -115,31 +304,31 @@ func (x *ProfileShowcaseEntries) ProtoReflect() protoreflect.Message { // Deprecated: Use ProfileShowcaseEntries.ProtoReflect.Descriptor instead. func (*ProfileShowcaseEntries) Descriptor() ([]byte, []int) { - return file_profile_showcase_proto_rawDescGZIP(), []int{1} + return file_profile_showcase_proto_rawDescGZIP(), []int{4} } -func (x *ProfileShowcaseEntries) GetCommunities() []*ProfileShowcaseEntry { +func (x *ProfileShowcaseEntries) GetCommunities() []*ProfileShowcaseCommunity { if x != nil { return x.Communities } return nil } -func (x *ProfileShowcaseEntries) GetAccounts() []*ProfileShowcaseEntry { +func (x *ProfileShowcaseEntries) GetAccounts() []*ProfileShowcaseAccount { if x != nil { return x.Accounts } return nil } -func (x *ProfileShowcaseEntries) GetCollectibles() []*ProfileShowcaseEntry { +func (x *ProfileShowcaseEntries) GetCollectibles() []*ProfileShowcaseCollectible { if x != nil { return x.Collectibles } return nil } -func (x *ProfileShowcaseEntries) GetAssets() []*ProfileShowcaseEntry { +func (x *ProfileShowcaseEntries) GetAssets() []*ProfileShowcaseAsset { if x != nil { return x.Assets } @@ -158,7 +347,7 @@ type ProfileShowcaseEntriesEncrypted struct { func (x *ProfileShowcaseEntriesEncrypted) Reset() { *x = ProfileShowcaseEntriesEncrypted{} if protoimpl.UnsafeEnabled { - mi := &file_profile_showcase_proto_msgTypes[2] + mi := &file_profile_showcase_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -171,7 +360,7 @@ func (x *ProfileShowcaseEntriesEncrypted) String() string { func (*ProfileShowcaseEntriesEncrypted) ProtoMessage() {} func (x *ProfileShowcaseEntriesEncrypted) ProtoReflect() protoreflect.Message { - mi := &file_profile_showcase_proto_msgTypes[2] + mi := &file_profile_showcase_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -184,7 +373,7 @@ func (x *ProfileShowcaseEntriesEncrypted) ProtoReflect() protoreflect.Message { // Deprecated: Use ProfileShowcaseEntriesEncrypted.ProtoReflect.Descriptor instead. func (*ProfileShowcaseEntriesEncrypted) Descriptor() ([]byte, []int) { - return file_profile_showcase_proto_rawDescGZIP(), []int{2} + return file_profile_showcase_proto_rawDescGZIP(), []int{5} } func (x *ProfileShowcaseEntriesEncrypted) GetEncryptedEntries() []byte { @@ -214,7 +403,7 @@ type ProfileShowcase struct { func (x *ProfileShowcase) Reset() { *x = ProfileShowcase{} if protoimpl.UnsafeEnabled { - mi := &file_profile_showcase_proto_msgTypes[3] + mi := &file_profile_showcase_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -227,7 +416,7 @@ func (x *ProfileShowcase) String() string { func (*ProfileShowcase) ProtoMessage() {} func (x *ProfileShowcase) ProtoReflect() protoreflect.Message { - mi := &file_profile_showcase_proto_msgTypes[3] + mi := &file_profile_showcase_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -240,7 +429,7 @@ func (x *ProfileShowcase) ProtoReflect() protoreflect.Message { // Deprecated: Use ProfileShowcase.ProtoReflect.Descriptor instead. func (*ProfileShowcase) Descriptor() ([]byte, []int) { - return file_profile_showcase_proto_rawDescGZIP(), []int{3} + return file_profile_showcase_proto_rawDescGZIP(), []int{6} } func (x *ProfileShowcase) GetForEveryone() *ProfileShowcaseEntries { @@ -269,54 +458,73 @@ var File_profile_showcase_proto protoreflect.FileDescriptor var file_profile_showcase_proto_rawDesc = []byte{ 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x73, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x22, 0x47, 0x0a, 0x14, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, - 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x6e, - 0x74, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x6e, - 0x74, 0x72, 0x79, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x92, 0x02, 0x0a, 0x16, - 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, - 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, - 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, - 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x63, 0x6f, 0x6d, - 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x69, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, - 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x61, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x73, 0x12, 0x42, 0x0a, 0x0c, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, - 0x62, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, - 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x63, 0x6f, 0x6c, 0x6c, - 0x65, 0x63, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x36, 0x0a, 0x06, 0x61, 0x73, 0x73, 0x65, - 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, - 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, - 0x22, 0x77, 0x0a, 0x1f, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, - 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, - 0x74, 0x65, 0x64, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, - 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, - 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, - 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6b, - 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x65, 0x6e, 0x63, 0x72, 0x79, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x73, 0x22, 0x88, 0x02, 0x0a, 0x0f, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x12, 0x43, 0x0a, - 0x0c, 0x66, 0x6f, 0x72, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, - 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, - 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x0b, 0x66, 0x6f, 0x72, 0x45, 0x76, 0x65, 0x72, 0x79, 0x6f, - 0x6e, 0x65, 0x12, 0x4c, 0x0a, 0x0c, 0x66, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, - 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x75, 0x66, 0x22, 0x53, 0x0a, 0x18, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, + 0x77, 0x63, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x12, 0x21, + 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x49, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x8d, 0x01, 0x0a, 0x16, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x19, 0x0a, 0x08, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x6d, 0x6f, 0x6a, 0x69, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x6f, 0x6a, + 0x69, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x44, 0x0a, 0x1a, 0x50, 0x72, 0x6f, 0x66, 0x69, + 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, + 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x44, 0x0a, + 0x14, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, + 0x41, 0x73, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x12, 0x14, 0x0a, + 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x22, 0x9e, 0x02, 0x0a, 0x16, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, + 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x44, + 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, + 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x43, 0x6f, + 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, + 0x74, 0x69, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, + 0x65, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x12, 0x48, 0x0a, 0x0c, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x62, 0x6c, + 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, - 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, - 0x74, 0x65, 0x64, 0x52, 0x0b, 0x66, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, - 0x12, 0x62, 0x0a, 0x18, 0x66, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, - 0x69, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, - 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x52, 0x15, 0x66, - 0x6f, 0x72, 0x49, 0x64, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x74, - 0x61, 0x63, 0x74, 0x73, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x73, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x52, 0x0c, + 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x73, 0x12, 0x36, 0x0a, 0x06, + 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, + 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x06, 0x61, 0x73, + 0x73, 0x65, 0x74, 0x73, 0x22, 0x77, 0x0a, 0x1f, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, + 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x12, 0x2b, 0x0a, 0x11, 0x65, 0x6e, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x65, 0x64, 0x5f, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x10, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x45, 0x6e, 0x74, + 0x72, 0x69, 0x65, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0e, 0x65, + 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x65, 0x79, 0x73, 0x22, 0x88, 0x02, + 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, + 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x66, 0x6f, 0x72, 0x5f, 0x65, 0x76, 0x65, 0x72, 0x79, 0x6f, 0x6e, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, + 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x0b, 0x66, 0x6f, 0x72, 0x45, 0x76, + 0x65, 0x72, 0x79, 0x6f, 0x6e, 0x65, 0x12, 0x4c, 0x0a, 0x0c, 0x66, 0x6f, 0x72, 0x5f, 0x63, 0x6f, + 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, + 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, 0x64, 0x52, 0x0b, 0x66, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x74, + 0x61, 0x63, 0x74, 0x73, 0x12, 0x62, 0x0a, 0x18, 0x66, 0x6f, 0x72, 0x5f, 0x69, 0x64, 0x5f, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x63, 0x61, 0x73, + 0x65, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x65, + 0x64, 0x52, 0x15, 0x66, 0x6f, 0x72, 0x49, 0x64, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, + 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x73, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -331,21 +539,24 @@ func file_profile_showcase_proto_rawDescGZIP() []byte { return file_profile_showcase_proto_rawDescData } -var file_profile_showcase_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_profile_showcase_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_profile_showcase_proto_goTypes = []interface{}{ - (*ProfileShowcaseEntry)(nil), // 0: protobuf.ProfileShowcaseEntry - (*ProfileShowcaseEntries)(nil), // 1: protobuf.ProfileShowcaseEntries - (*ProfileShowcaseEntriesEncrypted)(nil), // 2: protobuf.ProfileShowcaseEntriesEncrypted - (*ProfileShowcase)(nil), // 3: protobuf.ProfileShowcase + (*ProfileShowcaseCommunity)(nil), // 0: protobuf.ProfileShowcaseCommunity + (*ProfileShowcaseAccount)(nil), // 1: protobuf.ProfileShowcaseAccount + (*ProfileShowcaseCollectible)(nil), // 2: protobuf.ProfileShowcaseCollectible + (*ProfileShowcaseAsset)(nil), // 3: protobuf.ProfileShowcaseAsset + (*ProfileShowcaseEntries)(nil), // 4: protobuf.ProfileShowcaseEntries + (*ProfileShowcaseEntriesEncrypted)(nil), // 5: protobuf.ProfileShowcaseEntriesEncrypted + (*ProfileShowcase)(nil), // 6: protobuf.ProfileShowcase } var file_profile_showcase_proto_depIdxs = []int32{ - 0, // 0: protobuf.ProfileShowcaseEntries.communities:type_name -> protobuf.ProfileShowcaseEntry - 0, // 1: protobuf.ProfileShowcaseEntries.accounts:type_name -> protobuf.ProfileShowcaseEntry - 0, // 2: protobuf.ProfileShowcaseEntries.collectibles:type_name -> protobuf.ProfileShowcaseEntry - 0, // 3: protobuf.ProfileShowcaseEntries.assets:type_name -> protobuf.ProfileShowcaseEntry - 1, // 4: protobuf.ProfileShowcase.for_everyone:type_name -> protobuf.ProfileShowcaseEntries - 2, // 5: protobuf.ProfileShowcase.for_contacts:type_name -> protobuf.ProfileShowcaseEntriesEncrypted - 2, // 6: protobuf.ProfileShowcase.for_id_verified_contacts:type_name -> protobuf.ProfileShowcaseEntriesEncrypted + 0, // 0: protobuf.ProfileShowcaseEntries.communities:type_name -> protobuf.ProfileShowcaseCommunity + 1, // 1: protobuf.ProfileShowcaseEntries.accounts:type_name -> protobuf.ProfileShowcaseAccount + 2, // 2: protobuf.ProfileShowcaseEntries.collectibles:type_name -> protobuf.ProfileShowcaseCollectible + 3, // 3: protobuf.ProfileShowcaseEntries.assets:type_name -> protobuf.ProfileShowcaseAsset + 4, // 4: protobuf.ProfileShowcase.for_everyone:type_name -> protobuf.ProfileShowcaseEntries + 5, // 5: protobuf.ProfileShowcase.for_contacts:type_name -> protobuf.ProfileShowcaseEntriesEncrypted + 5, // 6: protobuf.ProfileShowcase.for_id_verified_contacts:type_name -> protobuf.ProfileShowcaseEntriesEncrypted 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name @@ -360,7 +571,7 @@ func file_profile_showcase_proto_init() { } if !protoimpl.UnsafeEnabled { file_profile_showcase_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProfileShowcaseEntry); i { + switch v := v.(*ProfileShowcaseCommunity); i { case 0: return &v.state case 1: @@ -372,7 +583,7 @@ func file_profile_showcase_proto_init() { } } file_profile_showcase_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProfileShowcaseEntries); i { + switch v := v.(*ProfileShowcaseAccount); i { case 0: return &v.state case 1: @@ -384,7 +595,7 @@ func file_profile_showcase_proto_init() { } } file_profile_showcase_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProfileShowcaseEntriesEncrypted); i { + switch v := v.(*ProfileShowcaseCollectible); i { case 0: return &v.state case 1: @@ -396,6 +607,42 @@ func file_profile_showcase_proto_init() { } } file_profile_showcase_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProfileShowcaseAsset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_profile_showcase_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProfileShowcaseEntries); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_profile_showcase_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProfileShowcaseEntriesEncrypted); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_profile_showcase_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ProfileShowcase); i { case 0: return &v.state @@ -414,7 +661,7 @@ func file_profile_showcase_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_profile_showcase_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/protocol/protobuf/profile_showcase.proto b/protocol/protobuf/profile_showcase.proto index 747ce00746d..2c456372713 100644 --- a/protocol/protobuf/profile_showcase.proto +++ b/protocol/protobuf/profile_showcase.proto @@ -3,16 +3,34 @@ syntax = "proto3"; option go_package = "./;protobuf"; package protobuf; -message ProfileShowcaseEntry { - string entry_id = 1; +message ProfileShowcaseCommunity { + string community_id = 1; + uint32 order = 2; +} + +message ProfileShowcaseAccount { + string address = 1; + string name = 2; + string color_id = 3; + string emoji = 4; + uint32 order = 5; +} + +message ProfileShowcaseCollectible { + string uid = 1; + uint32 order = 2; +} + +message ProfileShowcaseAsset { + string symbol = 1; uint32 order = 2; } message ProfileShowcaseEntries { - repeated ProfileShowcaseEntry communities = 1; - repeated ProfileShowcaseEntry accounts = 2; - repeated ProfileShowcaseEntry collectibles = 3; - repeated ProfileShowcaseEntry assets = 4; + repeated ProfileShowcaseCommunity communities = 1; + repeated ProfileShowcaseAccount accounts = 2; + repeated ProfileShowcaseCollectible collectibles = 3; + repeated ProfileShowcaseAsset assets = 4; } message ProfileShowcaseEntriesEncrypted { @@ -20,7 +38,6 @@ message ProfileShowcaseEntriesEncrypted { repeated bytes encryption_keys = 2; } - message ProfileShowcase { ProfileShowcaseEntries for_everyone = 1; ProfileShowcaseEntriesEncrypted for_contacts = 2; diff --git a/services/ext/api.go b/services/ext/api.go index cdba98a7cd3..c5d86192ee8 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -1622,7 +1622,7 @@ func (api *PublicAPI) CreateTokenGatedCommunity() (*protocol.MessengerResponse, } // Set profile showcase preference for current user -func (api *PublicAPI) SetProfileShowcasePreferences(preferences protocol.ProfileShowcasePreferences) error { +func (api *PublicAPI) SetProfileShowcasePreferences(preferences *protocol.ProfileShowcasePreferences) error { return api.service.messenger.SetProfileShowcasePreferences(preferences) }