Infactum / tg2sip

Telegram <-> SIP voice gateway
GNU General Public License v2.0
285 stars 105 forks source link

DTMF does not work in v1.3.0 #54

Open dkovik opened 2 years ago

dkovik commented 2 years ago

After switching to version 1.3.0, DTMF from Telagram to Sip does not work.

dkovik commented 2 years ago

Hi Infactum, I have commented 2 lines in the process_event function inside the gateway.cpp and the DTMF started to work again.

The DTMF numbers are received, via Telegram chat.

However I still do not know if my changes do not have some unwanted side effect as I really do not understand the code.

void Gateway::process_event(td::td_api::object_ptr<td::td_api::updateNewMessage> update_message) {
      auto &sender = update_message->message_->sender_id_;
      //if (sender->get_id() == td_api::messageSenderUser::ID)
      //    return;
      auto user = static_cast<const td_api::messageSenderUser *>(sender.get());

      std::vector<Bridge *> matches;
      for (auto bridge : bridges) {
          if (bridge->ctx->user_id == user->user_id_) {
              matches.emplace_back(bridge);
          }   
      }   

      if (matches.size() > 1) {
          logger_->error("ambiguous message from {}", user->user_id_);
          return;
      } else if (matches.size() == 1) {
          TRACE(logger_, "routing message to ctx {}", matches[0]->ctx->id());
          matches[0]->sm->process_event(update_message);
      }   

  }

I have commented (removed)

if (sender->get_id() == td_api::messageSenderUser::ID)
    return;

So the functions

matches[0]->sm->process_event(update_message);

gets called and the DTMF starts to work again.