Removed all usages of custion utils.Filter function in favour of built-in slices DeleteFunc. Updated utils.ReadMessage to read with 8192 sized chunks to reduce the risk of running into a blocking read call when the end of the input is reached.

This commit is contained in:
Kelvin Clement Mwinuka
2024-02-28 06:34:11 +08:00
parent 369aa3ba89
commit 6566bb41c4
6 changed files with 42 additions and 60 deletions

View File

@@ -1,7 +1,6 @@
package acl
import (
"github.com/echovault/echovault/src/utils"
"slices"
"strings"
)
@@ -105,18 +104,18 @@ func (user *User) UpdateUser(cmd []string) error {
continue
}
if str[0] == '<' {
user.Passwords = utils.Filter(user.Passwords, func(password Password) bool {
user.Passwords = slices.DeleteFunc(user.Passwords, func(password Password) bool {
if strings.EqualFold(password.PasswordType, "SHA256") {
return true
return false
}
return password.PasswordValue == str[1:]
})
continue
}
if str[0] == '!' {
user.Passwords = utils.Filter(user.Passwords, func(password Password) bool {
user.Passwords = slices.DeleteFunc(user.Passwords, func(password Password) bool {
if strings.EqualFold(password.PasswordType, "plaintext") {
return true
return false
}
return password.PasswordValue == str[1:]
})