diff options
author | Lain Soykaf <lain@lain.com> | 2024-06-06 19:14:38 +0400 |
---|---|---|
committer | Mark Felder <feld@feld.me> | 2024-06-12 15:20:04 -0400 |
commit | 41434ffcec47510de86cd9b06eb32521b897a1c9 (patch) | |
tree | 8d0518201897d0364dd70d9505599ecb5435963d /lib | |
parent | 6774ff15db93f037b2243a4515864c4d04b2d3e6 (diff) | |
download | pleroma-41434ffcec47510de86cd9b06eb32521b897a1c9.tar.gz pleroma-41434ffcec47510de86cd9b06eb32521b897a1c9.zip |
Tests: Don't spawn processes in tests.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/web/streamer.ex | 8 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 0c16749a4..963658b1e 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do require Pleroma.Constants alias Pleroma.Activity + alias Pleroma.Config alias Pleroma.HTML alias Pleroma.Maps alias Pleroma.Object @@ -30,7 +31,13 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do # pagination is restricted to 40 activities at a time defp fetch_rich_media_for_activities(activities) do Enum.each(activities, fn activity -> - spawn(fn -> Card.get_by_activity(activity) end) + fun = fn -> Card.get_by_activity(activity) end + + if Config.get([__MODULE__, :sync_fetching], false) do + fun.() + else + spawn(fun) + end end) end diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 7065fdab2..9abdfae30 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -172,7 +172,13 @@ defmodule Pleroma.Web.Streamer do def stream(topics, items) do if should_env_send?() do for topic <- List.wrap(topics), item <- List.wrap(items) do - spawn(fn -> do_stream(topic, item) end) + fun = fn -> do_stream(topic, item) end + + if Config.get([__MODULE__, :sync_streaming], false) do + fun.() + else + spawn(fun) + end end end end |