improvements
This commit is contained in:
@@ -42,6 +42,8 @@ enum PadServerMessage {
|
||||
Diagnostics {
|
||||
diagnostics: ConnectionDiagnostics,
|
||||
},
|
||||
PasswordRequired,
|
||||
PasswordChanged,
|
||||
Error {
|
||||
message: String,
|
||||
},
|
||||
@@ -528,6 +530,28 @@ async fn handle_pad_socket(
|
||||
}
|
||||
},
|
||||
update=updates.recv()=>{
|
||||
if let Ok(RoomEvent::PasswordRequired { except_client_id }) = &update {
|
||||
if password_event_excludes_connection(
|
||||
except_client_id.as_deref(),
|
||||
&collaboration_client_id,
|
||||
) {
|
||||
let _=send_pad_split(&mut sender,&PadServerMessage::PasswordChanged).await;
|
||||
break;
|
||||
}
|
||||
let (read_allowed, _) = current_resource_access(
|
||||
&state,
|
||||
"pad",
|
||||
&slug,
|
||||
&external_tokens,
|
||||
session_token.as_deref(),
|
||||
false,
|
||||
).await;
|
||||
if !read_allowed {
|
||||
let _=send_pad_split(&mut sender,&PadServerMessage::PasswordRequired).await;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let (read_allowed, _) = current_resource_access(
|
||||
&state,
|
||||
"pad",
|
||||
@@ -544,6 +568,7 @@ async fn handle_pad_socket(
|
||||
Ok(RoomEvent::Document(u))=>if send_pad_split(&mut sender,&PadServerMessage::Document{base_revision_id:u.base_revision_id,revision_id:u.revision_id,updated_at:u.updated_at,author:u.author,client_id:u.client_id,update_id:u.update_id,operation:u.operation,owner_replacements:u.owner_replacements}).await.is_err(){break;},
|
||||
Ok(RoomEvent::Presence(users))=>if send_pad_split(&mut sender,&PadServerMessage::Presence{users}).await.is_err(){break;},
|
||||
Ok(RoomEvent::Chat{sender:chat_sender,text})=>if send_pad_split(&mut sender,&PadServerMessage::Chat{sender:chat_sender,text}).await.is_err(){break;},
|
||||
Ok(RoomEvent::PasswordRequired { .. })=>{},
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(_))=>{
|
||||
let document=collaborative_document.lock().await;
|
||||
let snapshot=(document.content.clone(),document.revision_id,document.owner_map.clone(),document.acknowledged_updates(&collaboration_client_id));
|
||||
|
||||
Reference in New Issue
Block a user