Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
Types ¶
type ConfirmAccountResponse ¶ added in v0.3.0
type ConfirmAccountResponse struct {
// contains filtered or unexported fields
}
ConfirmAccountResponse holds data coming from the token generator.
type CreateUserRequest ¶
type CreateUserRequest struct {
Email string `json:"email" validate:"required,email"`
Username string `json:"username" validate:"required,alphanum,min=1,max=20"`
Password string `json:"password" validate:"required,min=8,max=30"`
}
CreateUserRequest represents a user creation request.
type Repository ¶
type Repository interface {
// Get returns the user with the specified user ID.
Get(ctx context.Context, id string) (entity.User, error)
// Count returns the number of users.
Count(ctx context.Context) (int, error)
// Query returns the list of users with the given offset and limit.
Query(ctx context.Context, offset, limit int) ([]entity.User, error)
// Create saves a new user in the storage.
Create(ctx context.Context, User entity.User) error
// Update updates the user with given ID in the storage.
Update(ctx context.Context, User entity.User) error
// Patch patches a sub entry in the user with given ID in the storage.
Patch(ctx context.Context, key, path string, val interface{}) error
// Delete removes the user with given ID from the storage.
Delete(ctx context.Context, id string) error
EmailExists(ctx context.Context, email string) (bool, error)
GetByEmail(ctx context.Context, email string) (entity.User, error)
Likes(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Followers(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Following(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Submissions(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Comments(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Activities(ctx context.Context, id string, offset, limit int) ([]interface{}, error)
CountActivities(ctx context.Context) (int, error)
DeleteActivity(ctx context.Context, kind, username, target string) error
}
Repository encapsulates the logic to access users from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new user repository.
type Service ¶
type Service interface {
Get(ctx context.Context, id string) (User, error)
Query(ctx context.Context, offset, limit int) ([]User, error)
Count(ctx context.Context) (int, error)
Create(ctx context.Context, input CreateUserRequest) (User, error)
Update(ctx context.Context, id string, input interface{}) (User, error)
Patch(ctx context.Context, id, path string, input interface{}) error
Delete(ctx context.Context, id string) (User, error)
Activities(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Likes(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Followers(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Following(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Submissions(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
Comments(ctx context.Context, id string, offset, limit int) (
[]interface{}, error)
CountActivities(ctx context.Context) (int, error)
CountLikes(ctx context.Context, id string) (int, error)
CountFollowing(ctx context.Context, id string) (int, error)
CountFollowers(ctx context.Context, id string) (int, error)
CountComments(ctx context.Context, id string) (int, error)
CountSubmissions(ctx context.Context, id string) (int, error)
Follow(ctx context.Context, id string) error
Unfollow(ctx context.Context, id string) error
GetByEmail(ctx context.Context, id string) (User, error)
UpdateAvatar(ctx context.Context, id string, src io.Reader) error
UpdatePassword(ctx context.Context, input UpdatePasswordRequest) error
UpdateEmail(ctx context.Context, input UpdateEmailRequest) error
GenerateConfirmationEmail(ctx context.Context, user User) (
ConfirmAccountResponse, error)
}
Service encapsulates usecase logic for users.
func NewService ¶
func NewService(repo Repository, logger log.Logger, tokenGen secure.TokenGenerator, sec secure.Password, bucket string, upl Uploader, actSvc activity.Service) Service
NewService creates a new user service.
type UpdateEmailRequest ¶ added in v0.3.0
type UpdateEmailRequest struct {
Password string `json:"password" validate:"required,min=8,max=30"`
NewEmail string `json:"email" validate:"required,email"`
}
UpdateEmailRequest represents an email update request.
type UpdatePasswordRequest ¶ added in v0.3.0
type UpdatePasswordRequest struct {
OldPassword string `json:"old" validate:"required,min=8,max=30"`
NewPassword string `json:"new" validate:"required,necsfield=OldPassword,min=8,max=30"`
}
UpdatePasswordRequest represents a password update request.
type UpdateUserRequest ¶
type UpdateUserRequest struct {
Name string `json:"name" validate:"omitempty,min=1,max=32"`
Location string `json:"location" validate:"omitempty,min=1,max=16"`
URL string `json:"url" validate:"omitempty,url,max=64"`
Bio string `json:"bio" validate:"omitempty,min=1,max=64"`
}
UpdateUserRequest represents a user update request.
Click to show internal directories.
Click to hide internal directories.