mirror of
https://github.com/mikedilger/chorus.git
synced 2026-01-03 06:15:33 +00:00
clippy
This commit is contained in:
parent
408a10fd03
commit
fc8d588078
@ -478,7 +478,7 @@ impl WebSocketService {
|
||||
.get_event_by_offset(new_event_offset)?;
|
||||
|
||||
let event_flags = nostr::event_flags(event, &self.user);
|
||||
let authorized_user = self.user.map(|pk| is_authorized_user(pk)).unwrap_or(false);
|
||||
let authorized_user = self.user.map(is_authorized_user).unwrap_or(false);
|
||||
|
||||
'subs: for (subid, filters) in self.subscriptions.iter() {
|
||||
for filter in filters.iter() {
|
||||
@ -888,7 +888,7 @@ pub fn dump_authorized_users(store: &Store) -> Result<Vec<(Pubkey, bool)>, Error
|
||||
/// Is the pubkey an authorized user?
|
||||
pub fn is_authorized_user(pubkey: Pubkey) -> bool {
|
||||
let store = GLOBALS.store.get().unwrap();
|
||||
match get_authorized_user(&store, pubkey) {
|
||||
match get_authorized_user(store, pubkey) {
|
||||
Err(_) => false,
|
||||
Ok(None) => false,
|
||||
Ok(Some(_)) => true,
|
||||
@ -898,7 +898,7 @@ pub fn is_authorized_user(pubkey: Pubkey) -> bool {
|
||||
/// Is the pubkey a moderator?
|
||||
pub fn is_moderator(pubkey: Pubkey) -> bool {
|
||||
let store = GLOBALS.store.get().unwrap();
|
||||
match get_authorized_user(&store, pubkey) {
|
||||
match get_authorized_user(store, pubkey) {
|
||||
Err(_) => false,
|
||||
Ok(None) => false,
|
||||
Ok(Some(moderator)) => moderator,
|
||||
|
||||
15
src/nostr.rs
15
src/nostr.rs
@ -124,10 +124,7 @@ impl WebSocketService {
|
||||
}
|
||||
|
||||
let user = self.user;
|
||||
let authorized_user = self
|
||||
.user
|
||||
.map(|pk| crate::is_authorized_user(pk))
|
||||
.unwrap_or(false);
|
||||
let authorized_user = self.user.map(crate::is_authorized_user).unwrap_or(false);
|
||||
|
||||
if user.is_none() {
|
||||
for filter in filters.iter() {
|
||||
@ -295,10 +292,7 @@ impl WebSocketService {
|
||||
|
||||
async fn event_inner(&mut self) -> Result<(), Error> {
|
||||
let user = self.user;
|
||||
let authorized_user = self
|
||||
.user
|
||||
.map(|pk| crate::is_authorized_user(pk))
|
||||
.unwrap_or(false);
|
||||
let authorized_user = self.user.map(crate::is_authorized_user).unwrap_or(false);
|
||||
|
||||
// Delineate the event back out of the session buffer
|
||||
let event = unsafe { Event::delineate(&self.buffer)? };
|
||||
@ -525,10 +519,7 @@ impl WebSocketService {
|
||||
}
|
||||
|
||||
let user = self.user;
|
||||
let authorized_user = self
|
||||
.user
|
||||
.map(|pk| crate::is_authorized_user(pk))
|
||||
.unwrap_or(false);
|
||||
let authorized_user = self.user.map(crate::is_authorized_user).unwrap_or(false);
|
||||
|
||||
// Find all matching events
|
||||
let mut events: Vec<&Event> = Vec::new();
|
||||
|
||||
@ -359,7 +359,7 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
|
||||
|
||||
// Skip if pubkey marked approved
|
||||
if matches!(
|
||||
crate::get_pubkey_approval(&GLOBALS.store.get().unwrap(), event.pubkey()),
|
||||
crate::get_pubkey_approval(GLOBALS.store.get().unwrap(), event.pubkey()),
|
||||
Ok(Some(true))
|
||||
) {
|
||||
continue;
|
||||
@ -367,7 +367,7 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
|
||||
|
||||
// Skip if event marked approved
|
||||
if matches!(
|
||||
crate::get_event_approval(&GLOBALS.store.get().unwrap(), event.id()),
|
||||
crate::get_event_approval(GLOBALS.store.get().unwrap(), event.id()),
|
||||
Ok(Some(true))
|
||||
) {
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user