GODT-1740: Opt-out All Mail visibility in settings file.

This commit is contained in:
Jakub
2022-07-28 10:52:40 +02:00
parent 252ca9a5f9
commit 8b39ea4acb
9 changed files with 100 additions and 13 deletions

View File

@ -20,6 +20,7 @@ package fakeapi
import (
"context"
"fmt"
"strings"
"github.com/ProtonMail/proton-bridge/v2/pkg/pmapi"
)
@ -94,9 +95,16 @@ func (api *FakePMAPI) createLabel(_ context.Context, label *pmapi.Label, route s
if err := api.checkAndRecordCall(POST, route, &pmapi.LabelReq{Label: label}); err != nil {
return nil, err
}
// API blocks certain names
switch strings.ToLower(label.Name) {
case "inbox", "drafts", "trash", "spam", "starred":
return nil, fmt.Errorf("Invalid name") //nolint:stylecheck
}
for _, existingLabel := range api.labels {
if existingLabel.Name == label.Name {
return nil, fmt.Errorf("folder or label %s already exists", label.Name)
return nil, fmt.Errorf("A label or folder with this name already exists") //nolint:stylecheck
}
}
prefix := "label"