From fa99c09c57d348c3b6039364a6756ee1f6ae7ad3 Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Wed, 31 Mar 2021 18:32:37 +0200
Subject: [PATCH] Use tasks to process refreshing elements

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

diff --git a/lib/federation/activity_pub/refresher.ex b/lib/federation/activity_pub/refresher.ex
index 57f67ba09..f28dd623b 100644
--- a/lib/federation/activity_pub/refresher.ex
+++ b/lib/federation/activity_pub/refresher.ex
@@ -114,7 +114,10 @@ defmodule Mobilizon.Federation.ActivityPub.Refresher do
 
     Logger.debug(inspect(items))
 
-    Enum.each(items, &handling_element/1)
+    items
+    |> Enum.map(fn item -> Task.async(fn -> handling_element(item) end) end)
+    |> Task.await_many()
+
     Logger.debug("Finished processing a collection")
     :ok
   end