Skip to content

Commit 2c6ad65

Browse files
committed
fix: notify command using old logic
1 parent e6ac416 commit 2c6ad65

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Console/NotifyCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public function __construct(private SettingsRepositoryInterface $settings, priva
4040
public function handle()
4141
{
4242
$days = (int) $this->settings->get('fof-best-answer.select_best_answer_reminder_days');
43-
$canSelectOwn = (bool) (int) $this->settings->get('fof-best-answer.allow_select_own_post');
4443
$time = Carbon::now()->subDays($days);
4544

4645
// set a max time period to go back, so we don't spam really old discussions too.
@@ -76,11 +75,12 @@ public function handle()
7675

7776
$errors = [];
7877

79-
$query->chunkById(20, function ($discussions) use ($canSelectOwn, &$errors) {
78+
$query->chunkById(20, function ($discussions) use (&$errors) {
8079
// Filter out discussions where the user can't select a post as best answer.
8180
// - The user must have permission to select a best answer on their own discussion
8281
// - The user must be able to select a post, whether they can select any post (including their own) or not.
83-
$discussions = $discussions->filter(function ($d) use ($canSelectOwn) {
82+
$discussions = $discussions->filter(function ($d) {
83+
$canSelectOwn = $d->user->can('fof-best-answer.allow_select_own_post', $d);
8484
$hasPermission = $d->user->can('selectBestAnswerOwnDiscussion', $d);
8585
$canSelectPosts = $canSelectOwn || $d->posts()->where('user_id', '!=', $d->user_id)->count() != 0;
8686

0 commit comments

Comments
 (0)