[COMPONENT][Search] Be explicit about including :

This commit is contained in:
Hugo Sales 2021-12-11 20:56:47 +00:00
parent 01470ee664
commit bad5efe819
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 10 additions and 9 deletions

View File

@ -74,17 +74,17 @@ class Language extends Component
$temp_actor_expr = $eb->startsWith('language.locale', $search_term); $temp_actor_expr = $eb->startsWith('language.locale', $search_term);
} }
if (Formatting::startsWith($term, ['lang', 'language'])) { if (Formatting::startsWith($term, ['lang:', 'language:'])) {
$note_expr = $temp_note_expr; $note_expr = $temp_note_expr;
$actor_expr = $temp_actor_expr; $actor_expr = $temp_actor_expr;
return Event::stop; return Event::stop;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['lang', 'language']))) { } elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['lang', 'language'], [':']))) {
$note_expr = $temp_note_expr; $note_expr = $temp_note_expr;
return Event::stop; return Event::stop;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['author', 'actor', 'people', 'person'], ['lang', 'language']))) { } elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['author', 'actor', 'people', 'person'], ['lang', 'language'], [':']))) {
$note_expr = $temp_note_actor_expr; $note_expr = $temp_note_actor_expr;
return Event::stop; return Event::stop;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['actor', 'people', 'person'], ['lang', 'language']))) { } elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['actor', 'people', 'person'], ['lang', 'language'], [':']))) {
$actor_expr = $temp_actor_expr; $actor_expr = $temp_actor_expr;
return Event::stop; return Event::stop;
} }

View File

@ -30,6 +30,7 @@ use function App\Core\I18n\_m;
use App\Core\Modules\Component; use App\Core\Modules\Component;
use App\Core\Router\Router; use App\Core\Router\Router;
use App\Entity\Actor; use App\Entity\Actor;
use App\Entity\ActorTag;
use App\Entity\Language; use App\Entity\Language;
use App\Entity\Note; use App\Entity\Note;
use App\Entity\NoteTag; use App\Entity\NoteTag;
@ -158,11 +159,11 @@ class Tag extends Component
$canon_search_term = self::canonicalTag($search_term, $language); $canon_search_term = self::canonicalTag($search_term, $language);
$temp_note_expr = $eb->eq('note_tag.canonical', $canon_search_term); $temp_note_expr = $eb->eq('note_tag.canonical', $canon_search_term);
$temp_actor_expr = $eb->eq('actor_tag.canonical', $canon_search_term); $temp_actor_expr = $eb->eq('actor_tag.canonical', $canon_search_term);
if (Formatting::startsWith($term, ['note', 'tag'])) { if (Formatting::startsWith($term, ['note:', 'tag:', 'people:'])) {
$note_expr = $temp_note_expr; $note_expr = $temp_note_expr;
} elseif (Formatting::startsWith($term, ['people', 'actor'])) { } elseif (Formatting::startsWith($term, ['people:', 'actor:'])) {
$actor_expr = $temp_actor_expr; $actor_expr = $temp_actor_expr;
} else { } elseif (str_contains($term, '#')) {
$note_expr = $temp_note_expr; $note_expr = $temp_note_expr;
$actor_expr = $temp_actor_expr; $actor_expr = $temp_actor_expr;
return Event::next; return Event::next;
@ -172,8 +173,8 @@ class Tag extends Component
public function onSearchQueryAddJoins(QueryBuilder &$note_qb, QueryBuilder &$actor_qb): bool public function onSearchQueryAddJoins(QueryBuilder &$note_qb, QueryBuilder &$actor_qb): bool
{ {
$note_qb->leftJoin('App\Entity\NoteTag', 'note_tag', Expr\Join::WITH, 'note_tag.note_id = note.id'); $note_qb->leftJoin(NoteTag::class, 'note_tag', Expr\Join::WITH, 'note_tag.note_id = note.id');
$actor_qb->leftJoin('App\Entity\ActorTag', 'actor_tag', Expr\Join::WITH, 'actor_tag.tagger = actor.id'); $actor_qb->leftJoin(ActorTag::class, 'actor_tag', Expr\Join::WITH, 'actor_tag.tagger = actor.id');
return Event::next; return Event::next;
} }