mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-05-20 10:04:53 +00:00
🚀 Refactor: Centralize isBoardMember logic in EinundzwanzigPleb model and replace redundant checks
This commit is contained in:
@@ -29,7 +29,7 @@ class ElectionPolicy
|
||||
*/
|
||||
public function create(NostrUser $user): bool
|
||||
{
|
||||
return $this->isBoardMember($user);
|
||||
return $user->isBoardMember();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ class ElectionPolicy
|
||||
*/
|
||||
public function update(NostrUser $user, Election $election): bool
|
||||
{
|
||||
return $this->isBoardMember($user);
|
||||
return $user->isBoardMember();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ class ElectionPolicy
|
||||
*/
|
||||
public function delete(NostrUser $user, Election $election): bool
|
||||
{
|
||||
return $this->isBoardMember($user);
|
||||
return $user->isBoardMember();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,15 +64,4 @@ class ElectionPolicy
|
||||
|
||||
return $pleb->association_status->value >= 3;
|
||||
}
|
||||
|
||||
private function isBoardMember(NostrUser $user): bool
|
||||
{
|
||||
$pleb = $user->getPleb();
|
||||
|
||||
if (! $pleb) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($pleb->npub, config('einundzwanzig.config.current_board'), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user