Skip to content

Endpoint for batch rule unsubscription #498

@bracyw

Description

@bracyw

Description

Unsubscribe client from multiple rules and cleanup orphaned rules (rules with no remaining subscribers). Used when users bulk unsubscribe via checkboxes or when removing themselves from rules they no longer need, with automatic cleanup to prevent accumulation of unused rules in the system and maintain data hygiene.

Related diagram:

sequenceDiagram
    participant User
    participant Client
    participant Server
    
    User->>Client: Click Unsubscribe (checkbox or button)
    
    Note over Client,Server: (a) Unsubscribe from Rule(s)
    Client->>Server: POST /rules/unsubscribe (rule_ids, client_id)
    Note right of Server: (b) Server Logic: For each rule_id, remove (client_id, rule_id) from BiMap, Cleanup rules with no subscribers
    Server->>Server: Unsubscribe from rules
    Server-->>Client: Success response
    
    Note over Client,User: (c) UI Update
    Client->>User: Update rule list display
Loading

Acceptance Criteria

  • Removes client from subscriptions for each rule
  • Deletes rules with no remaining subscribers
  • Time: O(n) where n = rules to unsubscribe

Proposed Solution

POST /rules/unsubscribe
Body: { rule_ids: Vec<String>, client_id: String }
Response: 200 OK

Add unsubscribe_rules() method to RuleManager. Get rid of the Auth header and use client_id from request body. Reference delete_rule() for BiMap removal and BiMapRemoveResult handling. Test using Postman, add tests to rule_structs_test.rs.

Mocks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    mediumA more complex taskscylla-serverDevelopment Focused in the Backend

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions