Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: soft delete user #97

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading