Avoid duplicate tags with different casing

Closes #562

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-04-21 14:55:30 +02:00
parent ca860273a0
commit 7b3ce8d812
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -281,6 +281,21 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Events do
args
end
# Make sure we don't have duplicate (with different casing) tags
args =
Map.update(
args,
:tags,
[],
&Enum.uniq_by(&1, fn tag ->
case tag do
# For some reason transmogrifier gives us this
%{title: tag} -> String.downcase(tag)
tag -> String.downcase(tag)
end
end)
)
# Check that we can only allow anonymous participation if our instance allows it
{_, options} =
Map.get_and_update(