diff --git a/go.mod b/go.mod index 4819274a..465b3829 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/Masterminds/semver/v3 v3.2.0 github.com/ProtonMail/gluon v0.16.1-0.20230508105645-e4f4a844ccae github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a - github.com/ProtonMail/go-proton-api v0.4.1-0.20230426081144-f77778bae1be + github.com/ProtonMail/go-proton-api v0.4.1-0.20230505091503-167f3d239b0c github.com/ProtonMail/gopenpgp/v2 v2.7.1-proton github.com/PuerkitoBio/goquery v1.8.1 github.com/abiosoft/ishell v2.0.0+incompatible diff --git a/go.sum b/go.sum index d4dba3bc..4a7c0b88 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,8 @@ github.com/ProtonMail/go-message v0.0.0-20210611055058-fabeff2ec753 h1:I8IsYA297 github.com/ProtonMail/go-message v0.0.0-20210611055058-fabeff2ec753/go.mod h1:NBAn21zgCJ/52WLDyed18YvYFm5tEoeDauubFqLokM4= github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ekTTXpdwKYF8eBlsYsDVoggDAuAjoK66k= github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw= -github.com/ProtonMail/go-proton-api v0.4.1-0.20230426081144-f77778bae1be h1:TNHnEyUQDf97CRGCFWLxg7I5ASSEMO3TN2lbNw2cD6U= -github.com/ProtonMail/go-proton-api v0.4.1-0.20230426081144-f77778bae1be/go.mod h1:UkrG9gN2o9mzdx/an0XRc6a4s5Haef1A7Eyd2iXlw28= +github.com/ProtonMail/go-proton-api v0.4.1-0.20230505091503-167f3d239b0c h1:uqo3mKt4ffhqPFLVV7VxjuN12DAFQmqEju/Wy5dk6Rk= +github.com/ProtonMail/go-proton-api v0.4.1-0.20230505091503-167f3d239b0c/go.mod h1:UkrG9gN2o9mzdx/an0XRc6a4s5Haef1A7Eyd2iXlw28= github.com/ProtonMail/go-srp v0.0.5 h1:xhUioxZgDbCnpo9JehyFhwwsn9JLWkUGfB0oiKXgiGg= github.com/ProtonMail/go-srp v0.0.5/go.mod h1:06iYHtLXW8vjLtccWj++x3MKy65sIT8yZd7nrJF49rs= github.com/ProtonMail/gopenpgp/v2 v2.7.1-proton h1:YS6M20yvjCJPR1r4ADW5TPn6rahs4iAyZaACei86bEc= diff --git a/internal/bridge/user_test.go b/internal/bridge/user_test.go index 135c8f23..d8767110 100644 --- a/internal/bridge/user_test.go +++ b/internal/bridge/user_test.go @@ -708,6 +708,25 @@ func TestBridge_User_Refresh(t *testing.T) { }) } +func TestBridge_User_GetAddresses(t *testing.T) { + withEnv(t, func(ctx context.Context, s *server.Server, netCtl *proton.NetCtl, locator bridge.Locator, storeKey []byte) { + // Create a user. + userID, _, err := s.CreateUser("user", password) + require.NoError(t, err) + addrID2, err := s.CreateAddress(userID, "user@external.com", []byte("password")) + require.NoError(t, err) + require.NoError(t, s.ChangeAddressType(userID, addrID2, proton.AddressTypeExternal)) + + withBridge(ctx, t, s.GetHostURL(), netCtl, locator, storeKey, func(bridge *bridge.Bridge, _ *bridge.Mocks) { + userLoginAndSync(ctx, t, bridge, "user", password) + info, err := bridge.GetUserInfo(userID) + require.NoError(t, err) + require.Equal(t, 1, len(info.Addresses)) + require.Equal(t, info.Addresses[0], "user@proton.local") + }) + }) +} + // getErr returns the error that was passed to it. func getErr[T any](_ T, err error) error { return err diff --git a/internal/user/user.go b/internal/user/user.go index d8418330..3e601b9c 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -282,7 +282,7 @@ func (user *User) Match(query string) bool { func (user *User) Emails() []string { return safe.RLockRet(func() []string { addresses := xslices.Filter(maps.Values(user.apiAddrs), func(addr proton.Address) bool { - return addr.Status == proton.AddressStatusEnabled + return addr.Status == proton.AddressStatusEnabled && addr.Type != proton.AddressTypeExternal }) slices.SortFunc(addresses, func(a, b proton.Address) bool {