From 7b3ce8d8124bf75f21b3ab4a192ae39d77fc7326 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 21 Apr 2022 14:55:30 +0200 Subject: [PATCH] Avoid duplicate tags with different casing Closes #562 Signed-off-by: Thomas Citharel --- lib/federation/activity_pub/types/events.ex | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/federation/activity_pub/types/events.ex b/lib/federation/activity_pub/types/events.ex index d6bc9113c..2016a417c 100644 --- a/lib/federation/activity_pub/types/events.ex +++ b/lib/federation/activity_pub/types/events.ex @@ -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(