Skip to content

Commit

Permalink
Merge pull request #69 from v17development/beta-13-bug-fix
Browse files Browse the repository at this point in the history
Fix filter update & discussion language fix
  • Loading branch information
jaspervriends authored Feb 16, 2021
2 parents 4d2e83f + 0301300 commit 533d73f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Filter/FilterDiscussionsForBlogPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Flarum\Discussion\Event\Searching;
use Flarum\Settings\SettingsRepositoryInterface;
use V17Development\FlarumBlog\Gambit\BlogGambit;
use Flarum\Discussion\Search\Gambit\FulltextGambit;

class FilterDiscussionsForBlogPosts
{
Expand Down Expand Up @@ -38,6 +39,9 @@ public function handle(Searching $event)
if(get_class($gambit) === BlogGambit::class) {
$hideBlogPosts = false;
}
if(get_class($gambit) === FulltextGambit::class) {
$hideBlogPosts = false;
}
}

// Filter discussions from discussion list
Expand Down
6 changes: 6 additions & 0 deletions src/Listeners/CreateBlogMetaOnDiscussionCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public function handle(Saving $event)

// After the tags are synced, check if it's a blog article
$discussion->afterSave(function ($discussion) use ($event) {

// Here it may happen that `$discussion->tags` gives an empty array because of a strange bug.
// This can be reproduced when using the fof/discussion-language extension (v1.2.1)
// For this reason we need to explictly reloag the tags relationship before using it here.
$discussion->load('tags');

// Make sure it's a blog base discussion!
if ($discussion->tags && $discussion->tags->whereIn('id', $this->blogTags)->count() > 0) {
if(!$event->actor->can('blog.writeArticles')) {
Expand Down

0 comments on commit 533d73f

Please sign in to comment.