diff --git a/lib/philomena_web/controllers/filter/hide_controller.ex b/lib/philomena_web/controllers/filter/hide_controller.ex index 5aee4553..35af1f96 100644 --- a/lib/philomena_web/controllers/filter/hide_controller.ex +++ b/lib/philomena_web/controllers/filter/hide_controller.ex @@ -7,7 +7,7 @@ defmodule PhilomenaWeb.Filter.HideController do plug PhilomenaWeb.FilterBannedUsersPlug plug :authorize_filter - plug :load_tag + plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true def create(conn, _params) do case Filters.hide_tag(conn.assigns.current_filter, conn.assigns.tag) do @@ -48,10 +48,4 @@ defmodule PhilomenaWeb.Filter.HideController do |> text("") end end - - def load_tag(conn, _opts) do - tag = Repo.get_by!(Tag, slug: URI.encode(conn.params["tag"])) - - assign(conn, :tag, tag) - end end \ No newline at end of file diff --git a/lib/philomena_web/controllers/filter/spoiler_controller.ex b/lib/philomena_web/controllers/filter/spoiler_controller.ex index 2fbad82b..73307803 100644 --- a/lib/philomena_web/controllers/filter/spoiler_controller.ex +++ b/lib/philomena_web/controllers/filter/spoiler_controller.ex @@ -7,7 +7,7 @@ defmodule PhilomenaWeb.Filter.SpoilerController do plug PhilomenaWeb.FilterBannedUsersPlug plug :authorize_filter - plug :load_tag + plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true def create(conn, _params) do case Filters.spoiler_tag(conn.assigns.current_filter, conn.assigns.tag) do @@ -48,10 +48,4 @@ defmodule PhilomenaWeb.Filter.SpoilerController do |> text("") end end - - def load_tag(conn, _opts) do - tag = Repo.get_by!(Tag, slug: URI.encode(conn.params["tag"])) - - assign(conn, :tag, tag) - end end \ No newline at end of file diff --git a/lib/philomena_web/controllers/tag/watch_controller.ex b/lib/philomena_web/controllers/tag/watch_controller.ex index 8a588faa..abd0f508 100644 --- a/lib/philomena_web/controllers/tag/watch_controller.ex +++ b/lib/philomena_web/controllers/tag/watch_controller.ex @@ -5,7 +5,7 @@ defmodule PhilomenaWeb.Tag.WatchController do alias Philomena.Users alias Philomena.Repo - plug :load_tag + plug :load_resource, model: Tag, id_field: "slug", id_name: "tag_id", persisted: true def create(conn, _params) do case Users.watch_tag(conn.assigns.current_user, conn.assigns.tag) do @@ -34,10 +34,4 @@ defmodule PhilomenaWeb.Tag.WatchController do |> text("") end end - - def load_tag(conn, _opts) do - tag = Repo.get_by!(Tag, slug: URI.encode(conn.params["tag_id"])) - - assign(conn, :tag, tag) - end end \ No newline at end of file diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index 2ba26d7f..c4c49766 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -35,7 +35,7 @@ defmodule PhilomenaWeb.TagController do tag = Tag - |> where(slug: ^URI.encode(slug)) + |> where(slug: ^slug) |> preload([:aliases, :implied_tags, :implied_by_tags, :dnp_entries, public_links: :user]) |> Repo.one()