mirror of
https://github.com/mikedilger/chorus.git
synced 2026-05-03 06:51:42 +00:00
Clean up screen a bit
This commit is contained in:
parent
0fd74d83a8
commit
70e78f7b96
36
src/nostr.rs
36
src/nostr.rs
@ -794,13 +794,15 @@ pub fn screen_outgoing_event(
|
|||||||
event_flags: &EventFlags,
|
event_flags: &EventFlags,
|
||||||
authorized_user: bool,
|
authorized_user: bool,
|
||||||
) -> ScreenResult {
|
) -> ScreenResult {
|
||||||
// Deny if it is a private event (DM or GiftWrap) and theey are neither the recipient
|
// Deny if it is a private event (DM or GiftWrap) and they are neither the recipient
|
||||||
// nor the author
|
// nor the author
|
||||||
// (even for authorized users)
|
// (even for authorized users)
|
||||||
if event.kind() == Kind::from(4) || event.kind() == Kind::from(1059) {
|
if event.kind() == Kind::from(4) || event.kind() == Kind::from(1059) {
|
||||||
if event_flags.tags_current_user || event_flags.author_is_current_user {
|
if event_flags.tags_current_user || event_flags.author_is_current_user {
|
||||||
|
// they are tagged, it is ok
|
||||||
return ScreenResult::Match;
|
return ScreenResult::Match;
|
||||||
} else {
|
} else {
|
||||||
|
// they are not tagged
|
||||||
return ScreenResult::Redacted;
|
return ScreenResult::Redacted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -812,13 +814,28 @@ pub fn screen_outgoing_event(
|
|||||||
return ScreenResult::Mismatch;
|
return ScreenResult::Mismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny if it is marked approved:false
|
let event_approval = crate::get_event_approval(GLOBALS.store.get().unwrap(), event.id());
|
||||||
|
let pubkey_approval = crate::get_pubkey_approval(GLOBALS.store.get().unwrap(), event.pubkey());
|
||||||
|
|
||||||
|
// Deny if it is marked approval:false (event or pubkey)
|
||||||
// (even for authorized users)
|
// (even for authorized users)
|
||||||
if let Ok(Some(false)) = crate::get_event_approval(GLOBALS.store.get().unwrap(), event.id()) {
|
// event overrides pubkey
|
||||||
|
if let Ok(Some(false)) = event_approval {
|
||||||
|
return ScreenResult::Mismatch;
|
||||||
|
}
|
||||||
|
if let Ok(Some(false)) = pubkey_approval {
|
||||||
|
return ScreenResult::Mismatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow if is is marked approval:true (event or pubkey)
|
||||||
|
if let Ok(Some(true)) = event_approval {
|
||||||
|
return ScreenResult::Match;
|
||||||
|
}
|
||||||
|
if let Ok(Some(true)) = pubkey_approval {
|
||||||
return ScreenResult::Match;
|
return ScreenResult::Match;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow if an open relay
|
// Allow if we are an open relay
|
||||||
if GLOBALS.config.read().open_relay {
|
if GLOBALS.config.read().open_relay {
|
||||||
return ScreenResult::Match;
|
return ScreenResult::Match;
|
||||||
}
|
}
|
||||||
@ -845,17 +862,6 @@ pub fn screen_outgoing_event(
|
|||||||
return ScreenResult::Match;
|
return ScreenResult::Match;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow if event is explicitly approved
|
|
||||||
if let Ok(Some(true)) = crate::get_event_approval(GLOBALS.store.get().unwrap(), event.id()) {
|
|
||||||
return ScreenResult::Match;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow if author is explicitly approved
|
|
||||||
if let Ok(Some(true)) = crate::get_pubkey_approval(GLOBALS.store.get().unwrap(), event.pubkey())
|
|
||||||
{
|
|
||||||
return ScreenResult::Match;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not allow the rest
|
// Do not allow the rest
|
||||||
ScreenResult::Redacted
|
ScreenResult::Redacted
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user