Fix: wrong logic
Build and Push Docker Image / build_docker_image (push) Successful in 16m20s

This commit is contained in:
2025-11-23 19:23:19 +09:00
parent 7dbca66b2f
commit e09676582d
+8 -20
View File
@@ -264,7 +264,10 @@ pub async fn handle_message(
// 检查 channel 是否已关闭
if to_client_msg_tx.is_closed() {
debug!("Client channel closed before sending historical events for sub_id: {}", sub_id);
debug!(
"Client channel closed before sending historical events for sub_id: {}",
sub_id
);
return Ok(());
}
@@ -274,7 +277,10 @@ pub async fn handle_message(
for event in events {
// 在发送每个事件前检查 channel 状态,避免大量失败尝试
if to_client_msg_tx.is_closed() {
debug!("Client channel closed during historical event sending for sub_id: {}", sub_id);
debug!(
"Client channel closed during historical event sending for sub_id: {}",
sub_id
);
return Ok(());
}
RelayMessage::send_event(&event, &sub_id, to_client_msg_tx).await?;
@@ -318,24 +324,6 @@ pub async fn handle_message(
// 权限检查:是否需要认证,以及是否在信任列表中
if SERVER_INFO.auth_required {
let conn = client_conn_clone.read().await;
if !conn.authenticated {
match RelayMessage::send_closed(
// NIP-42 Auth: Forbid unauthenticated EVENT
&conn.id.to_string(), // 使用 client_id 作为 sub_id 来匹配 AUTH 挑战
"auth-required: Authentication required to publish events".to_string(),
&to_client_msg_tx_clone,
)
.await
{
Ok(_) => debug!("Client {}: Authentication challenge sent.", conn.id),
Err(e) => {
debug!("Failed to send authentication challenge: {}", e);
return;
}
};
debug!("Client {}: Not authenticated, event rejected.", conn.id);
return;
}
let trust_accounts_guard = trust_accounts_clone.read().await;
if !trust_accounts_guard.contains(&event_clone.pubkey) {
match RelayMessage::send_closed(