forked from Silverfish/proton-bridge
Other: Switch from liteapi to go-proton-api
This commit is contained in:
@ -23,7 +23,7 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"gitlab.protontech.ch/go/liteapi"
|
||||
"github.com/ProtonMail/go-proton-api"
|
||||
"golang.org/x/exp/maps"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
@ -80,7 +80,7 @@ func b64Decode(b []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
// getAddrID returns the address ID for the given email address.
|
||||
func getAddrID(apiAddrs map[string]liteapi.Address, email string) (string, error) {
|
||||
func getAddrID(apiAddrs map[string]proton.Address, email string) (string, error) {
|
||||
for _, addr := range apiAddrs {
|
||||
if strings.EqualFold(addr.Email, sanitizeEmail(email)) {
|
||||
return addr.ID, nil
|
||||
@ -91,13 +91,13 @@ func getAddrID(apiAddrs map[string]liteapi.Address, email string) (string, error
|
||||
}
|
||||
|
||||
// getAddrIdx returns the address with the given index.
|
||||
func getAddrIdx(apiAddrs map[string]liteapi.Address, idx int) (liteapi.Address, error) {
|
||||
sorted := sortSlice(maps.Values(apiAddrs), func(a, b liteapi.Address) bool {
|
||||
func getAddrIdx(apiAddrs map[string]proton.Address, idx int) (proton.Address, error) {
|
||||
sorted := sortSlice(maps.Values(apiAddrs), func(a, b proton.Address) bool {
|
||||
return a.Order < b.Order
|
||||
})
|
||||
|
||||
if idx < 0 || idx >= len(sorted) {
|
||||
return liteapi.Address{}, fmt.Errorf("address index %d out of range", idx)
|
||||
return proton.Address{}, fmt.Errorf("address index %d out of range", idx)
|
||||
}
|
||||
|
||||
return sorted[idx], nil
|
||||
|
||||
Reference in New Issue
Block a user