Skip to content

Feat/search users#74

Merged
maxogod merged 4 commits intodevfrom
feat/search_users
Jun 11, 2025
Merged

Feat/search users#74
maxogod merged 4 commits intodevfrom
feat/search_users

Conversation

@maxogod
Copy link
Copy Markdown
Member

@maxogod maxogod commented Jun 11, 2025

No description provided.

@maxogod maxogod self-assigned this Jun 11, 2025
@maxogod maxogod requested a review from Copilot June 11, 2025 15:20
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/handlers/users/management/management.go 80.76% 11 Missing and 4 partials ⚠️
internal/repository/users/postgres.go 80.76% 4 Missing and 1 partial ⚠️
internal/middleware/jwt_admin.go 86.36% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces new user management endpoints in the router along with corresponding service, repository, middleware, and documentation updates to support user search, account activation, recovery, and administrative user actions (blocking and deletion). Key changes include:

  • Adding routes and middleware for management operations in the router.
  • Implementing DeleteUser, GetUsers, and GetBlockStatus in both Postgres and in-memory repositories.
  • Updating tests, DTOs, and Swagger documentation to support the new endpoints.

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/router/router_test.go Added new routes for auth and management endpoints.
internal/router/router.go Added new middleware and management route initialization.
internal/router/management_router.go Created new management routes for user operations.
internal/repository/users/repository.go & postgres.go Added DeleteUser, GetUsers, GetBlockStatus methods with error handling.
internal/repository/memory/users.go Added corresponding implementations for in-memory repository.
internal/middleware/jwt_admin.go & jwt_admin_test.go Implemented and tested JWT admin middleware.
internal/handlers/users/management/* Implemented management handler endpoints and tests.
docs/* Updated Swagger docs to reflect new endpoints and DTO definitions.
config/config.go Updated config to include PAGE_SIZE, BLOCK_DURATION, and related environment helpers.

func (r *inMemoryUsersRepository) GetBlockStatus(id uuid.UUID) (*models.Block, error) {
blockedUntil, exists := r.blocksDB[id]
if !exists {
return nil, errors.NewNotFoundError("user not found")
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The in-memory repository returns 'user not found' for GetBlockStatus while the Postgres implementation returns 'block status not found'. Consider aligning these error messages for consistency across implementations.

Suggested change
return nil, errors.NewNotFoundError("user not found")
return nil, errors.NewNotFoundError("block status not found")

Copilot uses AI. Check for mistakes.
assert.Equal(t, http.StatusBadRequest, w.Code)

req, _ = http.NewRequest("PUT", "/management/block_status/"+userID.String(), bytes.NewBuffer([]byte("invalid json")))
req.Header.Set("Content-Type", "application/json")
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider creating a new httptest.ResponseRecorder for each ServeHTTP call in TestUpdateUserBlockStatus_BadRequest to ensure that responses from previous requests do not affect subsequent assertions.

Suggested change
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Content-Type", "application/json")
w = httptest.NewRecorder()

Copilot uses AI. Check for mistakes.
@maxogod maxogod merged commit 0b7959c into dev Jun 11, 2025
2 checks passed
@maxogod maxogod deleted the feat/search_users branch June 11, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants