diff --git a/lib/philomena/elasticsearch.ex b/lib/philomena/elasticsearch.ex index caedda7a..036b72f7 100644 --- a/lib/philomena/elasticsearch.ex +++ b/lib/philomena/elasticsearch.ex @@ -50,6 +50,7 @@ defmodule Philomena.Elasticsearch do index_name = index.index_name() doc_type = index.doc_type() + mapping = index.mapping().mappings |> Map.get(String.to_atom(doc_type)) diff --git a/lib/philomena/images/query.ex b/lib/philomena/images/query.ex index 523000b4..2a2d77a3 100644 --- a/lib/philomena/images/query.ex +++ b/lib/philomena/images/query.ex @@ -97,8 +97,7 @@ defmodule Philomena.Images.Query do literal_fields: fields[:literal_fields] ++ ~W(fingerprint upvoted_by downvoted_by true_uploader hidden_by deleted_by_user), - ngram_fields: - fields[:ngram_fields] ++ ~W(deletion_reason), + ngram_fields: fields[:ngram_fields] ++ ~W(deletion_reason), ip_fields: ~W(ip), bool_fields: ~W(deleted), aliases: diff --git a/lib/philomena/images/thumbnailer.ex b/lib/philomena/images/thumbnailer.ex index 1913289e..46ea318b 100644 --- a/lib/philomena/images/thumbnailer.ex +++ b/lib/philomena/images/thumbnailer.ex @@ -106,8 +106,13 @@ defmodule Philomena.Images.Thumbnailer do defp image_file(%Image{image: image}), do: Path.join(image_file_root(), image) - defp image_thumb_dir(%Image{created_at: created_at, id: id, hidden_from_users: true, hidden_image_key: key}), - do: Path.join([image_thumbnail_root(), time_identifier(created_at), "#{id}-#{key}"]) + defp image_thumb_dir(%Image{ + created_at: created_at, + id: id, + hidden_from_users: true, + hidden_image_key: key + }), + do: Path.join([image_thumbnail_root(), time_identifier(created_at), "#{id}-#{key}"]) defp image_thumb_dir(%Image{created_at: created_at, id: id}), do: Path.join([image_thumbnail_root(), time_identifier(created_at), to_string(id)]) diff --git a/lib/philomena_web/controllers/activity_controller.ex b/lib/philomena_web/controllers/activity_controller.ex index 359b5b07..5f03f4af 100644 --- a/lib/philomena_web/controllers/activity_controller.ex +++ b/lib/philomena_web/controllers/activity_controller.ex @@ -117,7 +117,7 @@ defmodule PhilomenaWeb.ActivityController do layout_class: "layout--wide" ) end - + def filter_hidden(featured_image, nil, _hidden) do featured_image end @@ -128,6 +128,13 @@ defmodule PhilomenaWeb.ActivityController do def filter_hidden(featured_image, user, _hidden) do featured_image - |> where([i], fragment("NOT EXISTS(SELECT 1 FROM image_hides WHERE image_id = ? AND user_id = ?)", i.id, ^user.id)) + |> where( + [i], + fragment( + "NOT EXISTS(SELECT 1 FROM image_hides WHERE image_id = ? AND user_id = ?)", + i.id, + ^user.id + ) + ) end end diff --git a/lib/philomena_web/controllers/image/delete_controller.ex b/lib/philomena_web/controllers/image/delete_controller.ex index 4cf041c4..92984db0 100644 --- a/lib/philomena_web/controllers/image/delete_controller.ex +++ b/lib/philomena_web/controllers/image/delete_controller.ex @@ -54,6 +54,7 @@ defmodule PhilomenaWeb.Image.DeleteController do case conn.assigns.image.hidden_from_users do true -> conn + _false -> conn |> put_flash(:error, "Cannot change hide reason on a non-hidden image!") diff --git a/lib/philomena_web/image_loader.ex b/lib/philomena_web/image_loader.ex index 0f211dc8..c0bb26b8 100644 --- a/lib/philomena_web/image_loader.ex +++ b/lib/philomena_web/image_loader.ex @@ -67,7 +67,7 @@ defmodule PhilomenaWeb.ImageLoader do end # Allow moderators to index hidden images - + defp maybe_show_deleted(filters, _show_hidden?, "1"), do: filters diff --git a/lib/philomena_web/router.ex b/lib/philomena_web/router.ex index 06cc509e..baa6d62f 100644 --- a/lib/philomena_web/router.ex +++ b/lib/philomena_web/router.ex @@ -158,7 +158,9 @@ defmodule PhilomenaWeb.Router do resources "/delete", Image.Comment.DeleteController, only: [:create], singleton: true end - resources "/delete", Image.DeleteController, only: [:create, :delete, :update], singleton: true + resources "/delete", Image.DeleteController, + only: [:create, :delete, :update], + singleton: true resources "/tamper", Image.TamperController, only: [:create], singleton: true resources "/hash", Image.HashController, only: [:delete], singleton: true