mirror of
https://github.com/mikedilger/chorus.git
synced 2026-05-03 06:51:42 +00:00
fix: serve partial redacted results, but reply with "auth-required" if any redactions happened
This commit is contained in:
parent
f1851e793b
commit
e7044ad0db
37
src/nostr.rs
37
src/nostr.rs
@ -180,19 +180,6 @@ impl WebSocketService {
|
||||
redacted = redacted || was_redacted;
|
||||
}
|
||||
|
||||
// New policy Feb 2025: Redactions trigger a "CLOSED: auth-required" because
|
||||
// some clients will not AUTH otherwise.
|
||||
if redacted {
|
||||
// They need to AUTH first
|
||||
let reply = NostrReply::Closed(
|
||||
subid,
|
||||
NostrReplyPrefix::AuthRequired,
|
||||
"At least one matching event requires AUTH".to_owned(),
|
||||
);
|
||||
self.send(Message::text(reply.as_json())).await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// sort
|
||||
events.sort_by_key(|e| std::cmp::Reverse(e.created_at()));
|
||||
|
||||
@ -219,17 +206,23 @@ impl WebSocketService {
|
||||
self.send(Message::text(reply.as_json())).await?;
|
||||
}
|
||||
|
||||
// New policy Feb 2025: Redactions trigger a "CLOSED: auth-required" because
|
||||
// some clients will not AUTH otherwise.
|
||||
// (But we also already sent partial results, which I think is good)
|
||||
if redacted {
|
||||
// They need to AUTH first
|
||||
let reply = NostrReply::Closed(
|
||||
subid,
|
||||
NostrReplyPrefix::AuthRequired,
|
||||
"At least one matching event requires AUTH".to_owned(),
|
||||
);
|
||||
self.send(Message::text(reply.as_json())).await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if completes {
|
||||
// Closed
|
||||
let reply = if redacted {
|
||||
NostrReply::Closed(
|
||||
subid,
|
||||
NostrReplyPrefix::Redacted,
|
||||
"Some matching events could not be served to you.".to_owned(),
|
||||
)
|
||||
} else {
|
||||
NostrReply::Closed(subid, NostrReplyPrefix::None, "".to_owned())
|
||||
};
|
||||
let reply = NostrReply::Closed(subid, NostrReplyPrefix::None, "".to_owned());
|
||||
self.send(Message::text(reply.as_json())).await?;
|
||||
} else {
|
||||
// EOSE
|
||||
|
||||
@ -9,7 +9,6 @@ pub enum NostrReplyPrefix {
|
||||
Duplicate,
|
||||
Blocked,
|
||||
RateLimited,
|
||||
Redacted,
|
||||
Restricted,
|
||||
Invalid,
|
||||
Error,
|
||||
@ -24,7 +23,6 @@ impl fmt::Display for NostrReplyPrefix {
|
||||
NostrReplyPrefix::Duplicate => write!(f, "duplicate: "),
|
||||
NostrReplyPrefix::Blocked => write!(f, "blocked: "),
|
||||
NostrReplyPrefix::RateLimited => write!(f, "rate-limited: "),
|
||||
NostrReplyPrefix::Redacted => write!(f, "redacted: "),
|
||||
NostrReplyPrefix::Restricted => write!(f, "restricted: "),
|
||||
NostrReplyPrefix::Invalid => write!(f, "invalid: "),
|
||||
NostrReplyPrefix::Error => write!(f, "error: "),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user