1+ use crate :: db:: repr:: { ApiKey , Permission } ;
2+ use crate :: prelude:: api:: * ;
13use crate :: types:: BotState ;
24use axum:: Json ;
3- use axum:: extract:: State ;
5+ use axum:: extract:: { Extension , State } ;
46use axum:: http:: StatusCode ;
57use rustmail_types:: CreateTicket ;
68use std:: sync:: Arc ;
79use tokio:: sync:: Mutex ;
810
911pub async fn handle_external_ticket_create (
12+ Extension ( api_key) : Extension < ApiKey > ,
1013 State ( bot_state) : State < Arc < Mutex < BotState > > > ,
1114 Json ( update) : Json < CreateTicket > ,
1215) -> Result < Json < serde_json:: Value > , ( StatusCode , String ) > {
13- let current_config = {
16+ check_permission ( & api_key, Permission :: CreateTicket )
17+ . map_err ( |e| ( StatusCode :: FORBIDDEN , format ! ( "{:?}" , e) ) ) ?;
18+
19+ let _current_config = {
1420 let state = bot_state. lock ( ) . await ;
1521 match & state. config {
1622 Some ( c) => c. clone ( ) ,
@@ -24,9 +30,12 @@ pub async fn handle_external_ticket_create(
2430 } ;
2531
2632 println ! (
27- "Discor ID : {:?} | Api key : {:?}" ,
28- update . discord_id , update. api_key
33+ "API Key #{} creating ticket for Discord ID : {:?}" ,
34+ api_key . id , update. discord_id
2935 ) ;
3036
31- Ok ( Json ( serde_json:: json!( { "status" : "ticket created" } ) ) )
37+ Ok ( Json ( serde_json:: json!( {
38+ "status" : "ticket created" ,
39+ "message" : "Ticket creation endpoint - implementation pending"
40+ } ) ) )
3241}
0 commit comments