From 843398cead0b395448b87f04d592caa846aa5cd8 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Thu, 28 May 2020 21:16:51 -0400 Subject: [PATCH] fix error on gallery search --- lib/philomena/images/query.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/philomena/images/query.ex b/lib/philomena/images/query.ex index c1107352..9f0daaf2 100644 --- a/lib/philomena/images/query.ex +++ b/lib/philomena/images/query.ex @@ -2,8 +2,12 @@ defmodule Philomena.Images.Query do alias Philomena.Search.Parser alias Philomena.Repo - defp gallery_id_transform(_ctx, value), - do: {:ok, %{nested: %{path: :galleries, query: %{term: %{"galleries.id" => value}}}}} + defp gallery_id_transform(_ctx, value) do + case Integer.parse(value) do + {value, ""} when value >= 0 -> {:ok, %{nested: %{path: :galleries, query: %{term: %{"galleries.id" => value}}}}} + _error -> {:error, "Invalid gallery `#{value}'."} + end + end defp user_my_transform(%{user: %{id: id}}, "faves"), do: {:ok, %{term: %{favourited_by_user_ids: id}}}