Skip to content

feat(api): create ticket api endpoint#270

Merged
Akinator31 merged 2 commits intomainfrom
269-create-ticket-api-endpoint
Dec 3, 2025
Merged

feat(api): create ticket api endpoint#270
Akinator31 merged 2 commits intomainfrom
269-create-ticket-api-endpoint

Conversation

@Akinator31
Copy link
Copy Markdown
Member

@Akinator31 Akinator31 commented Dec 3, 2025

This pull request introduces major improvements to the external ticket creation API endpoint and related bot state management. The primary focus is on implementing the full ticket creation flow, including Discord integration, user validation, and thread/channel management. It also refactors the authentication middleware, enhances bot state to store the Discord context, and updates several type definitions for better consistency.

Ticket Creation Endpoint Implementation:

  • Fully implements the handle_external_ticket_create function, adding Discord user validation, guild membership checks, prevention of duplicate tickets, dynamic channel/thread creation, and messaging via Discord. It now returns detailed responses and error handling for all major failure cases.

Bot State and Context Management:

  • Updates the BotState struct to include a thread-safe, shared reference to the Discord Context, allowing for richer bot interactions and message sending. The context is now initialized and updated in the ReadyHandler.
  • Modifies the ReadyHandler to accept and manage the shared bot state, ensuring the context is available throughout the bot's lifecycle.

Authentication Middleware Refactor:

  • Refactors the API key authentication logic for clarity and correctness, improving error handling and response codes, and streamlining the code path for valid and invalid keys.

Type and Import Cleanups:

  • Removes the unused api_key field from the CreateTicket struct, as authentication is now handled exclusively via headers.
  • Cleans up and organizes imports across several modules for consistency and clarity.

Other Improvements:

  • Ensures the bot state is properly initialized with the new context field and passed to all relevant handlers and services.

These changes collectively make the ticket creation API endpoint robust, production-ready, and tightly integrated with Discord, while improving maintainability and reliability across the codebase.

@Akinator31 Akinator31 self-assigned this Dec 3, 2025
@Akinator31 Akinator31 linked an issue Dec 3, 2025 that may be closed by this pull request
@Akinator31 Akinator31 merged commit 164c8ee into main Dec 3, 2025
6 checks passed
@Akinator31 Akinator31 deleted the 269-create-ticket-api-endpoint branch December 3, 2025 20:52
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.

Create ticket api endpoint

1 participant