Commit 480c53d7 authored by Steven's avatar Steven

chore: fix id converter

parent 2b7d7c95
......@@ -2,10 +2,11 @@ package v2
import (
"fmt"
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/usememos/memos/internal/util"
)
const (
......@@ -38,9 +39,9 @@ func GetInboxID(name string) (int32, error) {
if err != nil {
return 0, err
}
id, err := strconv.Atoi(tokens[0])
id, err := util.ConvertStringToInt32(tokens[0])
if err != nil {
return 0, errors.Errorf("invalid inbox ID %q", tokens[0])
}
return int32(id), nil
return id, nil
}
......@@ -12,11 +12,11 @@ import (
// ConvertStringToInt32 converts a string to int32.
func ConvertStringToInt32(src string) (int32, error) {
i, err := strconv.Atoi(src)
parsed, err := strconv.ParseInt(src, 10, 32)
if err != nil {
return 0, err
}
return int32(i), nil
return int32(parsed), nil
}
// HasPrefixes returns true if the string s has any of the given prefixes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment