feat(API): optional display name on users
This commit is contained in:
1 parent
792aba433d
commit
7aae704d0a
22 files changed
+1051
-40
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package useCases
|
||||
|
||||
import (
|
||||
"RenewCMS/internal/domain/user"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
const maxDisplayNameRunes = 60
|
||||
|
||||
type UpdateUserProfileUseCase struct {
|
||||
userRepository user.Repository
|
||||
}
|
||||
|
||||
func NewUpdateUserProfileUseCase(userRepository user.Repository) *UpdateUserProfileUseCase {
|
||||
return &UpdateUserProfileUseCase{userRepository}
|
||||
}
|
||||
|
||||
func (u *UpdateUserProfileUseCase) UpdateDisplayName(userId uint32, displayName string) (user.User, error) {
|
||||
trimmed := strings.TrimSpace(displayName)
|
||||
if utf8.RuneCountInString(trimmed) > maxDisplayNameRunes {
|
||||
return user.User{}, user.ErrInvalidDisplayName
|
||||
}
|
||||
return u.userRepository.UpdateDisplayName(userId, trimmed)
|
||||
}
|
||||
Reference in new issue
Block a user