disallow tag self-aliasing

This commit is contained in:
Wren 2020-06-06 12:13:31 -04:00
parent 7f55c63303
commit 485d8be3b3

View file

@ -179,6 +179,9 @@ defmodule Philomena.Tags do
def alias_tag(%Tag{} = tag, attrs) do
target_tag = Repo.get_by!(Tag, name: attrs["target_tag"])
if(tag.id == target_tag.id) do
tag
else
filters_hidden =
where(Filter, [f], fragment("? @> ARRAY[?]::integer[]", f.hidden_tag_ids, ^tag.id))
@ -230,6 +233,7 @@ defmodule Philomena.Tags do
reindex_tag_images(target_tag)
reindex_tags([tag, target_tag])
end
end
def reindex_tag_images(%Tag{} = tag) do
# First recount the tag