users

package
v0.0.0-...-bf3ae6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if an error is a user not found error

func IsUserError

func IsUserError(err error) bool

IsUserError checks if an error is a UserError

func IsValidationError

func IsValidationError(err error) bool

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

func NewService(queries *sqlc.Queries, cfg *config.Config) (*Service, error)

NewService creates a new user management service

func (*Service) DeleteUser

func (s *Service) DeleteUser(ctx context.Context, userID uuid.UUID, hardDelete bool) error

DeleteUser soft-deletes a user (sets deletedAt timestamp)

func (*Service) GetUser

func (s *Service) GetUser(ctx context.Context, userID uuid.UUID) (*UserInfo, error)

GetUser retrieves a user by ID

func (*Service) GetUserByEmail

func (s *Service) GetUserByEmail(ctx context.Context, email string) (*UserInfo, error)

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

func (s *Service) RestoreUser(ctx context.Context, userID uuid.UUID) (*UserInfo, error)

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"`
	SharedLinksEnabled            *bool  `json:"sharedLinksEnabled,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

func NewDatabaseError(message string, err error) *UserError

NewDatabaseError creates a database error

func NewInvalidUserIDError

func NewInvalidUserIDError(message string, err error) *UserError

NewInvalidUserIDError creates an invalid user ID error

func NewUnauthorizedError

func NewUnauthorizedError(message string) *UserError

NewUnauthorizedError creates an unauthorized error

func NewUserError

func NewUserError(errorType UserErrorType, message string, err error) *UserError

NewUserError creates a new user error

func NewUserNotFoundError

func NewUserNotFoundError(message string) *UserError

NewUserNotFoundError creates a user not found error

func (*UserError) Error

func (e *UserError) Error() string

func (*UserError) Unwrap

func (e *UserError) Unwrap() 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"
	ErrUnauthorized    UserErrorType = "unauthorized"
	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"`
	SharedLinksEnabled            *bool     `json:"sharedLinksEnabled,omitempty"`
	TagsEnabled                   *bool     `json:"tagsEnabled,omitempty"`
	TagsSizeThreshold             *int32    `json:"tagsSizeThreshold,omitempty"`
}

UserPreferences represents user preferences

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL