mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 13:16:53 +00:00
GODT-1742: Implement hide All Mail
This commit is contained in:
committed by
James Houlahan
parent
395e7b54f6
commit
a7a7d9a3d4
@ -22,6 +22,7 @@ import (
|
||||
"crypto/subtle"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/ProtonMail/gluon/connector"
|
||||
@ -54,9 +55,11 @@ type User struct {
|
||||
|
||||
syncStopCh chan struct{}
|
||||
syncLock try.Group
|
||||
|
||||
showAllMail int32
|
||||
}
|
||||
|
||||
func New(ctx context.Context, encVault *vault.User, client *liteapi.Client, apiUser liteapi.User) (*User, error) { //nolint:funlen
|
||||
func New(ctx context.Context, encVault *vault.User, client *liteapi.Client, apiUser liteapi.User, showAllMail bool) (*User, error) { //nolint:funlen
|
||||
// Get the user's API addresses.
|
||||
apiAddrs, err := client.GetAddresses(ctx)
|
||||
if err != nil {
|
||||
@ -111,6 +114,8 @@ func New(ctx context.Context, encVault *vault.User, client *liteapi.Client, apiU
|
||||
syncStopCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
user.SetShowAllMail(showAllMail)
|
||||
|
||||
// When we receive an auth object, we update it in the vault.
|
||||
// This will be used to authorize the user on the next run.
|
||||
user.client.AddAuthHandler(func(auth liteapi.Auth) {
|
||||
@ -390,6 +395,20 @@ func (user *User) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user *User) SetShowAllMail(show bool) {
|
||||
var value int32
|
||||
if show {
|
||||
value = 1
|
||||
} else {
|
||||
value = 0
|
||||
}
|
||||
atomic.StoreInt32(&user.showAllMail, value)
|
||||
}
|
||||
|
||||
func (user *User) GetShowAllMail() bool {
|
||||
return atomic.LoadInt32(&user.showAllMail) == 1
|
||||
}
|
||||
|
||||
func (user *User) checkAuth(email string, password []byte) (string, error) {
|
||||
dec, err := hexDecode(password)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user