Skip to content

Commit

Permalink
feat: soft delete user
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed Oct 8, 2024
1 parent 835d580 commit 44019f4
Show file tree
Hide file tree
Showing 18 changed files with 3,148 additions and 2,191 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2)

.PHONY: build check fmt lint test test-race vet test-cover-html help install proto
.DEFAULT_GOAL := build
PROTON_COMMIT := "4165013edcadd3b5de3136e1ad93e6d4fbdfba44"
PROTON_COMMIT := "e0c6ae65649c06de6e3dd9af5028ea583a9ed999"

install:
@echo "Clean up imports..."
Expand Down
4 changes: 2 additions & 2 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func StartServer(logger *log.Zap, cfg *config.Shield) error {
activityService := activity.NewService(appConfig, activityRepository)

userRepository := postgres.NewUserRepository(dbClient)
userService := user.NewService(logger, userRepository, activityService)
userService := user.NewService(logger, user.Config{InactiveEmailTag: cfg.App.InactiveEmailTag}, userRepository, activityService)

actionRepository := postgres.NewActionRepository(dbClient)
actionService := action.NewService(logger, actionRepository, userService, activityService)
Expand Down Expand Up @@ -231,7 +231,7 @@ func BuildAPIDependencies(
activityService := activity.NewService(appConfig, activityRepository)

userRepository := postgres.NewUserRepository(dbc)
userService := user.NewService(logger, userRepository, activityService)
userService := user.NewService(logger, user.Config{InactiveEmailTag: cfg.App.InactiveEmailTag}, userRepository, activityService)

actionRepository := postgres.NewActionRepository(dbc)
actionService := action.NewService(logger, actionRepository, userService, activityService)
Expand Down
96 changes: 96 additions & 0 deletions core/user/mocks/user_repository.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion core/user/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ type ActivityService interface {

type Service struct {
logger log.Logger
config Config
repository Repository
activityService ActivityService
}

func NewService(logger log.Logger, repository Repository, activityService ActivityService) *Service {
func NewService(logger log.Logger, config Config, repository Repository, activityService ActivityService) *Service {
return &Service{
logger: logger,
config: config,
repository: repository,
activityService: activityService,
}
Expand Down Expand Up @@ -210,3 +212,10 @@ func (s Service) FetchCurrentUser(ctx context.Context) (User, error) {

return fetchedUser, nil
}

func (s Service) Delete(ctx context.Context, id string) error {
if uuid.IsValid(id) {
return s.repository.DeleteById(ctx, id, s.config.InactiveEmailTag)
}
return s.repository.DeleteByEmail(ctx, id, s.config.InactiveEmailTag)
}
Loading

0 comments on commit 44019f4

Please sign in to comment.