Implement Db::cancel_call
This commit is contained in:
parent
0310e27347
commit
59e8600e4c
3 changed files with 50 additions and 74 deletions
|
@ -558,13 +558,13 @@ impl Server {
|
|||
request.sender_connection_id,
|
||||
)
|
||||
.await?;
|
||||
for recipient_id in self
|
||||
for connection_id in self
|
||||
.store()
|
||||
.await
|
||||
.connection_ids_for_user(request.sender_user_id)
|
||||
{
|
||||
self.peer
|
||||
.send(recipient_id, proto::CallCanceled {})
|
||||
.send(connection_id, proto::CallCanceled {})
|
||||
.trace_err();
|
||||
}
|
||||
|
||||
|
@ -610,7 +610,7 @@ impl Server {
|
|||
) -> Result<()> {
|
||||
let mut contacts_to_update = HashSet::default();
|
||||
|
||||
let Some(left_room) = self.app_state.db.leave_room(connection_id).await? else {
|
||||
let Some(left_room) = self.app_state.db.leave_room_for_connection(connection_id).await? else {
|
||||
return Err(anyhow!("no room to leave"))?;
|
||||
};
|
||||
contacts_to_update.insert(user_id);
|
||||
|
@ -751,7 +751,7 @@ impl Server {
|
|||
self.room_updated(&room);
|
||||
self.update_user_contacts(called_user_id).await?;
|
||||
|
||||
Err(anyhow!("failed to ring call recipient"))?
|
||||
Err(anyhow!("failed to ring user"))?
|
||||
}
|
||||
|
||||
async fn cancel_call(
|
||||
|
@ -759,23 +759,23 @@ impl Server {
|
|||
request: Message<proto::CancelCall>,
|
||||
response: Response<proto::CancelCall>,
|
||||
) -> Result<()> {
|
||||
let recipient_user_id = UserId::from_proto(request.payload.called_user_id);
|
||||
{
|
||||
let mut store = self.store().await;
|
||||
let (room, recipient_connection_ids) = store.cancel_call(
|
||||
request.payload.room_id,
|
||||
recipient_user_id,
|
||||
request.sender_connection_id,
|
||||
)?;
|
||||
for recipient_id in recipient_connection_ids {
|
||||
self.peer
|
||||
.send(recipient_id, proto::CallCanceled {})
|
||||
.trace_err();
|
||||
}
|
||||
self.room_updated(room);
|
||||
response.send(proto::Ack {})?;
|
||||
let called_user_id = UserId::from_proto(request.payload.called_user_id);
|
||||
let room_id = RoomId::from_proto(request.payload.room_id);
|
||||
|
||||
let room = self
|
||||
.app_state
|
||||
.db
|
||||
.cancel_call(room_id, request.sender_connection_id, called_user_id)
|
||||
.await?;
|
||||
for connection_id in self.store().await.connection_ids_for_user(called_user_id) {
|
||||
self.peer
|
||||
.send(connection_id, proto::CallCanceled {})
|
||||
.trace_err();
|
||||
}
|
||||
self.update_user_contacts(recipient_user_id).await?;
|
||||
self.room_updated(&room);
|
||||
response.send(proto::Ack {})?;
|
||||
|
||||
self.update_user_contacts(called_user_id).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -788,13 +788,13 @@ impl Server {
|
|||
message.sender_user_id,
|
||||
)
|
||||
.await?;
|
||||
for recipient_id in self
|
||||
for connection_id in self
|
||||
.store()
|
||||
.await
|
||||
.connection_ids_for_user(message.sender_user_id)
|
||||
{
|
||||
self.peer
|
||||
.send(recipient_id, proto::CallCanceled {})
|
||||
.send(connection_id, proto::CallCanceled {})
|
||||
.trace_err();
|
||||
}
|
||||
self.room_updated(&room);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue