feat: make store use ClientManager

This commit is contained in:
James Houlahan
2020-04-07 09:55:28 +02:00
parent f269be4291
commit 042c340881
43 changed files with 414 additions and 264 deletions

View File

@ -18,9 +18,7 @@
package liveapi
import (
"fmt"
"os"
"github.com/ProtonMail/bridge/pkg/pmapi"
"github.com/cucumber/godog"
"github.com/pkg/errors"
)
@ -30,11 +28,7 @@ func (cntrl *Controller) AddUser(user *pmapi.User, addresses *pmapi.AddressList,
return godog.ErrPending
}
client := pmapi.NewClient(&pmapi.ClientConfig{
AppVersion: fmt.Sprintf("Bridge_%s", os.Getenv("VERSION")),
ClientID: "bridge-cntrl",
TokenManager: pmapi.NewTokenManager(),
}, user.ID)
client := cntrl.clientManager.GetClient(user.ID)
authInfo, err := client.AuthInfo(user.Name)
if err != nil {
@ -60,6 +54,5 @@ func (cntrl *Controller) AddUser(user *pmapi.User, addresses *pmapi.AddressList,
return errors.Wrap(err, "failed to clean user")
}
cntrl.pmapiByUsername[user.Name] = client
return nil
}