@@ -25,6 +25,15 @@ namespace td_api = td::td_api;
2525
2626volatile sig_atomic_t e_flag = 0 ;
2727
28+ namespace {
29+ vector<string> voip_library_versions () {
30+ // actually we want to provide real tgvoip version from
31+ // tgvoip::VoIPController::GetVersion()
32+ // but telegram servers accepts only this one
33+ return vector<string>{" 2.4.4" };
34+ }
35+ }
36+
2837namespace state_machine ::guards {
2938 bool IsIncoming::operator ()(const td::td_api::object_ptr<td::td_api::updateCall> &event) const {
3039 return !event->call_ ->is_outgoing_ ;
@@ -108,6 +117,7 @@ namespace state_machine::actions {
108117 ctx.tg_call_id , /* call_id_ */
109118 false , /* is_disconnected_ */
110119 0 , /* duration_ */
120+ false , /* is_video_ */
111121 ctx.tg_call_id /* connection_id */
112122 )).get ();
113123
@@ -211,7 +221,8 @@ namespace state_machine::actions {
211221 td_api::make_object<td_api::callProtocol>(settings.udp_p2p (),
212222 settings.udp_reflector (),
213223 CALL_PROTO_MIN_LAYER,
214- tgvoip::VoIPController::GetConnectionMaxLayer ())
224+ tgvoip::VoIPController::GetConnectionMaxLayer (),
225+ voip_library_versions ())
215226 )).get ();
216227
217228 if (response->get_id () == td_api::error::ID) {
@@ -337,13 +348,18 @@ namespace state_machine::actions {
337348 voip_controller->SetEncryptionKey (encryption_key, event->call_ ->is_outgoing_ );
338349
339350 vector<Endpoint> endpoints;
340- for (const auto &connection : state.connections_ ) {
351+ for (const auto &server : state.servers_ ) {
352+ if (server->type_ ->get_id () != td_api::callServerTypeTelegramReflector::ID)
353+ continue ;
354+
355+ auto reflector = static_cast <const td_api::callServerTypeTelegramReflector *>(server->type_ .get ());
356+
341357 unsigned char peer_tag[16 ];
342- memcpy (peer_tag, connection ->peer_tag_ .c_str (), 16 );
343- auto ipv4 = IPv4Address (connection-> ip_ );
344- auto ipv6 = IPv6Address (connection-> ipv6_ );
345- endpoints.emplace_back (Endpoint (connection ->id_ ,
346- static_cast <uint16_t >(connection ->port_ ),
358+ memcpy (peer_tag, reflector ->peer_tag_ .c_str (), 16 );
359+ auto ipv4 = IPv4Address (server-> ip_address_ );
360+ auto ipv6 = IPv6Address (server-> ipv6_address_ );
361+ endpoints.emplace_back (Endpoint (server ->id_ ,
362+ static_cast <uint16_t >(server ->port_ ),
347363 ipv4,
348364 ipv6,
349365 Endpoint::UDP_RELAY,
@@ -419,12 +435,14 @@ namespace state_machine::actions {
419435 }
420436 }
421437
422- void DialTg::dial_by_id (int32_t id) {
438+ void DialTg::dial_by_id (int64_t id) {
423439 auto response = tg_client_->send_query_async (td_api::make_object<td_api::createCall>(
424440 id /* id */ ,
425441 td_api::make_object<td_api::callProtocol>(settings_->udp_p2p (), settings_->udp_reflector (),
426442 CALL_PROTO_MIN_LAYER,
427- tgvoip::VoIPController::GetConnectionMaxLayer ()))
443+ tgvoip::VoIPController::GetConnectionMaxLayer (),
444+ voip_library_versions ()),
445+ false /* is_video_ */ )
428446 ).get ();
429447
430448 if (response->get_id () == td_api::error::ID) {
@@ -535,7 +553,7 @@ namespace state_machine::actions {
535553 return ;
536554 }
537555
538- auto id = static_cast < int32_t >( chat->id_ ) ;
556+ auto id = chat->id_ ;
539557 DEBUG (logger_, " [{}] adding id {} for {} to username cache" , ctx_->id (), id, ctx_->ext_username );
540558 cache_->username_cache .emplace (ctx_->ext_username , id);
541559 dial_by_id (id);
@@ -835,15 +853,20 @@ void Gateway::process_event(td::td_api::object_ptr<td::td_api::updateCall> updat
835853
836854void Gateway::process_event (td::td_api::object_ptr<td::td_api::updateNewMessage> update_message) {
837855
856+ auto &sender = update_message->message_ ->sender_id_ ;
857+ if (sender->get_id () == td_api::messageSenderUser::ID)
858+ return ;
859+ auto user = static_cast <const td_api::messageSenderUser *>(sender.get ());
860+
838861 std::vector<Bridge *> matches;
839862 for (auto bridge : bridges) {
840- if (bridge->ctx ->user_id == update_message-> message_ -> sender_user_id_ ) {
863+ if (bridge->ctx ->user_id == user-> user_id_ ) {
841864 matches.emplace_back (bridge);
842865 }
843866 }
844867
845868 if (matches.size () > 1 ) {
846- logger_->error (" ambiguous message from {}" , update_message-> message_ -> sender_user_id_ );
869+ logger_->error (" ambiguous message from {}" , user-> user_id_ );
847870 return ;
848871 } else if (matches.size () == 1 ) {
849872 TRACE (logger_, " routing message to ctx {}" , matches[0 ]->ctx ->id ());
0 commit comments