Documentation
¶
Index ¶
- func IsNotFoundError(err error) bool
- func IsUserError(err error) bool
- func IsValidationError(err error) bool
- type ListUsersRequest
- type ListUsersResponse
- type Service
- func (s *Service) DeleteUser(ctx context.Context, userID uuid.UUID, hardDelete bool) error
- func (s *Service) GetUser(ctx context.Context, userID uuid.UUID) (*UserInfo, error)
- func (s *Service) GetUserByEmail(ctx context.Context, email string) (*UserInfo, error)
- func (s *Service) GetUserPreferences(ctx context.Context, userID uuid.UUID) (*UserPreferences, error)
- func (s *Service) ListUsers(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error)
- func (s *Service) RestoreUser(ctx context.Context, userID uuid.UUID) (*UserInfo, error)
- func (s *Service) UpdateUser(ctx context.Context, userID uuid.UUID, req UpdateUserRequest) (*UserInfo, error)
- func (s *Service) UpdateUserAdmin(ctx context.Context, userID uuid.UUID, isAdmin bool) (*UserInfo, error)
- func (s *Service) UpdateUserPassword(ctx context.Context, userID uuid.UUID, req UpdatePasswordRequest) error
- func (s *Service) UpdateUserPreferences(ctx context.Context, userID uuid.UUID, req UpdateUserPreferencesRequest) (*UserPreferences, error)
- type UpdatePasswordRequest
- type UpdateUserPreferencesRequest
- type UpdateUserRequest
- type UserError
- func NewDatabaseError(message string, err error) *UserError
- func NewInvalidUserIDError(message string, err error) *UserError
- func NewUnauthorizedError(message string) *UserError
- func NewUserError(errorType UserErrorType, message string, err error) *UserError
- func NewUserNotFoundError(message string) *UserError
- type UserErrorType
- type UserInfo
- type UserPreferences
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFoundError ¶
IsNotFoundError checks if an error is a user not found error
func IsValidationError ¶
IsValidationError checks if an error is a validation error
Types ¶
type ListUsersRequest ¶
type ListUsersRequest struct { Limit int `json:"limit"` Offset int `json:"offset"` IncludeDeleted bool `json:"includeDeleted"` }
ListUsersRequest represents a request to list users
type ListUsersResponse ¶
type ListUsersResponse struct { Users []*UserInfo `json:"users"` Total int `json:"total"` Limit int `json:"limit"` Offset int `json:"offset"` }
ListUsersResponse represents the response from listing users
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles user management operations
func NewService ¶
NewService creates a new user management service
func (*Service) DeleteUser ¶
DeleteUser soft-deletes a user (sets deletedAt timestamp)
func (*Service) GetUserByEmail ¶
GetUserByEmail retrieves a user by email address
func (*Service) GetUserPreferences ¶
func (s *Service) GetUserPreferences(ctx context.Context, userID uuid.UUID) (*UserPreferences, error)
GetUserPreferences retrieves user preferences
func (*Service) ListUsers ¶
func (s *Service) ListUsers(ctx context.Context, req ListUsersRequest) (*ListUsersResponse, error)
ListUsers retrieves all users with pagination
func (*Service) RestoreUser ¶
RestoreUser restores a soft-deleted user
func (*Service) UpdateUser ¶
func (s *Service) UpdateUser(ctx context.Context, userID uuid.UUID, req UpdateUserRequest) (*UserInfo, error)
UpdateUser updates user profile information
func (*Service) UpdateUserAdmin ¶
func (s *Service) UpdateUserAdmin(ctx context.Context, userID uuid.UUID, isAdmin bool) (*UserInfo, error)
UpdateUserAdmin updates a user's admin status
func (*Service) UpdateUserPassword ¶
func (s *Service) UpdateUserPassword(ctx context.Context, userID uuid.UUID, req UpdatePasswordRequest) error
UpdateUserPassword updates a user's password (admin function)
func (*Service) UpdateUserPreferences ¶
func (s *Service) UpdateUserPreferences(ctx context.Context, userID uuid.UUID, req UpdateUserPreferencesRequest) (*UserPreferences, error)
UpdateUserPreferences updates user preferences
type UpdatePasswordRequest ¶
type UpdatePasswordRequest struct {
NewPassword string `json:"newPassword"`
}
UpdatePasswordRequest represents a request to update a user's password
type UpdateUserPreferencesRequest ¶
type UpdateUserPreferencesRequest struct { EmailNotifications *bool `json:"emailNotifications,omitempty"` DownloadIncludeEmbeddedVideos *bool `json:"downloadIncludeEmbeddedVideos,omitempty"` FoldersEnabled *bool `json:"foldersEnabled,omitempty"` MemoriesEnabled *bool `json:"memoriesEnabled,omitempty"` PeopleEnabled *bool `json:"peopleEnabled,omitempty"` PeopleSizeThreshold *int32 `json:"peopleSizeThreshold,omitempty"` TagsEnabled *bool `json:"tagsEnabled,omitempty"` TagsSizeThreshold *int32 `json:"tagsSizeThreshold,omitempty"` }
UpdateUserPreferencesRequest represents a request to update user preferences
type UpdateUserRequest ¶
type UpdateUserRequest struct { Name *string `json:"name,omitempty"` Email *string `json:"email,omitempty"` AvatarColor *string `json:"avatarColor,omitempty"` ProfileImagePath *string `json:"profileImagePath,omitempty"` QuotaSizeInBytes *int64 `json:"quotaSizeInBytes,omitempty"` StorageLabel *string `json:"storageLabel,omitempty"` }
UpdateUserRequest represents a request to update user information
type UserError ¶
type UserError struct { Type UserErrorType `json:"type"` Message string `json:"message"` Err error `json:"-"` }
UserError represents errors that can occur in user operations
func NewDatabaseError ¶
NewDatabaseError creates a database error
func NewInvalidUserIDError ¶
NewInvalidUserIDError creates an invalid user ID error
func NewUnauthorizedError ¶
NewUnauthorizedError creates an unauthorized error
func NewUserError ¶
func NewUserError(errorType UserErrorType, message string, err error) *UserError
NewUserError creates a new user error
func NewUserNotFoundError ¶
NewUserNotFoundError creates a user not found error
type UserErrorType ¶
type UserErrorType string
UserErrorType represents different types of user errors
const ( ErrInvalidUserID UserErrorType = "invalid_user_id" ErrUserNotFound UserErrorType = "user_not_found" ErrUserDeleted UserErrorType = "user_deleted" ErrUserExists UserErrorType = "user_exists" ErrInvalidPassword UserErrorType = "invalid_password" ErrPasswordHashing UserErrorType = "password_hashing" ErrDatabaseError UserErrorType = "database_error" ErrInvalidInput UserErrorType = "invalid_input" )
func GetUserErrorType ¶
func GetUserErrorType(err error) UserErrorType
GetUserErrorType returns the type of a UserError
type UserInfo ¶
type UserInfo struct { ID uuid.UUID `json:"id"` Email string `json:"email"` Name string `json:"name"` IsAdmin bool `json:"isAdmin"` ShouldChangePassword bool `json:"shouldChangePassword"` Status string `json:"status"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` QuotaUsageInBytes int64 `json:"quotaUsageInBytes"` OAuthID string `json:"oauthId"` ProfileImagePath *string `json:"profileImagePath,omitempty"` StorageLabel *string `json:"storageLabel,omitempty"` QuotaSizeInBytes *int64 `json:"quotaSizeInBytes,omitempty"` AvatarColor *string `json:"avatarColor,omitempty"` ProfileChangedAt *time.Time `json:"profileChangedAt,omitempty"` DeletedAt *time.Time `json:"deletedAt,omitempty"` }
UserInfo represents user information
type UserPreferences ¶
type UserPreferences struct { UserID uuid.UUID `json:"userId"` EmailNotifications *bool `json:"emailNotifications,omitempty"` DownloadIncludeEmbeddedVideos *bool `json:"downloadIncludeEmbeddedVideos,omitempty"` FoldersEnabled *bool `json:"foldersEnabled,omitempty"` MemoriesEnabled *bool `json:"memoriesEnabled,omitempty"` PeopleEnabled *bool `json:"peopleEnabled,omitempty"` PeopleSizeThreshold *int32 `json:"peopleSizeThreshold,omitempty"` TagsEnabled *bool `json:"tagsEnabled,omitempty"` TagsSizeThreshold *int32 `json:"tagsSizeThreshold,omitempty"` }
UserPreferences represents user preferences