Skip to content

Conversation

@kastov
Copy link
Contributor

@kastov kastov commented Dec 28, 2025

No description provided.

@snyk-io
Copy link

snyk-io bot commented Dec 28, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@what-the-diff
Copy link

what-the-diff bot commented Dec 28, 2025

PR Summary

  • New Event Scopes and Webhook Models
    The update added a new EVENTS_SCOPES constant for various event scopes and created a new webhook model with detailed schemas for different events (such as user and service events). These allow us to handle a broader range of scenarios and improve data accuracy.

  • Package and Dependency Upgrades
    The package version of @remnawave/backend-contract has been upgraded, and several dependencies have been updated, improving the system complexity while also ensuring security and performance.

  • User Handling Enhancements
    The 'AxiosService' now includes methods for handling bulk user operations, allowing for smoother and faster operations when managing users.

  • Event Handling Extensions
    The event handling capacity has been extended, offering increased versatility when dealing with webhooks.

  • New Events Management
    New features for adding users to nodes have been introduced, such as the AddUsersToNodeEvent and AddUsersToNodeHandler. These are designed to increase the ease and efficiency of user management.

  • Improved Documentation
    The documentation generation includes new webhook event models, ensuring accurate and up-to-date information.

  • Node and User Manipulation Enhancements
    Further methods, queries, and handlers targeting user and node functionality have been developed, such as the RemoveUsersFromNodeEvent and RemoveUsersFromNodeHandler, and the GetUsersWithResolvedInboundsQuery.

  • UsersService and UsersRepository expansions
    The UsersRepository now provides more methods for fetching data, and UsersService has been updated to accommodate new events. These changes have led to improved user request handling and user data management.

  • Bulk User Operation Improvements
    For mass user operations, the handling mechanisms have been improved, including the introduction of a new queue processor NodeBulkUsersQueueProcessor, offering more efficient processing for these tasks.

  • Queue and Processor Structure Enhancement
    The job registration and processors have been modified to handle new bulk operations. These optimizations should result in improved job handling benchmarks.

@greptile-apps
Copy link

greptile-apps bot commented Dec 28, 2025

Greptile Summary

This release (v2.5.0) introduces bulk user management capabilities and enhances webhook event handling with scope-based categorization.

Major Changes:

  • Implemented bulk user add/remove operations for nodes via new event-driven architecture (AddUsersToNodeEvent, RemoveUsersFromNodeEvent)
  • Added dedicated BULK_USERS queue with NodeBulkUsersProcessor for handling bulk operations (concurrency: 20)
  • Refactored bulkDeleteUsersByUuid and bulkUpdateUsersInternalSquads to use targeted user sync instead of full node restarts
  • Added EVENTS_SCOPES constant and updated all webhook payloads to include scope field for better event categorization
  • Created comprehensive Zod schemas for webhook events with discriminated unions by scope
  • Added node version check warning for nodes < 2.5.0

Performance Improvements:

  • Bulk operations now sync only affected users rather than restarting entire nodes
  • Removed batching logic in bulkUpdateUsersInternalSquads (previously 3,000 user batches)
  • Uses ZSTD compression for bulk API requests to nodes

Dependencies:

  • Updated @remnawave/node-contract to 2.5.0 (breaking change requiring node upgrades)
  • Updated @bull-board/*, @nestjs/*, bullmq, and other dependencies

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean implementation of bulk user management with proper error handling, event-driven architecture, backward compatibility warnings for node versions, and comprehensive webhook schema definitions. No logical errors or security issues identified.
  • No files require special attention

Important Files Changed

Filename Overview
src/common/axios/axios.service.ts Added addUsers and deleteUsers methods for bulk user operations with proper error handling and logging
src/queue/_nodes/processors/node-bulk-users.processor.ts New processor for bulk user operations on nodes with proper error logging and job handling
src/modules/nodes/events/add-users-to-node/add-users-to-node.handler.ts Event handler that adds multiple users to nodes by resolving inbounds and filtering based on active node tags
src/modules/nodes/events/remove-users-from-node/remove-users-from-node.handler.ts Event handler that removes multiple users from all connected nodes
src/modules/users/repositories/users.repository.ts Added getIdsAndHashesByUserUuids and getUsersWithResolvedInbounds methods for bulk user operations
src/modules/users/users.service.ts Refactored bulk operations to use event-driven user management instead of full node restarts
libs/contract/models/webhook/webhook.schema.ts New webhook event schemas with scope-based discriminated unions for all event types
src/integration-modules/notifications/webhook-module/events/webhook.events.ts Updated all webhook event handlers to include scope field in payload

Sequence Diagram

sequenceDiagram
    participant US as UsersService
    participant EB as EventBus
    participant AUH as AddUsersToNodeHandler
    participant RUH as RemoveUsersFromNodeHandler
    participant QB as QueryBus
    participant UR as UsersRepository
    participant NQS as NodesQueuesService
    participant BulkQ as BulkUsersQueue
    participant BP as NodeBulkUsersProcessor
    participant AS as AxiosService
    participant Node as RemoteNode

    Note over US,Node: Bulk Delete Users Flow
    US->>UR: getIdsAndHashesByUserUuids(uuids)
    UR-->>US: [{tId, vlessUuid}]
    US->>UR: deleteManyByUuid(uuids)
    UR-->>US: deleteCount
    US->>EB: publish(RemoveUsersFromNodeEvent)
    EB->>RUH: handle(event)
    RUH->>NQS: removeUsersFromNode(payload)
    NQS->>BulkQ: add(REMOVE_USERS_FROM_NODE)
    BulkQ->>BP: process(job)
    BP->>AS: deleteUsers(data, url, port)
    AS->>Node: POST /api/v1/xray/users/remove (zstd compressed)
    Node-->>AS: response
    AS-->>BP: result

    Note over US,Node: Bulk Update Users Internal Squads Flow
    US->>UR: getUserIdsByUuids(usersUuids)
    UR-->>US: [tIds]
    US->>UR: removeUsersFromInternalSquads(userIds)
    US->>UR: addUsersToInternalSquads(userIds, squadsUuids)
    US->>EB: publish(AddUsersToNodeEvent)
    EB->>AUH: handle(event)
    AUH->>QB: execute(GetUsersWithResolvedInboundsQuery)
    QB->>UR: getUsersWithResolvedInbounds(tIds)
    UR-->>QB: [users with inbounds]
    QB-->>AUH: users
    loop For each active node
        AUH->>AUH: Filter users by active inbound tags
        AUH->>NQS: addUsersToNode(usersForNode)
        NQS->>BulkQ: add(ADD_USERS_TO_NODE)
        BulkQ->>BP: process(job)
        BP->>AS: addUsers(data, url, port)
        AS->>Node: POST /api/v1/xray/users/add (zstd compressed)
        Node-->>AS: response
        AS-->>BP: result
        opt Users to remove
            AUH->>NQS: removeUsersFromNode(usersToRemove)
            NQS->>BulkQ: add(REMOVE_USERS_FROM_NODE)
        end
    end
Loading

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