Skip to content

Commit a070858

Browse files
Grimur Vid NeystGrimur Vid Neyst
authored andcommitted
fix-move-select-own-post-to-permission: Styling Fixes
Reported by: Grimur Vid Neyst Signed off by: Grimur Vid Neyst <grimur.vid-neyst@glowingblue>
1 parent dc65355 commit a070858

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Api/PostAttributes.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace FoF\BestAnswer\Api;
1313

14+
use Flarum\Api\Serializer\PostSerializer;
1415
use Flarum\Post\Post;
1516
use FoF\BestAnswer\Repository\BestAnswerRepository;
16-
use Flarum\Api\Serializer\PostSerializer;
1717

1818
class PostAttributes
1919
{
@@ -28,5 +28,4 @@ public function __invoke(PostSerializer $serializer, Post $post, array $attribut
2828

2929
return $attributes;
3030
}
31-
3231
}

src/Repository/BestAnswerRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ public function __construct(
5151
$this->events = $events;
5252
$this->translator = $translator;
5353
}
54-
54+
5555
public function canSelectBestAnswer(User $user, Discussion $discussion): bool
5656
{
5757
// Prevent best answers being set in a private discussion (ie byobu, etc)
5858
if ($discussion->is_private) {
5959
return false;
6060
}
61+
6162
return $this->tagEnabledForBestAnswer($discussion) && ($user->id === $discussion->user_id
6263
? $user->can('discussion.selectBestAnswerOwnDiscussion', $discussion)
6364
: $user->can('discussion.selectBestAnswerNotOwnDiscussion', $discussion));

tests/integration/api/UnsetBestAnswerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ public function user_can_unset_best_answer_in_own_discussion_and_select_a_differ
149149
$this->assertEquals(3, $attributes['hasBestAnswer'], 'Expected best answer post ID to be 3');
150150
}
151151

152-
private function getCanSelectBestAnswer(array $included, int $userId): bool {
152+
private function getCanSelectBestAnswer(array $included, int $userId): bool
153+
{
153154
foreach ($included as $item) {
154155
if (($item['type'] ?? null) === 'posts' && isset($item['attributes']['canSelectBestAnswer'])
155156
&& $item['relationships']['user']['data']['id'] == $userId) {

0 commit comments

Comments
 (0)