forked from mirrors/protonmail-bridge-docker
Initial commit for http rest bridge
This commit is contained in:
24
http_rest_frontend/cli/accounts_util.go
Normal file
24
http_rest_frontend/cli/accounts_util.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/frontend/types"
|
||||
)
|
||||
|
||||
func (f *frontendCLI) getUserByIndexOrName(account string) types.User {
|
||||
users := f.bridge.GetUsers()
|
||||
numberOfAccounts := len(users)
|
||||
if index, err := strconv.Atoi(account); err == nil {
|
||||
if index < 0 || index >= numberOfAccounts {
|
||||
return nil
|
||||
}
|
||||
return users[index]
|
||||
}
|
||||
for _, user := range users {
|
||||
if user.Username() == account {
|
||||
return user
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user