@@ -591,7 +591,51 @@ void TinyPhoneHttpServer::Start() {
591591 return tp::response (200 , response);
592592 }
593593 });
594-
594+
595+ CROW_ROUTE (app, " /calls/<int>/join/<int>" )
596+ .methods (" POST" _method)
597+ ([&phone](int call_id, int call_to_join_id) {
598+ pj_thread_auto_register ();
599+
600+ SIPCall* call = phone.CallById (call_id);
601+ SIPCall* call_to_join = phone.CallById (call_to_join_id);
602+
603+ if (call == nullptr ) {
604+ return tp::response (400 , {
605+ { " message" , " Current Call Not Found" },
606+ { " call_id" , call_id },
607+ { " call_to_join_id" , call_to_join_id },
608+ });
609+ }
610+ else if (call_to_join == nullptr ) {
611+ return tp::response (400 , {
612+ { " message" , " Call To Join Not Found" },
613+ { " call_id" , call_id },
614+ { " call_to_join_id" , call_to_join_id }
615+ });
616+ }
617+ else if (call->HoldState () == +HoldStatus::LOCAL_HOLD) {
618+ json response = {
619+ { " message" , " Bad Request, CallOnHold Currently" },
620+ { " call_id" , call_id },
621+ { " call_to_join_id" , call_to_join_id },
622+ { " status" , " 400" }
623+ };
624+
625+ return tp::response (400 , response);
626+ }
627+ else {
628+ json response = {
629+ { " message" , " Calls Join Triggered" },
630+ { " call_id" , call_id },
631+ { " call_to_join_id" , call_to_join_id },
632+ { " response" , phone.Join (call, call_to_join) }
633+ };
634+
635+ return tp::response (200 , response);
636+ }
637+ });
638+
595639 CROW_ROUTE (app, " /calls/<int>/transfer" )
596640 .methods (" POST" _method)
597641 ([&phone](const crow::request& req, int call_id) {
0 commit comments