From ca860273a0ac32e55e51e093041c8158d7a34d11 Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Thu, 21 Apr 2022 14:54:39 +0200
Subject: [PATCH] Exclude tags with more than 40 characters from being
 extracted.

They are still in the HTML produced

Closes #562

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 lib/federation/activity_pub/types/events.ex | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/federation/activity_pub/types/events.ex b/lib/federation/activity_pub/types/events.ex
index 42d96d069..d6bc9113c 100644
--- a/lib/federation/activity_pub/types/events.ex
+++ b/lib/federation/activity_pub/types/events.ex
@@ -267,7 +267,15 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Events do
         Map.merge(args, %{
           description: description,
           mentions: mentions,
-          tags: tags
+          # Exclude tags with length > 40
+          tags:
+            Enum.filter(tags, fn tag ->
+              case tag do
+                # For some reason transmogrifier gives us this
+                %{title: tag} -> String.length(tag) < 40
+                tag -> String.length(tag) < 40
+              end
+            end)
         })
       else
         args