chore: update user definition

This commit is contained in:
Steven
2023-11-05 23:03:43 +08:00
parent e67820cabe
commit e60e47f76f
21 changed files with 323 additions and 280 deletions

View File

@@ -10,6 +10,7 @@ import (
)
const (
UserNamePrefix = "users/"
InboxNamePrefix = "inboxes/"
)
@@ -33,6 +34,15 @@ func GetNameParentTokens(name string, tokenPrefixes ...string) ([]string, error)
return tokens, nil
}
// GetUsername returns the username from a resource name.
func GetUsername(name string) (string, error) {
tokens, err := GetNameParentTokens(name, UserNamePrefix)
if err != nil {
return "", err
}
return tokens[0], nil
}
// GetInboxID returns the inbox ID from a resource name.
func GetInboxID(name string) (int32, error) {
tokens, err := GetNameParentTokens(name, InboxNamePrefix)