Skip to content

Commit f183edb

Browse files
committed
end outgoing calls after one minute
1 parent 2663df7 commit f183edb

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/calls.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,22 @@ impl Context {
6767
let chat = Chat::load_from_db(self, chat_id).await?;
6868
ensure!(chat.typ == Chattype::Single && !chat.is_self_talk());
6969

70-
let mut msg = Message {
70+
let mut call = Message {
7171
viewtype: Viewtype::Text,
7272
text: "Calling...".into(),
7373
..Default::default()
7474
};
75-
msg.param.set_cmd(SystemMessage::OutgoingCall);
76-
msg.id = send_msg(self, chat_id, &mut msg).await?;
77-
Ok(msg.id)
75+
call.param.set_cmd(SystemMessage::OutgoingCall);
76+
call.id = send_msg(self, chat_id, &mut call).await?;
77+
78+
let wait = RINGING_SECONDS;
79+
task::spawn(Context::emit_end_call_if_unaccepted(
80+
self.clone(),
81+
wait.try_into()?,
82+
call.id,
83+
));
84+
85+
Ok(call.id)
7886
}
7987

8088
/// Accept an incoming call.
@@ -176,6 +184,7 @@ impl Context {
176184
msg_id: call.msg.id,
177185
});
178186
} else {
187+
call.msg.clone().mark_call_as_accepted(self).await?;
179188
self.emit_event(EventType::OutgoingCallAccepted {
180189
msg_id: call.msg.id,
181190
});

0 commit comments

Comments
 (0)